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,16 @@
' FB 1.05.0 Win64
#Macro ForAll(C, S)
For _i as integer = 0 To Len(s)
#Define C (Chr(s[_i]))
#EndMacro
#Define In ,
Dim s As String = "Rosetta"
ForAll(c in s)
Print c; " ";
Next
Print
Sleep

View file

@ -0,0 +1,3 @@
r = RETURN
str = "on halt"&r&"--do nothing"&r&"end"
new(#script).scripttext = str

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

View file

@ -0,0 +1,5 @@
o1 = new point { x=10 y=20 z=30 }
addmethod(o1,"print", func { see x + nl + y + nl + z + nl } )
o1.print()
Class point
x y z

View file

@ -0,0 +1,44 @@
New App
{
I want window
The window title = "hello world"
}
Class App
func geti
if nIwantwindow = 0
nIwantwindow++
ok
func getwant
if nIwantwindow = 1
nIwantwindow++
ok
func getwindow
if nIwantwindow = 2
nIwantwindow= 0
see "Instruction : I want window" + nl
ok
if nWindowTitle = 0
nWindowTitle++
ok
func settitle cValue
if nWindowTitle = 1
nWindowTitle=0
see "Instruction : Window Title = " + cValue + nl
ok
private
# Attributes for the instruction I want window
i want window
nIwantwindow = 0
# Attributes for the instruction Window title
# Here we don't define the window attribute again
title
nWindowTitle = 0
# Keywords to ignore, just give them any value
the=0

View file

@ -0,0 +1,8 @@
(define make-list
[A|D] -> [cons (make-list A) (make-list D)]
X -> X)
(defmacro info-macro
[info Exp] -> [output "~A: ~A~%" (make-list Exp) Exp])
(info (* 5 6)) \\ outputs [* 5 6]: 30

View file

@ -0,0 +1,7 @@
(0-) (defmacro +-macro
[A + B] -> [+ A B])
macro
+-macro
(1-) (1 + (* 2 3))
7

View file

@ -0,0 +1,14 @@
(2-) (tc +)
true
(3+) (+ 1 2 3)
6 : number
(4+) +
+ : (number --> (number --> number))
(5-) (tc -)
false
(6-) (macroexpand [+ 1 2 3])
[+ 1 [+ 2 3]]

View file

@ -0,0 +1,7 @@
class Number {
method ⊕(arg) {
self + arg
}
}
say (21 ⊕ 42)

View file

@ -0,0 +1,20 @@
var colors = Hash(
'black' => "000",
'red' => "f00",
'green' => "0f0",
'yellow' => "ff0",
'blue' => "00f",
'magenta' => "f0f",
'cyan' => "0ff",
'white' => "fff",
)
colors.each { |color, code|
String.def_method("in_#{color}", func (self) {
'<span style="color: #' + code + '">' + self + '</span>'
})
}
say "blue".in_blue;
say "red".in_red;
say "white".in_white;