Hacker News .hnnew | past | comments | ask | show | jobs | submitlogin

Because functional languages discourage loops. This is just a really trivial example, but:

    # value x =[|1;2;3;4|];
    value x : array int = [|1; 2; 3; 4|]
    # for i = 0 to (Array.length x) - 1 do {
      Printf.printf "%d" x.(i);
      };
    1234- : unit = ()
    # Array.iter (fun y -> Printf.printf "%d" y) x;
    1234- : unit = ()
Basically the entire body of any for loop I would want to make an anonymous function. Then if I cared about the result I could do:

    # Array.map (fun y -> Printf.printf "%d" y) x;
    1234- : array unit = [|(); (); (); ()|]

Assuming the underlying platform supported it, and the function is pure, that's "free" parallelism.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: