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,11 @@
proc `^`*[T: SomeInteger](base: T, exp: T): T =
var (base, exp) = (base, exp)
result = 1
while exp != 0:
if (exp and 1) != 0:
result *= base
exp = exp shr 1
base *= base
echo 2 ^ 10 # 1024

View file

@ -0,0 +1,6 @@
when defined windows:
echo "Call some Windows specific functions here"
elif defined linux:
echo "Call some Linux specific functions here"
else:
echo "Code for the other platforms"

View file

@ -0,0 +1,2 @@
static:
echo "Hello Compile time world: ", 2 ^ 10

View file

@ -0,0 +1 @@
const x = 2 ^ 10

View file

@ -0,0 +1,14 @@
import os
const debug = false
proc expensive: string =
sleep(milsecs = 100)
result = "That was difficult"
proc log(msg: string) =
if debug:
echo msg
for i in 1..10:
log expensive()

View file

@ -0,0 +1,6 @@
template log(msg: string) =
if debug:
echo msg
for i in 1..10:
log expensive()

View file

@ -0,0 +1,7 @@
template times(x: expr, y: stmt): stmt =
for i in 1..x:
y
10.times: # or times 10:
echo "hi"
echo "bye"

View file

@ -0,0 +1,15 @@
template optLog1{a and a}(a): auto = a
template optLog2{a and (b or (not b))}(a,b): auto = a
template optLog3{a and not a}(a: int): auto = 0
var
x = 12
s = x and x
# Hint: optLog1(x) --> x [Pattern]
r = (x and x) and ((s or s) or (not (s or s)))
# Hint: optLog2(x and x, s or s) --> x and x [Pattern]
# Hint: optLog1(x) --> x [Pattern]
q = (s and not x) and not (s and not x)
# Hint: optLog3(s and not x) --> 0 [Pattern]

View file

@ -0,0 +1,13 @@
import macros
dumpTree:
if x:
if y:
p0
else:
p1
else:
if y:
p2
else:
p3