diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-07-25 15:05:34 +0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-07-25 15:05:34 +0000 |
commit | 991a130b1e71b3b849b3640264f8834d6e13da22 (patch) | |
tree | 1e99a52b73043814fa501c8d470a933d2bc7cded /src/libexpr/eval.cc | |
parent | e6899794ae9ce3924b818721d5caff463bccd60c (diff) |
* Added a list concatenation operator:
[1 2 3] ++ [4 5 6] => [1 2 3 4 5 6]
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index d4593b5c0..9a6d414db 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -140,6 +140,15 @@ bool evalBool(EvalState & state, Expr e) } +ATermList evalList(EvalState & state, Expr e) +{ + e = evalExpr(state, e); + ATermList list; + if (!matchList(e, list)) throw Error("list expected"); + return list; +} + + Expr evalExpr2(EvalState & state, Expr e) { Expr e1, e2, e3, e4; @@ -336,6 +345,13 @@ Expr evalExpr2(EvalState & state, Expr e) else throw Error("wrong argument types in `+' operator"); } + /* List concatenation. */ + if (matchOpConcat(e, e1, e2)) { + ATermList l1 = evalList(state, e1); + ATermList l2 = evalList(state, e2); + return makeList(ATconcat(l1, l2)); + } + /* Barf. */ throw badTerm("invalid expression", e); } |