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,5 @@
define printArgs(...items) => stdoutnl(#items)
define printEachArg(...) => with i in #rest do stdoutnl(#i)
printArgs('a', 2, (:3))
printEachArg('a', 2, (:3))

View file

@ -0,0 +1,2 @@
local(args = (:"Rosetta", "Code", "Is", "Awesome!"))
printEachArg(:#args)

View file

@ -0,0 +1,8 @@
staticarray(a, 2, staticarray(3))
a
2
staticarray(3)
Rosetta
Code
Is
Awesome!

View file

@ -0,0 +1,3 @@
proc print(xs: varargs[string, `$`]) =
for x in xs:
echo x

View file

@ -0,0 +1,6 @@
print(12, "Rosetta", "Code", 15.54321)
print 12, "Rosetta", "Code", 15.54321, "is", "awesome!"
let args = @["12", "Rosetta", "Code", "15.54321"]
print(args)

View file

@ -0,0 +1 @@
: sumNum(n) | i | 0 n loop: i [ + ] ;

View file

@ -0,0 +1,6 @@
procedure print_args(sequence args)
for i=1 to length(args) do
?args[i]
end for
end procedure
print_args({"Mary", "had", "a", "little", "lamb"})

View file

@ -0,0 +1,3 @@
func print_all(*things) {
things.each { |x| say x };
}

View file

@ -0,0 +1,3 @@
print_all(4, 3, 5, 6, 4, 3);
print_all(4, 3, 5);
print_all("Rosetta", "Code", "Is", "Awesome!");

View file

@ -0,0 +1,2 @@
var args = ["Rosetta", "Code", "Is", "Awesome!"];
print_all(args...);

View file

@ -0,0 +1,6 @@
func printAll<T>(things: T...) {
// "things" is a [T]
for i in things {
print(i)
}
}

View file

@ -0,0 +1,3 @@
printAll(4, 3, 5, 6, 4, 3)
printAll(4, 3, 5)
printAll("Rosetta", "Code", "Is", "Awesome!")

View file

@ -0,0 +1,14 @@
(defun print-on-separate-lines (&rest xs)
(for-each print xs))
; test the function:
(print-on-separate-lines 'i 'am 'doing 'a 'great 'work 'so 'that 'i 'cannot 'come 'down)
; to use it on a list of arguments assembled at run time, first create your list
(define test '(why should the work cease whilst i leave it and come down to you))
; and then call APPLY:
(apply print-on-separate-lines test)

View file

@ -0,0 +1 @@
def demo: .[];

View file

@ -0,0 +1 @@
args | demo

View file

@ -0,0 +1 @@
["cheese"] + [3.14] + [[range(0;3)]] | demo

View file

@ -0,0 +1,3 @@
"cheese"
3.14
[0,1,2]

View file

@ -0,0 +1,13 @@
# arity-0:
def f: "I have no arguments";
# arity-1:
def f(a1): a1;
# arity-1:
def f(a1;a2): a1,a2;
def f(a1;a2;a3): a1,a2,a3;
# Example:
f, f(1), f(2;3), f(4;5;6)

View file

@ -0,0 +1,6 @@
1
2
3
4
5
6