Saturday, August 20, 2011

Studying F# : ignore

POSIX shell has /dev/null - a kind of redirect target to ignore standard outputs and error outputs. In F#, there is a similar function, the name is ignore. To illustrate along the examples in Studying F# : Accumulator, pipe and composition, all the functions using |> ignore return unit.
> let fizzBuzzMapper data =
-     List.map ( fun elem -> (elem, (elem % 3 = 0), (elem % 5 = 0) ) ) data;;

val fizzBuzzMapper : int list -> (int * bool * bool) list

> [1..40] |> fizzBuzzMapper |> ignore;;
val it : unit = ()

No comments:

Post a Comment