Skip to content

Instantly share code, notes, and snippets.

View Varriount's full-sized avatar

Clay Sweetser Varriount

View GitHub Profile
@Varriount
Varriount / vccDynAlloc.nim
Created January 31, 2014 20:40
Dynamic Allocation Test
when isMainModule:
var x = newSeq[string]()
x.add("Hello")
x.add(" and ")
x.add("Goodbye")
echo($x[0], $x[1], $x[2])
@Varriount
Varriount / transpose.nim
Created February 1, 2014 05:14
Use varargs for even more awesomeness!
iterator transpose[T](groups: seq[seq[T]]): seq[T] =
let maxLen = groups[0].len - 1
for i in 0..maxLen:
var selection: seq[T] = @[]
for group in groups:
selection.add(group[i])
yield selection
when isMainModule:
var foo = @[@[1,2,3,4],@[5,6,7,8],@[9,10,11,12]]
2/2/2014 4:50:52 PM - Microsoft VSIX Installer
2/2/2014 4:50:52 PM - -------------------------------------------
2/2/2014 4:50:52 PM - Initializing Install...
2/2/2014 4:50:53 PM - Extension Details...
2/2/2014 4:50:53 PM - Identifier : 2d33766d-5a12-49b5-9e70-80530a3eba98
2/2/2014 4:50:53 PM - Name : NimrodVS
2/2/2014 4:50:53 PM - Author : Company
2/2/2014 4:50:53 PM - Version : 0.4
2/2/2014 4:50:53 PM - Description : Adds nimrod support to visual studio
2/2/2014 4:50:53 PM - Locale : en-US
@Varriount
Varriount / output.txt
Last active August 29, 2015 13:56
Iterator bug
C:\64\Nimrod>nimrod c --run test.nim
config\nimrod.cfg(37, 2) Hint: added path: 'C:\Users\Clay\.babel\pkgs\windows-1.0' [Path]
config\nimrod.cfg(37, 2) Hint: added path: 'C:\Users\Clay\.babel\pkgs\babel-0.1.0' [Path]
config\nimrod.cfg(37, 2) Hint: added path: 'C:\Users\Clay\.babel\pkgs\' [Path]
Hint: used config file 'C:\64\nimrod\config\nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: test [Processing]
Hint: os [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
## Nimrod Itertools, based on the python itertools module
## Written by Clay Sweetser
##
## Please note that, like the nimrod countX iterators, anything
## dealing with ranges is inclusive.
## Also note that, while efforts have been made to make these iterators
## Resistant to errors regarding parameters which change from iteration
## to iteration, nothing can be guaranteed.
discard """
Unfinished iterators:
@Varriount
Varriount / itertools.nim
Created February 9, 2014 05:50
Portion of Itertools module
iterator cycle*[iterT, returnT](iter: iterT): returnT =
## An iterator returning elements from the iterable and saving a
## copy of each. When the iterable is exhausted, return elements
## from the saved copy. Repeats indefinitely.
##
## Parameters:
## iter: The iterator to cycle through
var cont: seq[returnT] = @[]
for element in iter:
type filterProc[T] = proc (value:T): bool {.closure.}
iterator dropWhile* [iT, rT](predicate: filterProc[rT], iter: iT): rT =
## An iterator that drops (skips) elements from the iterable as long as the
## predicate is true; afterwards, returns every element.
## Note, this version of the iterator does not produce any output until
## the predicate first becomes false, so it may have a lengthy start-up time.
var
broken = false
element: rT
@Varriount
Varriount / Coroutine Implementations
Created February 12, 2014 18:55
Links to coroutine implementations in C
Links to C implementations of coroutines
----------------------------------------
http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html (Macro based)
http://swtch.com/libtask/ (FreeBSD, Linux, OS X, and Solaris only)
http://xmailserver.org/libpcl.html (Multi-OS)
https://github.com/halayli/lthread (Multi-OS, Makes use of fibers on windows, I think)
https://github.com/stevedekorte/coroutine/tree/master (Multi-OS, also uses fibers on windows)
https://code.google.com/p/libconcurrency/ (Multi-OS, has multiple implementations, I think)
http://software.schmorp.de/pkg/libcoro.html (Limited to Unix, Linux, and related OS's)
FTP: Uploading C:\32\nimbuild\Outgoing\commits\windows-x86\902ef5ce8f5c\testresults.html to testresults.html
Got message from hub: { "fatal": "Traceback (most recent call last)\u000Awebsite.nim(1109) website\u000Aasyncio.n
im(631) poll\u000Aasyncio.nim(212) asyncSockHandleRead\u000Awebsite.nim(141) :anonymous\u000Aweb
site.nim(589) handleModuleMsg\u000Awebsite.nim(303) parseMessage\u000Atypes.nim(35) jobInProg
ress\u000Asystem.nim(2555) hiddenRaiseAssert\u000Asystem.nim(1844) raiseAssert\u000A"}
FATAL ERROR
"Traceback (most recent call last)\u000Awebsite.nim(1109) website\u000Aasyncio.nim(631) poll\u000Aasyncio
.nim(212) asyncSockHandleRead\u000Awebsite.nim(141) :anonymous\u000Awebsite.nim(589) handleModul
eMsg\u000Awebsite.nim(303) parseMessage\u000Atypes.nim(35) jobInProgress\u000Asystem.nim(2555)
hiddenRaiseAssert\u000Asystem.nim(1844) raiseAssert\u000A"
[#SPYBOT: 1, #sLevel: 3, #credits: 4347850, #agents: ["Hack", "Sensor", "Slingshot", "Bug", "Hack", "Bug", "Slingshot", "Data Doctor", "Data Doctor", "Frag-Man", "Frag-Man", "Hack 2.0", "Hack 2.0", "Clog.01", "Wolf Spider", "Wolf Spider", "Golem.mud", "Golem.mud", "Silo", "Silo", "Medic", "Medic", "Turbo", "Turbo", "Seeker", "Seeker", "Wolf Spider", "Frag-Man", "Frag-Man", "Black Widow", "Black Widow", "Hack 3.0", "Clog.02", "Turbo Deluxe", "Turbo Deluxe", "Clog.02", "Data Doctor Pro", "Data Doctor Pro", "Ballista", "Ballista", "Satellite", "Satellite", "SCUD", "SCUD", "Seeker 2.0", "Seeker 2.0", "Fiddle", "Fiddle", "BuzzBomb", "BuzzBomb", "MandelBug", "MandelBug", "Golem.clay", "Golem.clay"], #nodes: [#WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #WIN, #off, #on, #WIN, #on, #off, #off, #off, #off, #off, #off, #WIN, #on, #on, #on, #off, #off, #off, #off, #off, #off, #off, #off]]