Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,57 @@
type Trit* = enum ttrue, tmaybe, tfalse
proc `$`*(a: Trit): string =
case a
of ttrue: "T"
of tmaybe: "?"
of tfalse: "F"
proc `not`*(a: Trit): Trit =
case a
of ttrue: tfalse
of tmaybe: tmaybe
of tfalse: ttrue
proc `and`*(a, b: Trit): Trit =
const t: array[Trit, array[Trit, Trit]] =
[ [ttrue, tmaybe, tfalse]
, [tmaybe, tmaybe, tfalse]
, [tfalse, tfalse, tfalse] ]
t[a][b]
proc `or`*(a, b: Trit): Trit =
const t: array[Trit, array[Trit, Trit]] =
[ [ttrue, ttrue, ttrue]
, [ttrue, tmaybe, tmaybe]
, [ttrue, tmaybe, tfalse] ]
t[a][b]
proc then*(a, b: Trit): Trit =
const t: array[Trit, array[Trit, Trit]] =
[ [ttrue, tmaybe, tfalse]
, [ttrue, tmaybe, tmaybe]
, [ttrue, ttrue, ttrue] ]
t[a][b]
proc equiv*(a, b: Trit): Trit =
const t: array[Trit, array[Trit, Trit]] =
[ [ttrue, tmaybe, tfalse]
, [tmaybe, tmaybe, tmaybe]
, [tfalse, tmaybe, ttrue] ]
t[a][b]
import strutils
var
op1 = ttrue
op2 = ttrue
for t in Trit:
echo "Not ", t , ": ", not t
for op1 in Trit:
for op2 in Trit:
echo "$# and $#: $#".format(op1, op2, op1 and op2)
echo "$# or $#: $#".format(op1, op2, op1 or op2)
echo "$# then $#: $#".format(op1, op2, op1.then op2)
echo "$# equiv $#: $#".format(op1, op2, op1.equiv op2)