![]() | ![]() | ![]() | Mapping | Documentation and user's manual | Table of contents | OCaml programs |
Consider the following codes
|
Look at the definitions of map_twice and map_length .
Clearly their structures are similar.
Transform what is identical in them into a functional value (named
|
The type of map_to_all is
|
An example of application of the higher-order function map_to_all :
Now an example of application of the result of this application of the higher-order function
|
Note that map_to_all and List.map (the function map provided by the Objective Caml module List ) have the same value.
|
Finally note that the value of map_to_all can also be recursively defined:
|
![]() | ![]() | ![]() | Mapping | Documentation and user's manual | Table of contents | OCaml programs |