refactoring aoc
This commit is contained in:
@@ -259,6 +259,7 @@ class Helpers {
|
||||
ReaderExpDef: ReaderExpDef
|
||||
},
|
||||
Operand: {
|
||||
toDynamic: Operand.toDynamic,
|
||||
fromDynamic: Operand.fromDynamic
|
||||
}
|
||||
});
|
||||
|
@@ -20,6 +20,13 @@ class KissInterp extends Interp {
|
||||
this.nullForUnknownVar = nullForUnknownVar;
|
||||
|
||||
variables.set("Prelude", Prelude);
|
||||
variables.set("kiss", {
|
||||
Operand: {
|
||||
fromDynamic: Operand.fromDynamic,
|
||||
toDynamic: Operand.toDynamic
|
||||
}
|
||||
});
|
||||
trace(variables["kiss"]);
|
||||
variables.set("Lambda", Lambda);
|
||||
variables.set("Std", Std);
|
||||
variables.set("Keep", ExtraElementHandling.Keep);
|
||||
|
@@ -192,7 +192,11 @@ class Macros {
|
||||
conditionInterp.variables.set(flag, value);
|
||||
}
|
||||
try {
|
||||
var conditionHScript = parser.parseString(Prelude.convertToHScript(conditionStr));
|
||||
var hscriptStr = Prelude.convertToHScript(conditionStr);
|
||||
#if test
|
||||
Prelude.print(hscriptStr);
|
||||
#end
|
||||
var conditionHScript = parser.parseString(hscriptStr);
|
||||
return if (Prelude.truthy(conditionInterp.execute(conditionHScript))) {
|
||||
thenExp;
|
||||
} else {
|
||||
|
@@ -25,7 +25,7 @@ abstract Operand(Either<String, Float>) from Either<String, Float> to Either<Str
|
||||
// Doing this one implicitly just wasn't working in conjunction with Lambda.fold
|
||||
|
||||
/* @:from */
|
||||
public inline static function fromDynamic(d:Dynamic):Operand {
|
||||
public static function fromDynamic(d:Dynamic):Operand {
|
||||
return switch (Type.typeof(d)) {
|
||||
case TInt | TFloat: Right(0.0 + d);
|
||||
// Treating true and false as operands can be useful for equality. In practice, no one should use them
|
||||
|
Reference in New Issue
Block a user