Settings

Theme

Making the obvious code fast

jackmott.github.io

23 points by dalailambda 9 years ago · 2 comments

Reader

Nelkins 9 years ago

Great work on the SIMDArray extensions, always nice to get speed while maintaining a functional style.

BTW, I don't think you need a third party library like Nessos to get that streaming behavior (iterating over the items in a single pass). Seq will do the job just fine. For example this code:

    let arr = [|1;2;3|]

    let sumSquares =
        arr
        |> Seq.map (fun x -> printfn "%i map" x; x*x)
        |> Seq.fold(fun sum x -> printfn "%i fold" x; sum + x)
will produce this output in F# Interactive:

    > 
    1 map
    1 fold
    2 map
    4 fold
    3 map
    9 fold

    val arr : int [] = [|1; 2; 3|]
    val sumSquares : int = 14
camkego 9 years ago

Nice article!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection