Skip to content

Instantly share code, notes, and snippets.

View bluenote10's full-sized avatar

Fabian Keller bluenote10

  • Bosch
  • Ludwigsburg, Germany
View GitHub Profile
@bluenote10
bluenote10 / gist:fc7907f2538606912799
Created April 29, 2015 14:52
Issues with Channel
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.} =
@bluenote10
bluenote10 / CrossProduct.scala
Last active December 16, 2015 16:49
Scala: cross (cartesian) product with multiple sources and heterogeneous types. More information: http://stackoverflow.com/q/16219545/1804173
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)
}