These are mostly inspired by the C++ function templates in the C++ standard library (include "functional"). That might seem an odd place to start, but the well-known FP languages such as Haskell do too much as part of the language to be a good starting point (for example, there is no explicit "curry" function in Haskell, because the language itself does it).
Static Public Member Functions | |
UnaryOp | bind1st (BinaryOp binary_op, Object arg1) |
return a unary function given a binary function and the first argument. | |
UnaryOp | bind2nd (BinaryOp binary_op, Object arg2) |
return a unary function given a binary function and the second argument. | |
Function | bind (func, arg1,...) |
Return a function with the supplied arguments bound. | |
UnaryPred | not1 (UnaryPred unary_pred) |
Return a unary predicate which reverses the sense of the provided unary predicate. | |
BinaryPred | not2 (BinaryPred binary_pred) |
Return a binary predicate which reverses the sense of the provided binary predicate. | |
ZeroaryOp | mem_fun0 (ZeroAryMemberFunction mem_func) |
Return a function which will bind 'this' to the object in its single argument, and call the provided member function. | |
UnaryOp | mem_fun1 (UnAryMemberFunction mem_func) |
Return a function which will bind 'this' to the object in its first argument, and call the provided member function with its second argument. | |
Function | mem_fn (MemberFunction mem_func) |
Like mem_fun but works with any number of arguments. | |
UnaryOp | compose_f_gx (UnaryOp f, UnaryOp g) |
For compose operations, we use the boost naming convention:. | |
UnaryOp | compose_f_gx_hx (BinaryOp f, UnaryOp g, UnaryOp h) |
f(g(value),h(value)) | |
BinaryOp | compose_f_gx_hy (BinaryOp f, UnaryOp g, UnaryOp h) |
f(g(value1),h(value2)) | |
BinaryOp | compose_f_gxy (UnaryOp f, BinaryOp g) |
f(g(value1,value2)) | |
ZeroaryOp | compose_f_g (ZeroaryOp f, ZeroaryOp g) |
f(g()) | |
Function | compose (UnaryOp f, Function g) |
Generic compose. | |
Function | compose_sort (BinaryOp secondary, BinaryOp primary) |
compose two sort comparators. |
|
Return a function with the supplied arguments bound. The variable args supplied are matched positionally to the parameters of the supplied function. The caller can pass in one of the constants burst.Functional._1, burst.Functional._2, etc. to indicate that the function func should be called with the first, second, etc. argument of the returned function.
For example: See http://www.boost.org/libs/bind/bind.html
|
|
Generic compose. The returned function calls f(g(...)). The function f is unary. The returned function and g take the same number of arguments. |
|
For compose operations, we use the boost naming convention:.
|
|
compose two sort comparators. The secondary is applied only if the primary returns 0. |
|
Like mem_fun but works with any number of arguments. See http://www.boost.org/libs/bind/mem_fn.html
|
|
Return a function which will bind 'this' to the object in its single argument, and call the provided member function.
An example might be |
|
Return a function which will bind 'this' to the object in its first argument, and call the provided member function with its second argument.
An example might be (Note that the C++ mem_fun function template will work with zeroary or unary functions. Unless the function counts its arguments, mem_fun1 could be used as mem_fun.) |