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 @@
define mymethod(
-first::integer, // with no default value the param is required
-second::integer,
-delimiter::string = ':' // when given a default value the param becomes optional
) => #first + #delimiter + #second
mymethod(
-first = 54,
-second = 45
)
'<br />'
mymethod(
-second = 45, // named params can be given in any order
-first = 54,
-delimiter = '#'
)

View file

@ -0,0 +1,22 @@
-- accepts either 3 integers or a single property list
on foo (arg1, arg2, arg3)
if ilk(arg1)=#propList then
args = arg1
arg1 = args[#arg1]
arg2 = args[#arg2]
arg3 = args[#arg3]
end if
put "arg1="&arg1
put "arg2="&arg2
put "arg3="&arg3
end
foo(1,2) -- 3rd argument omitted
-- "arg1=1"
-- "arg2=2"
-- "arg3="
foo([#arg3:3]) -- only 3rd argument specified
-- "arg1="
-- "arg2="
-- "arg3=3"

View file

@ -0,0 +1,4 @@
proc subtract(x, y): auto = x - y
echo subtract(5, 3) # used as positional parameters
echo subtract(y = 3, x = 5) # used as named parameters

View file

@ -0,0 +1,9 @@
global function timedelta(atom weeks=0, atom days=0, atom hours=0, atom minutes=0, atom seconds=0, atom milliseconds=0, atom microseconds=0)
-- can be invoked as:
constant fourdays = timedelta(days:=4)
-- fourdays = timedelta(0,4) -- equivalent
-- **NB** a plain '=' is a very different thing
constant oneday = timedelta(days=1) -- equivalent to timedelta([weeks:=]iff((equal(days,1)?true:false))
-- - with an error if no local variable days exists.
constant shift = timedelta(hours:=hours) -- perfectly valid (param hours:=local hours)
-- timedelta(0,hours:=15,3) -- illegal (it is not clear whether you meant days:=3 or minutes:=3)

View file

@ -0,0 +1,6 @@
func example(foo: 0, bar: 1, grill: "pork chops") {
say "foo is #{foo}, bar is #{bar}, and grill is #{grill}";
}
# Note that :foo is omitted and :grill precedes :bar
example(grill: "lamb kebab", bar: 3.14);

View file

@ -0,0 +1,4 @@
func isGreater(x x:Int, thanY y:Int) -> Bool {
return x > y
}
assert(isGreater(x: 5, thanY: 10) == false)

View file

@ -0,0 +1,4 @@
func isGreater(x:Int, _ y:Int) -> Bool {
return x > y
}
assert(isGreater(5, 10) == false)

View file

@ -0,0 +1,7 @@
def formatName(obj):
({ "name": "?"} + obj) as $obj # the default default value is null
| ($obj|.name) as $name
| ($obj|.first) as $first
| if ($first == null) then $name
else $name + ", " + $first
end;

View file

@ -0,0 +1,9 @@
formatName({"first": "George", "name": "Eliot"})
formatName({"name": "Eliot", "first": "George"})
formatName({"name": "Eliot"})
formatName({"first": "George"})
formatName({})