1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

* Added a list concatenation operator:

[1 2 3] ++ [4 5 6] => [1 2 3 4 5 6]
This commit is contained in:
Eelco Dolstra 2005-07-25 15:05:34 +00:00
parent e6899794ae
commit 991a130b1e
8 changed files with 29 additions and 12 deletions

View file

@ -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);
}