1 module orelang.operator.CondOperator;
2 import orelang.operator.IOperator,
3        orelang.Engine,
4        orelang.Value;
5 
6 class CondOperator : IOperator {
7   /**
8    * call
9    */
10   public Value call(Engine engine, Value[] args) {
11     for (size_t i; i < args.length; ++i) {
12       Value[] state = args[i].getArray;
13       Value pred = state[0];
14       Value expr = state[1];
15 
16       Value epred = engine.eval(pred);
17 
18       if ((epred.type == ValueType.Bool && epred.getBool) || ((pred.type == ValueType.SymbolValue || pred.type == ValueType.String) && pred.getString == "else")) {
19         return engine.eval(expr);
20       }
21     }
22 
23     return new Value(0.0);
24   }
25 }