package net.ciklum.icfpc11.domain.greenspoon10 import net.ciklum.icfpc11.domain.GameError /** * blabla * @author vic */ @Typed class ConstantFunction extends Function { final static ConstantFunction ZERO = new ConstantFunction(0) final int value ConstantFunction(int value) { this.value = value } static ConstantFunction valueOf(int value) { (value == 0) ? ZERO : new ConstantFunction(value) } @Override boolean canEvaluate() { true } @Override Function apply(Function arg) { throw new GameError("You cannot apply() constant $value (tried applying to $arg)!") } boolean isValidSlotNumber() { this.@value >= 0 && this.@value <= 255 } String toString() { value == 0 ? 'zero' : "const($value)" } }