g = defs >> fun
The new function g works as follows. The value of g args, say, is obtained by evaluation of (fun opts)(args'), where args' is obtained from args by removing the options of the form X=>A (where X is a name of an optional argument), and opts is a hash table of the same form as defs in which the default values have been replaced by the user-supplied values, e.g., the value stored under the key X has been replaced by A.
Remark: defs can also be simply a list of options.
In the following example we use a simple definition for fun so we can see everything that fun receives.
|
|
|
|
|
|