🐐 First order functions
This commit is contained in:
11
snippets/invoca_expr.cent
Normal file
11
snippets/invoca_expr.cent
Normal file
@@ -0,0 +1,11 @@
|
||||
// Immediately invoked
|
||||
DICE(INVOCA FVNCTIO (x) VT { REDI (x + I) } (V))
|
||||
|
||||
// From an array
|
||||
DESIGNA fns VT [FVNCTIO (x) VT { REDI (x + I) }]
|
||||
DICE(INVOCA fns[I] (V))
|
||||
|
||||
// Passing a named function as an argument
|
||||
DEFINI apply (f, x) VT { REDI (INVOCA f (x)) }
|
||||
DEFINI sqr (x) VT { REDI (x * x) }
|
||||
DICE(INVOCA apply (sqr, IV))
|
||||
Reference in New Issue
Block a user