Last active
May 28, 2019 23:51
-
-
Save hodzanassredin/9202887d9d6149ceab7d4c21a1633b62 to your computer and use it in GitHub Desktop.
process networks from Field Harrison
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
//networks | |
let rec from x = Seq.unfold (fun x -> Some(x,x+1)) x | |
let rec filter n xs = Seq.filter (fun m -> (m % n) <> 0) xs | |
let rec sieve (xs:seq<int>) = | |
let m = Seq.head xs | |
seq{yield m; yield! sieve <| filter m (Seq.tail xs) } | |
let incList xs = Seq.map ((+) 1) xs | |
let rec ints () = seq {yield 0; yield! incList <| ints()} | |
let rec cycle () = seq {yield 1; yield 2; yield! cycle ()} | |
let rec s2 () = | |
let ints k = seq {yield 0; yield! k} | |
let s1 = seq { yield! s2() |> incList} | |
ints s1 | |
let f k =seq {yield 1; yield! k} | |
let a xs1 xs2 = Seq.zip xs1 xs2|> Seq.map (fun (a,b) -> a+b) | |
let rec s1 () = | |
let rec s2 () = | |
let s3 = seq{ yield! a (s1()) (s2())} | |
f s3 | |
f (s2()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment