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
|
|
@ -0,0 +1,12 @@
|
|||
ORG RESET
|
||||
mov a, #100
|
||||
mov b, #10
|
||||
call multiply
|
||||
; at this point, the result of 100*10 = 1000 = 03e8h is stored in registers a and b
|
||||
; a = e8
|
||||
; b = 03
|
||||
jmp $
|
||||
|
||||
multiply:
|
||||
mul ab
|
||||
ret
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
multiply: * /`*' is a normal function
|
||||
multiply: {x * y}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{expr-or-def1; expr-or-def2; ..; return-expr}
|
||||
3
Task/Function-definition/Axe/function-definition.axe
Normal file
3
Task/Function-definition/Axe/function-definition.axe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Lbl MULT
|
||||
r₁*r₂
|
||||
Return
|
||||
6
Task/Function-definition/ChucK/function-definition.chuck
Normal file
6
Task/Function-definition/ChucK/function-definition.chuck
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
fun float multiply (float a, float b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
// uncomment next line and change values to test
|
||||
//<<< multiply(16,4) >>>;
|
||||
1
Task/Function-definition/Coco/function-definition-1.coco
Normal file
1
Task/Function-definition/Coco/function-definition-1.coco
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply = -> @@0 * @@1
|
||||
1
Task/Function-definition/Coco/function-definition-2.coco
Normal file
1
Task/Function-definition/Coco/function-definition-2.coco
Normal file
|
|
@ -0,0 +1 @@
|
|||
double = -> 2 * it
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
(define (multiply a b) (* a b)) → multiply ;; (1)
|
||||
(multiply 1/3 666) → 222
|
||||
|
||||
;; a function is a lambda definition :
|
||||
multiply
|
||||
→ (λ (_a _b) (#* _a _b))
|
||||
|
||||
;; The following is the same as (1) :
|
||||
(define multiply (lambda(a b) (* a b)))
|
||||
multiply
|
||||
→ (🔒 λ (_a _b) (#* _a _b)) ;; a closure
|
||||
|
||||
|
||||
;; a function may be compiled
|
||||
(lib 'compile)
|
||||
(compile 'multiply "-float-verbose")
|
||||
→
|
||||
💡 [0] compiling _🔶_multiply ((#* _a _b))
|
||||
;; object code (javascript) :
|
||||
var ref,top = _blocks[_topblock];
|
||||
/* */return (
|
||||
/* */(_stack[top] *_stack[1 + top])
|
||||
/* */);
|
||||
|
||||
multiply → (λ (_a _b) (#🔶_multiply)) ;; compiled function
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Function multiply(d1 As Double, d2 As Double) As Double
|
||||
Return d1 * d2
|
||||
End Function
|
||||
|
|
@ -0,0 +1 @@
|
|||
#Define multiply(d1, d2) (d1) * (d2)
|
||||
|
|
@ -0,0 +1 @@
|
|||
fun multiply(x: int, y: int): int = x * y
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
local fn multiply( a as long, b as long ) as long
|
||||
end fn = a * b
|
||||
|
||||
print fn multiply( 3, 9 )
|
||||
2
Task/Function-definition/LFE/function-definition.lfe
Normal file
2
Task/Function-definition/LFE/function-definition.lfe
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defun mutiply (a b)
|
||||
(* a b))
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
define multiply(a,b) => {
|
||||
return #a * #b
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
define multiply(a,b) => #a * #b
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
// Signatures that convert second input to match first input
|
||||
define multiply(a::integer,b::any) => #a * integer(#b)
|
||||
define multiply(a::decimal,b::any) => #a * decimal(#b)
|
||||
|
||||
// Catch all signature
|
||||
define multiply(a::any,b::any) => decimal(#a) * decimal(#b)
|
||||
4
Task/Function-definition/Lily/function-definition.lily
Normal file
4
Task/Function-definition/Lily/function-definition.lily
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
define multiply(a: Integer, b: Integer): Integer
|
||||
{
|
||||
return a * b
|
||||
}
|
||||
3
Task/Function-definition/Lingo/function-definition.lingo
Normal file
3
Task/Function-definition/Lingo/function-definition.lingo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
on multiply (a, b)
|
||||
return a * b
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
function multiplyy n1 n2
|
||||
return n1 * n2
|
||||
end multiplyy
|
||||
|
||||
put multiplyy(2,5) -- = 10
|
||||
1
Task/Function-definition/NESL/function-definition.nesl
Normal file
1
Task/Function-definition/NESL/function-definition.nesl
Normal file
|
|
@ -0,0 +1 @@
|
|||
function multiply(x, y) = x * y;
|
||||
2
Task/Function-definition/Nim/function-definition-1.nim
Normal file
2
Task/Function-definition/Nim/function-definition-1.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
proc multiply(a, b: Int): Int =
|
||||
result = a * b
|
||||
2
Task/Function-definition/Nim/function-definition-2.nim
Normal file
2
Task/Function-definition/Nim/function-definition-2.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
proc multiply(a, b: Int): Int =
|
||||
return a * b
|
||||
1
Task/Function-definition/Nim/function-definition-3.nim
Normal file
1
Task/Function-definition/Nim/function-definition-3.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
proc multiply(a, b: Int): Int = a * b
|
||||
|
|
@ -0,0 +1 @@
|
|||
: multiply * ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
: multiply2(a, b) a b * ;
|
||||
3
Task/Function-definition/PHL/function-definition.phl
Normal file
3
Task/Function-definition/PHL/function-definition.phl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@Integer multiply(@Integer a, @Integer b) [
|
||||
return a * b;
|
||||
]
|
||||
3
Task/Function-definition/Phix/function-definition.phix
Normal file
3
Task/Function-definition/Phix/function-definition.phix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply(atom a, atom b)
|
||||
return a*b
|
||||
end function
|
||||
1
Task/Function-definition/Picat/function-definition.picat
Normal file
1
Task/Function-definition/Picat/function-definition.picat
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply(A, B) = A*B.
|
||||
1
Task/Function-definition/Ring/function-definition.ring
Normal file
1
Task/Function-definition/Ring/function-definition.ring
Normal file
|
|
@ -0,0 +1 @@
|
|||
func multiply x,y return x*y
|
||||
5
Task/Function-definition/SSEM/function-definition-1.ssem
Normal file
5
Task/Function-definition/SSEM/function-definition-1.ssem
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
01000000000000100000000000000000 0. -2 to c
|
||||
00100000000000000000000000000000 1. 4 to CI
|
||||
01111111111111111111111111111111 2. -2
|
||||
00000000000001110000000000000000 3. Stop
|
||||
11100000000000000000000000000000 4. 7
|
||||
26
Task/Function-definition/SSEM/function-definition-2.ssem
Normal file
26
Task/Function-definition/SSEM/function-definition-2.ssem
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
00010000000000000000000000000000 6. 8
|
||||
11100000000000000000000000000000 7. 7
|
||||
11111000000001100000000000000000 8. c to 31
|
||||
01100000000000100000000000000000 9. -6 to c
|
||||
01111000000001100000000000000000 10. c to 30
|
||||
01111000000000100000000000000000 11. -30 to c
|
||||
01111000000001100000000000000000 12. c to 30
|
||||
11100000000000100000000000000000 13. -7 to c
|
||||
11100000000001100000000000000000 14. c to 7
|
||||
11100000000000100000000000000000 15. -7 to c
|
||||
00111000000000010000000000000000 16. Sub. 28
|
||||
11100000000001100000000000000000 17. c to 7
|
||||
00111000000000010000000000000000 18. Sub. 28
|
||||
00000000000000110000000000000000 19. Test
|
||||
00111000000001000000000000000000 20. Add 28 to CI
|
||||
11111000000000000000000000000000 21. 31 to CI
|
||||
01100000000000100000000000000000 22. -6 to c
|
||||
01111000000000010000000000000000 23. Sub. 30
|
||||
01100000000001100000000000000000 24. c to 6
|
||||
01100000000000100000000000000000 25. -6 to c
|
||||
01100000000001100000000000000000 26. c to 6
|
||||
10111000000000000000000000000000 27. 29 to CI
|
||||
10000000000000000000000000000000 28. 1
|
||||
00110000000000000000000000000000 29. 12
|
||||
00000000000000000000000000000000 30. 0
|
||||
00000000000000000000000000000000 31. 0
|
||||
3
Task/Function-definition/Sidef/function-definition.sidef
Normal file
3
Task/Function-definition/Sidef/function-definition.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func multiply(a, b) {
|
||||
a * b;
|
||||
}
|
||||
3
Task/Function-definition/Swift/function-definition.swift
Normal file
3
Task/Function-definition/Swift/function-definition.swift
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func multiply(a: Double, b: Double) -> Double {
|
||||
return a * b
|
||||
}
|
||||
4
Task/Function-definition/Ursa/function-definition.ursa
Normal file
4
Task/Function-definition/Ursa/function-definition.ursa
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# multiply is a built-in in ursa, so the function is called mult instead
|
||||
def mult (int a, int b)
|
||||
return (* a b)
|
||||
end
|
||||
2
Task/Function-definition/Wart/function-definition-1.wart
Normal file
2
Task/Function-definition/Wart/function-definition-1.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def (multiply a b)
|
||||
a*b
|
||||
2
Task/Function-definition/Wart/function-definition-2.wart
Normal file
2
Task/Function-definition/Wart/function-definition-2.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(multiply 3 4)
|
||||
=> 12
|
||||
2
Task/Function-definition/Wart/function-definition-3.wart
Normal file
2
Task/Function-definition/Wart/function-definition-3.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(multiply 3 :a 4) # arg order doesn't matter here, but try subtract instead
|
||||
=> 12
|
||||
2
Task/Function-definition/Wart/function-definition-4.wart
Normal file
2
Task/Function-definition/Wart/function-definition-4.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def (multiply a b|by)
|
||||
(* a b)
|
||||
2
Task/Function-definition/Wart/function-definition-5.wart
Normal file
2
Task/Function-definition/Wart/function-definition-5.wart
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
multiply 3 :by 4
|
||||
=> 12
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(defun multiply (x y)
|
||||
(* x y))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(define (multiply x y)
|
||||
(* x y))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(define multiply
|
||||
(lambda (x y) (* x y)))
|
||||
1
Task/Function-definition/jq/function-definition-1.jq
Normal file
1
Task/Function-definition/jq/function-definition-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def multiply(a; b): a*b;
|
||||
2
Task/Function-definition/jq/function-definition-2.jq
Normal file
2
Task/Function-definition/jq/function-definition-2.jq
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
# 2 | generate(. * .) will generate 2, 4, 16, 256, ...
|
||||
def generate(f): def r: ., (f | r); r;
|
||||
1
Task/Function-definition/jq/function-definition-3.jq
Normal file
1
Task/Function-definition/jq/function-definition-3.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
def summation(f): reduce .[] as $x (0; . + ($x|f));
|
||||
1
Task/Function-definition/jq/function-definition-4.jq
Normal file
1
Task/Function-definition/jq/function-definition-4.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
summation( .h * .w)
|
||||
Loading…
Add table
Add a link
Reference in a new issue