Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

burst.Functional Class Reference

List of all members.

Detailed Description

Scoping class to hold static functions for functional programming.

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.


Member Function Documentation

Function burst.Functional.bind func  ,
arg1  ,
... 
[static]
 

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:burst.Functional.bind(op, burst.Functional._2, burst.Functional._1, 17) returns a binary function f(x,y) which will call op(y,x,17).

See http://www.boost.org/libs/bind/bind.html

Todo:
finish implementation of bind

Function burst.Functional.compose UnaryOp  f,
Function  g
[static]
 

Generic compose.

The returned function calls f(g(...)). The function f is unary. The returned function and g take the same number of arguments.

UnaryOp burst.Functional.compose_f_gx UnaryOp  f,
UnaryOp  g
[static]
 

For compose operations, we use the boost naming convention:.

f(g(value)) compose_f_gx C++ compose1 f(g(value),h(value)) compose_f_gx_hx C++ compose2 f(g(value1),h(value2)) compose_f_gx_hy f(g(value1,value2)) compose_f_gxy f(g()) compose_f_g
See http://www.josuttis.com/cppcode/compose.html

Function burst.Functional.compose_sort BinaryOp  secondary,
BinaryOp  primary
[static]
 

compose two sort comparators.

The secondary is applied only if the primary returns 0.

Function burst.Functional.mem_fn MemberFunction  mem_func  )  [static]
 

Like mem_fun but works with any number of arguments.

See http://www.boost.org/libs/bind/mem_fn.html

Todo:
finish implementation of mem_fn

ZeroaryOp burst.Functional.mem_fun0 ZeroAryMemberFunction  mem_func  )  [static]
 

Return a function which will bind 'this' to the object in its single argument, and call the provided member function.

An example might be burst.Functional.mem_fun0(Person.prototype.kill)(myperson).

UnaryOp burst.Functional.mem_fun1 UnAryMemberFunction  mem_func  )  [static]
 

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 burst.Functional.mem_fun1(Person.prototype.setManager)(myperson, mgr).

(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.)


The documentation for this class was generated from the following file:
Generated on Tue Nov 30 04:03:08 2004 for BurstProject by doxygen 1.3.4