You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i1 : Truthy = newTypeofList;
i2 : Truthy == Boolean := (T, B) -> T#0 === B;
i3 : T = new Truthy from {true}
o3 = {true}
o3 : Truthy
i4 : F = new Truthy from {false}
o4 = {false}
o4 : Truthy
Given such a type, it would be desirable to use it in if .. then .. else .. clauses, but this fails:
i5 : if T thenprint"true"stdio:5:4:(3): error: expected trueorfalse
Even though this works fine:
i6 : T == true
o6 = true
i8 : T == false
o8 = false
We can define binary operations fine:
i9 : not Truthy := T -> new Truthy from {not T#0};
i10 : not T
o10 = {false}
o10 : Truthy
i17 : Truthy and Truthy := (T1, T2) -> new Truthy from {T1#0 and T2#0};
i18 : T and F
o18 = {false}
o18 : Truthy
i19 : T and T
o19 = {true}
o19 : Truthy
One solution is having if and while clauses evaluate truthiness using a method that can be installed from the top level.
One application of this is having lazily evaluated predicates and binary operations that take advantage of this, or even basic symbolic logic.
The text was updated successfully, but these errors were encountered:
I'll explain via an example:
Given such a type, it would be desirable to use it in
if .. then .. else ..
clauses, but this fails:Even though this works fine:
We can define binary operations fine:
One solution is having
if
andwhile
clauses evaluate truthiness using a method that can be installed from the top level.One application of this is having lazily evaluated predicates and binary operations that take advantage of this, or even basic symbolic logic.
The text was updated successfully, but these errors were encountered: