diff options
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r-- | src/libexpr/primops.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index aa27df6ad..f5c004044 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -931,6 +931,7 @@ static void prim_filter(EvalState & state, Value * * args, Value & v) } +/* Return true if a list contains a given element. */ static void prim_elem(EvalState & state, Value * * args, Value & v) { bool res = false; @@ -944,6 +945,14 @@ static void prim_elem(EvalState & state, Value * * args, Value & v) } +/* Concatenate a list of lists. */ +static void prim_concatLists(EvalState & state, Value * * args, Value & v) +{ + state.forceList(*args[0]); + state.concatLists(v, args[0]->list.length, args[0]->list.elems); +} + + /* Return the length of a list. This is an O(1) time operation. */ static void prim_length(EvalState & state, Value * * args, Value & v) { @@ -1160,6 +1169,7 @@ void EvalState::createBaseEnv() addPrimOp("map", 2, prim_map); addPrimOp("__filter", 2, prim_filter); addPrimOp("__elem", 2, prim_elem); + addPrimOp("__concatLists", 1, prim_concatLists); addPrimOp("__length", 1, prim_length); // Integer arithmetic |