1 module orelang.operator.RemoveOperator;
2 import orelang.expression.ImmediateValue,
3        orelang.expression.IExpression,
4        orelang.operator.IOperator,
5        orelang.Closure,
6        orelang.Engine,
7        orelang.Value;
8 import std.algorithm,
9        std.array;
10 
11 class RemoveOperator : IOperator {
12   /**
13    * call
14    */
15   public Value call(Engine engine, Value[] args) {
16     Value efunc = engine.eval(args[0]);
17     Value[] eargs1 = engine.eval(args[1]).getArray;
18     Value[] ret;
19 
20     foreach (elem; eargs1) {
21       bool cnd;
22 
23       if (efunc.type == ValueType.Closure) {
24         cnd = efunc.getClosure.eval([elem]).getBool;
25       } else {
26         cnd = efunc.getIOperator.call(engine, [elem]).getBool;
27       }
28 
29       if (!cnd) {
30         ret ~= elem;
31       }
32     }
33 
34     return new Value(ret);
35   }
36 }