Module std.functional
Functional programming.
Functions
bind (f, ...) | Partially apply a function. |
collect (i) | Collect the results of an iterator. |
compose () | Compose functions. |
curry (f, n) | Curry a function. |
eval (s) | Evaluate a string. |
filter (p, i) | Filter an iterator with a predicate. |
fold (f, d, i) | Fold a binary function into an iterator. |
id (...) | Identity function. |
map (f, i) | Map a function over an iterator. |
memoize (fn) | Memoize a function, by wrapping it in a functable. |
metamethod (x, n) | Return given metamethod, if any, or nil. |
Tables
op | Functional forms of infix operators. |
Functions
- bind (f, ...)
-
Partially apply a function.
Parameters:
- f function to apply partially
- ... arguments to bind
Returns:
-
function with ai already bound
- collect (i)
-
Collect the results of an iterator.
Parameters:
- i iterator
Returns:
-
results of running the iterator on its arguments
- compose ()
-
Compose functions.
Returns:
-
composition of f1 ... fn
- curry (f, n)
-
Curry a function.
Parameters:
- f function to curry
- n number of arguments
Returns:
-
curried version of f
- eval (s)
-
Evaluate a string.
Parameters:
- s string
Returns:
-
value of string
- filter (p, i)
-
Filter an iterator with a predicate.
Parameters:
- p predicate
- i iterator
Returns:
-
result table containing elements e for which p (e)
- fold (f, d, i)
-
Fold a binary function into an iterator.
Parameters:
- f function
- d initial first argument
- i iterator
Returns:
-
result
- id (...)
-
Identity function.
Parameters:
- ...
Returns:
-
the arguments passed to the function
- map (f, i)
-
Map a function over an iterator.
Parameters:
- f function
- i iterator
Returns:
-
result table
- memoize (fn)
-
Memoize a function, by wrapping it in a functable.
Parameters:
- fn function that returns a single result
Returns:
-
memoized function
- metamethod (x, n)
-
Return given metamethod, if any, or nil.
Parameters:
- x object to get metamethod of
- n name of metamethod to get
Returns:
-
metamethod function or nil if no metamethod or not a
function