This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, threadpool | |
proc spawnBackgroundJob[T](f: iterator (): int): TChannel[T] = | |
type Args = tuple[iter: iterator (): T, channel: ptr TChannel[T]] | |
#type Args = tuple | |
# iter: iterator (): T | |
# channel: ptr TChannel[T] | |
proc threadFunc(args: Args) {.thread.} = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait CrossProduct[A,B,C] { | |
def cross( as: Traversable[A], bs: Traversable[B] ): Traversable[C] | |
} | |
trait LowPriorityCrossProductImplicits { | |
private type TV[X] = Traversable[X] | |
implicit def crosser2[A,B] = new CrossProduct[A,B,(A,B)] { | |
def cross( as: TV[A], bs: TV[B] ): TV[(A,B)] = for { a <- as; b <- bs } yield (a, b) | |
} |
NewerOlder