Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Yet Another Functional Programming Thread

Name: Anonymous 2011-10-10 18:42

I must say after trying the pure part of F#, I am really starting to like functional programming. If You had to use a completely pure functional programming language, which one would it be?

Here is Sieve of Eratosthenes (I know it's pig disgusting):


(* eratosthenes: the sieve of eratosthenes for |N \ {0,1} *)
let eratosthenes n =
    let list = 2::[3 .. 2 .. n]
    let rec sieve list acc =
        match (list,acc) with
        | ([],acc) -> []
        | (a::b,acc) -> a::(sieve (List.filter(fun x -> x % a <> 0) b) (a + 1))
    sieve list (List.head list) ;;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List