Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
10
Task/Function-composition/Lingo/function-composition-1.lingo
Normal file
10
Task/Function-composition/Lingo/function-composition-1.lingo
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
-- in some movie script
|
||||
----------------------------------------
|
||||
-- Composes 2 call-functions, returns a new call-function
|
||||
-- @param {symbol|instance} f
|
||||
-- @param {symbol|instance} g
|
||||
-- @return {instance}
|
||||
----------------------------------------
|
||||
on compose (f, g)
|
||||
return script("Composer").new(f, g)
|
||||
end
|
||||
34
Task/Function-composition/Lingo/function-composition-2.lingo
Normal file
34
Task/Function-composition/Lingo/function-composition-2.lingo
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
-- parent script "Composer"
|
||||
|
||||
property _f
|
||||
property _g
|
||||
|
||||
----------------------------------------
|
||||
-- @constructor
|
||||
-- @param {symbol|instance} f
|
||||
-- @param {symbol|instance} g
|
||||
----------------------------------------
|
||||
on new (me, f, g)
|
||||
me._f = f
|
||||
me._g = g
|
||||
return me
|
||||
end
|
||||
|
||||
on call (me)
|
||||
if ilk(me._g)=#instance then
|
||||
cmd = "_movie.call(#call,me._g,VOID"
|
||||
else
|
||||
cmd = "_movie.call(me._g,_movie"
|
||||
end if
|
||||
a = [] -- local args list
|
||||
repeat with i = 1 to the paramCount-2
|
||||
a[i] = param(i+2)
|
||||
put ",a["&i&"]" after cmd
|
||||
end repeat
|
||||
put ")" after cmd
|
||||
if ilk(me._f)=#instance then
|
||||
return _movie.call(#call, me._f, VOID, value(cmd))
|
||||
else
|
||||
return _movie.call(me._f, _movie, value(cmd))
|
||||
end if
|
||||
end
|
||||
16
Task/Function-composition/Lingo/function-composition-3.lingo
Normal file
16
Task/Function-composition/Lingo/function-composition-3.lingo
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- compose new function based on built-in function 'sin' and user-defined function 'asin'
|
||||
f1 = compose(#asin, #sin)
|
||||
put call(f1, _movie, 0.5)
|
||||
-- 0.5000
|
||||
|
||||
-- compose new function based on previously composed function 'f1' and user-defined function 'double'
|
||||
f2 = compose(#double, f1)
|
||||
put call(f2, _movie, 0.5)
|
||||
-- 1.0000
|
||||
|
||||
-- compose new function based on 2 composed functions
|
||||
f1 = compose(#asin, #sin)
|
||||
f2 = compose(#double, #triple)
|
||||
f3 = compose(f2, f1)
|
||||
put call(f3, _movie, 0.5)
|
||||
-- 3.0000
|
||||
14
Task/Function-composition/Lingo/function-composition-4.lingo
Normal file
14
Task/Function-composition/Lingo/function-composition-4.lingo
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
-- in some movie script
|
||||
on asin (x)
|
||||
res = atan(sqrt(x*x/(1-x*x)))
|
||||
if x<0 then res = -res
|
||||
return res
|
||||
end
|
||||
|
||||
on double (x)
|
||||
return x*2
|
||||
end
|
||||
|
||||
on triple (x)
|
||||
return x*3
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue