-
Notifications
You must be signed in to change notification settings - Fork 106
New apis
nilsbecker edited this page Sep 18, 2014
·
8 revisions
#Features provided by Batteries
This operator is commonly used to give code a dataflow structure. Since 4.01 this is included in standard OCaml.
Everything converts to and from an Enum, an efficient enumeration type.
Instead of a for
loop with body f:int -> unit
, one can write (1--n) |> iter f
.
To convert between a List
and a Set
, write List.enum lst |> Set.of_enum
.
General purpose Input/Output channels
###Return Same as http://ocaml.janestcapital.com/?q=node/91 but with slightly different names.
Data structure modules provide a print
function that can be used with Printf.printf
like this:
Printf.printf "Int is: %a" Int.print 5
This is pretty boring, until you realize that polymorphic containers' print
functions are composable:
Printf.printf "Pair: %a, List:%a\n" (Pair.print String.print Float.print) ("abc",3.14) (List.print Int.print) [3;4;5]