diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-11 00:01:04 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-11 00:01:04 +0000 |
commit | a64c1ec2a50f62d63872eac6bc740966602e87bd (patch) | |
tree | e4eab2e74b82eb51c4a5d9b3a132506895974f93 /cpp/sca/kernel/function.hpp | |
parent | 89246640ca239097800fed58e7abc5bc050e3f56 (diff) |
Some code cleanup, removed unused functions, changed == empty-list to isNil to avoid unnecessary construction of empty lists, replaced some casts by generic declarations. Added simple maybe, failable and state monad classes to help return optional objects or failures and carry state around. Added utility functions to zip and unzip list.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@823981 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | cpp/sca/kernel/function.hpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/cpp/sca/kernel/function.hpp b/cpp/sca/kernel/function.hpp index 07b4111239..c22a93c715 100644 --- a/cpp/sca/kernel/function.hpp +++ b/cpp/sca/kernel/function.hpp @@ -174,13 +174,6 @@ template<typename S> std::ostream& operator<<(std::ostream& out, const lambda<S> } /** - * Creates a lambda function from a pointer to a function. - */ -template<typename R, typename... P> lambda<R(P...)> makeLambda(const R (* const f)(P...)) { - return lambda<R(P...)>(f); -} - -/** * Curry a lambda function. */ template<typename R, typename T, typename... P> class curried { @@ -198,7 +191,7 @@ private: }; template<typename R, typename T, typename... P> const lambda<R(P...)> curry(const lambda<R(T, P...)>& f, const T& t) { - return (lambda<R(P...)>)curried<R, T, P...>(f, t); + return curried<R, T, P...>(f, t); } template<typename R, typename T, typename U, typename... P> const lambda<R(P...)> curry(const lambda<R(T, U, P...)>& f, const T& t, const U& u) { @@ -212,9 +205,9 @@ template<typename R, typename T, typename U, typename V, typename... P> const la /** * A lambda function that returns the given value. */ -template<typename T> class unitReturn { +template<typename T> class returnResult { public: - unitReturn(const T& v) : + returnResult(const T& v) : v(v) { } const T operator()() const { @@ -224,8 +217,8 @@ private: const T v; }; -template<typename T> const lambda<T()> unit(const T& v) { - return lambda<T()> (unitReturn<T> (v)); +template<typename T> const lambda<T()> result(const T& v) { + return returnResult<T> (v); } } |