aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-07-25 15:05:34 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-07-25 15:05:34 +0000
commit991a130b1e71b3b849b3640264f8834d6e13da22 (patch)
tree1e99a52b73043814fa501c8d470a933d2bc7cded /src/libexpr/primops.cc
parente6899794ae9ce3924b818721d5caff463bccd60c (diff)
* Added a list concatenation operator:
[1 2 3] ++ [4 5 6] => [1 2 3 4 5 6]
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index b0986028e..5736a7f91 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -414,17 +414,13 @@ static Expr primIsNull(EvalState & state, const ATermVector & args)
static Expr primMap(EvalState & state, const ATermVector & args)
{
Expr fun = evalExpr(state, args[0]);
- Expr list = evalExpr(state, args[1]);
+ ATermList list = evalList(state, args[1]);
- ATermList list2;
- if (!matchList(list, list2))
- throw Error("`map' expects a list as its second argument");
-
- ATermList list3 = ATempty;
- for (ATermIterator i(list2); i; ++i)
- list3 = ATinsert(list3, makeCall(fun, *i));
+ ATermList res = ATempty;
+ for (ATermIterator i(list); i; ++i)
+ res = ATinsert(res, makeCall(fun, *i));
- return makeList(ATreverse(list3));
+ return makeList(ATreverse(res));
}
@@ -449,9 +445,7 @@ static Expr primRemoveAttrs(EvalState & state, const ATermVector & args)
ATermMap attrs;
queryAllAttrs(evalExpr(state, args[0]), attrs, true);
- ATermList list;
- if (!matchList(evalExpr(state, args[1]), list))
- throw Error("`removeAttrs' expects a list as its second argument");
+ ATermList list = evalList(state, args[1]);
for (ATermIterator i(list); i; ++i)
/* It's not an error for *i not to exist. */