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/modules/eval/eval.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 'cpp/sca/modules/eval/eval.hpp')
-rw-r--r-- | cpp/sca/modules/eval/eval.hpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/cpp/sca/modules/eval/eval.hpp b/cpp/sca/modules/eval/eval.hpp index 783f5c6447..0f6ef77904 100644 --- a/cpp/sca/modules/eval/eval.hpp +++ b/cpp/sca/modules/eval/eval.hpp @@ -87,7 +87,7 @@ const list<value> operands(const value& exp) { } const list<value> listOfValues(const list<value> exps, Env& env) { - if(exps == list<value> ()) + if(isNil(exps)) return list<value> (); return cons(eval(car(exps), env), listOfValues(cdr(exps), env)); } @@ -117,7 +117,7 @@ const Env procedureEnvironment(const value& exp) { } const bool isLastExp(const list<value>& seq) { - return cdr(seq) == list<value> (); + return isNil(cdr(seq)); } const value firstExp(const list<value>& seq) { @@ -151,7 +151,7 @@ const value applyProcedure(const value& procedure, list<value>& arguments) { } const value sequenceToExp(const list<value> exps) { - if(exps == list<value> ()) + if(isNil(exps)) return list<value>(); if(isLastExp(exps)) return firstExp(exps); @@ -179,7 +179,7 @@ const value ifConsequent(const value& exp) { } const value ifAlternative(const value& exp) { - if(cdr(cdr(cdr((list<value> )exp))) != list<value> ()) + if(!isNil(cdr(cdr(cdr((list<value> )exp))))) return car(cdr(cdr(cdr((list<value> )exp)))); return false; } @@ -201,12 +201,12 @@ const value makeIf(value predicate, value consequent, value alternative) { } const value expandClauses(const list<value>& clauses) { - if(clauses == list<value> ()) + if(isNil(clauses)) return false; const value first = car(clauses); const list<value> rest = cdr(clauses); if(isCondElseClause(first)) { - if(rest == list<value> ()) + if(isNil(rest)) return sequenceToExp(condActions(first)); std::cout << "else clause isn't last " << clauses << "\n"; return value(); |