Skip to content

Instantly share code, notes, and snippets.

@dscleaver
dscleaver / Fib.scala
Created February 27, 2013 14:45
Port of http://t.co/KvoY7PDGSg. Created in a Scala IDE worksheet.
import scalaz._
import Scalaz._
object monads {
def fix[A](f: (=> A) => A): A = f(fix(f)) //> fix: [A](f: => A => A)A
type Gen[A] = (=> A) => A
def gFib: Gen[Int => Int] = (self) => n =>
@dscleaver
dscleaver / Sieve.mag
Created June 14, 2011 16:33
Implementation of the Sieve of Eratosthenes in Magpie
import async
import lazy
import chanutils
def spawnGenerator(channel is Channel)
run with for i = count(from: 2) do channel send(i)
end
def spawnFilter(in is Channel, prime is Int)
val out = Channel new(1)