From 991a130b1e71b3b849b3640264f8834d6e13da22 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 25 Jul 2005 15:05:34 +0000 Subject: * Added a list concatenation operator: [1 2 3] ++ [4 5 6] => [1 2 3 4 5 6] --- src/libexpr/eval.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/libexpr/eval.cc') 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); } -- cgit v1.2.3