Chapter 5:
Streams and Higher-Order Primitives

Streams

Higher-Order Functions

Some Daisy primitives return closures as their result. Usually, the function returned has been specialized for a particular task based on the arguments that were passed to the primitive that created it. A good example is Daisy's map primitive. map takes a function FA as an argument and returns a function FB that maps FA over a list.
map: FA         => FB
FB:L            => FA mapped over L
Some functional programming languages curry all primitives and functions, meaning that all primitives and functions take exactly one argument. Daisy only makes use of higher-order functions in certain cases.
map: FA	           => FB
FB: [V0 V1 V2 ...] => [FA:V0 FA:V1 FA:V2 ...]
smap: FA           => FB
FB: [V0 V1 V2 ...] => [FA:V0 FA:V1 FA:V2 ...]
map is the simplest of Daisy's built-in map makers. It takes a closure as its sole argument, returning a new function that maps that closure over a list. To Lisp programmers who are used to the uncurried form of map, this form may seem onerous, but it turns out to be quite useful if you are using the same mapper more than once. If you want to apply the mapper without creating a binding to it you can simply nest the mapper application (remember that application associates to the right):
(map: FA): [V0 V1 V2 ...] => [FA:V0 FA:V1 FA:V2 ...]

smap stands for sequential map. Functionally, smap is identical to map, but differs operationally in that elements in the result are guaranteed to be computed sequentially; e.g. FA:V2 is guaranteed to be computed before FA:V3 , even if there is no dependence between them. smap is a bit more efficient (in terms of space used), than map, and can be used when the implied dependence is known or desired.

Functional Combination

fc: [F0 F1 F2 ...]	=> FFC
FFC: [[V00 V01 V02 ...]
      [V10 V11 V12 ...]
       ...
      [VN0 VN1 VN2 ...]] => [F0:[V00 V01 V02 ...] F1:[V10 V11 V12 ...]...]
fc stands for functional combination. This is a very powerful mapper that allows you to specify a matrix of function mappings. fc takes a list of functions and returns a new closure. When this closure is applied to a list of lists, the functions are applied column-wise, as if the argument lists were rows of values.

With a little thought you can see that the list of lists argument is being transposed, followed by