1 module orelang.operator.CdrOperator; 2 import orelang.operator.IOperator, 3 orelang.Engine, 4 orelang.Value; 5 import std.conv; 6 7 class CdrOperator : IOperator { 8 /** 9 * call 10 */ 11 public Value call(Engine engine, Value[] args) { 12 Value obj = engine.eval(args[0]); 13 14 if (obj.type == ValueType.Array) { 15 Value[] obx = obj.getArray; 16 17 if (obx.length == 1) { 18 Value[] arr; 19 return new Value(arr); 20 } else if (obx.length > 1) { 21 return new Value(obx[1..$]); 22 } else { 23 throw new Exception("pair required, but got ()"); 24 } 25 } else { 26 throw new Exception("pair required, but got invalid data, the type of which is " ~ obj.type.to!string); 27 } 28 } 29 }