1 module orelang.operator.ConsOperator;
2 import orelang.operator.IOperator,
3        orelang.Engine,
4        orelang.Value;
5 
6 class ConsOperator : IOperator {
7   /**
8    * call
9    */
10   public Value call(Engine engine, Value[] args) {
11     Value car = engine.eval(args[0]);
12     Value cdr = engine.eval(args[1]);
13 
14     Value[] ret = [car];
15 
16     if (cdr.type == ValueType.Array) {
17       foreach (elem; cdr.getArray) {
18         ret ~= engine.eval(elem);
19       }
20     } else {
21       ret ~= cdr;
22     }
23 
24     return new Value(ret);
25   }
26 }