A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
6
Task/Function-definition/0DESCRIPTION
Normal file
6
Task/Function-definition/0DESCRIPTION
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
A function is a body of code that returns a value. The value returned may depend on arguments provided to the function.
|
||||
|
||||
Write a definition of a function called "multiply" that takes two arguments and returns their product.
|
||||
(Argument types should be chosen so as not to distract from showing how functions are created and values returned).
|
||||
|
||||
See also:[[Function prototype]]
|
||||
4
Task/Function-definition/1META.yaml
Normal file
4
Task/Function-definition/1META.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
category:
|
||||
- Functions and subroutines
|
||||
note: Basic language learning
|
||||
1
Task/Function-definition/ACL2/function-definition.acl2
Normal file
1
Task/Function-definition/ACL2/function-definition.acl2
Normal file
|
|
@ -0,0 +1 @@
|
|||
(defun multiply (a b) (* a b))
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
PROC multiply = ( LONG REAL a, b ) LONG REAL:
|
||||
(
|
||||
a * b
|
||||
)
|
||||
1
Task/Function-definition/APL/function-definition.apl
Normal file
1
Task/Function-definition/APL/function-definition.apl
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply ← ×
|
||||
7
Task/Function-definition/AWK/function-definition.awk
Normal file
7
Task/Function-definition/AWK/function-definition.awk
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function multiply(a, b)
|
||||
{
|
||||
return a*b
|
||||
}
|
||||
BEGIN {
|
||||
print multiply(5, 6)
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
function multiply(a:Number, b:Number):Number {
|
||||
return a * b;
|
||||
}
|
||||
1
Task/Function-definition/Ada/function-definition-1.ada
Normal file
1
Task/Function-definition/Ada/function-definition-1.ada
Normal file
|
|
@ -0,0 +1 @@
|
|||
function Multiply (A, B : Float) return Float;
|
||||
4
Task/Function-definition/Ada/function-definition-2.ada
Normal file
4
Task/Function-definition/Ada/function-definition-2.ada
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
function Multiply (A, B : Float) return Float is
|
||||
begin
|
||||
return A * B;
|
||||
end Multiply;
|
||||
1
Task/Function-definition/Ada/function-definition-3.ada
Normal file
1
Task/Function-definition/Ada/function-definition-3.ada
Normal file
|
|
@ -0,0 +1 @@
|
|||
function Multiply(A, B: Float) return Float is (A * B);
|
||||
3
Task/Function-definition/Ada/function-definition-4.ada
Normal file
3
Task/Function-definition/Ada/function-definition-4.ada
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
generic
|
||||
type Number is digits <>;
|
||||
function Multiply (A, B : Number) return Number;
|
||||
4
Task/Function-definition/Ada/function-definition-5.ada
Normal file
4
Task/Function-definition/Ada/function-definition-5.ada
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
function Multiply (A, B : Number) return Number is
|
||||
begin
|
||||
return A * B;
|
||||
end Multiply;
|
||||
7
Task/Function-definition/Ada/function-definition-6.ada
Normal file
7
Task/Function-definition/Ada/function-definition-6.ada
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
with Multiply;
|
||||
...
|
||||
function Multiply_Integer is new Multiply(Number => Integer);
|
||||
use Multiply_Integer; -- If you must
|
||||
|
||||
type My_Integer is Range -100..100;
|
||||
function Multiply_My_Integer is new Multiply(My_Integer);
|
||||
11
Task/Function-definition/AmigaE/function-definition.amiga
Normal file
11
Task/Function-definition/AmigaE/function-definition.amiga
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
PROC my_molt(a,b)
|
||||
-> other statements if needed... here they are not
|
||||
ENDPROC a*b -> return value
|
||||
|
||||
-> or simplier
|
||||
|
||||
PROC molt(a,b) IS a*b
|
||||
|
||||
PROC main()
|
||||
WriteF('\d\n', my_molt(10,20))
|
||||
ENDPROC
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
on multiply(a, b)
|
||||
return a * b
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
10 DEF FN MULTIPLY(P) = P(P) * P(P+1)
|
||||
20 P(1) = 611 : P(2) = 78 : PRINT FN MULTIPLY(1)
|
||||
|
|
@ -0,0 +1 @@
|
|||
47658
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
use std
|
||||
.: multiply <real a, real b> :. -> real {a * b}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
use std
|
||||
=: multiply <real a> [<real b>...] := -> real {Cgen a (@@1 (Cgen " * " b))}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
MsgBox % multiply(10,2)
|
||||
|
||||
multiply(multiplicand, multiplier) {
|
||||
Return (multiplicand * multiplier)
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#AutoIt Version: 3.2.10.0
|
||||
$I=11
|
||||
$J=12
|
||||
MsgBox(0,"Multiply", $I &" * "& $J &" = " & product($I,$J))
|
||||
Func product($a,$b)
|
||||
Return $a * $b
|
||||
EndFunc
|
||||
5
Task/Function-definition/BASIC/function-definition.bas
Normal file
5
Task/Function-definition/BASIC/function-definition.bas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
DECLARE FUNCTION multiply% (a AS INTEGER, b AS INTEGER)
|
||||
|
||||
FUNCTION multiply% (a AS INTEGER, b AS INTEGER)
|
||||
multiply = a * b
|
||||
END FUNCTION
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
PRINT FNmultiply(6,7)
|
||||
END
|
||||
|
||||
DEF FNmultiply(a,b) = a * b
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
DEF FNmultiply(a,b)
|
||||
LOCAL c
|
||||
c = a * b
|
||||
= c
|
||||
11
Task/Function-definition/Batch-File/function-definition.bat
Normal file
11
Task/Function-definition/Batch-File/function-definition.bat
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
@ECHO OFF
|
||||
SET /A result = 0
|
||||
CALL :multiply 2 3
|
||||
ECHO %result%
|
||||
GOTO :eof
|
||||
|
||||
:multiply
|
||||
SET /A result = %1 * %2
|
||||
GOTO :eof
|
||||
|
||||
:eof
|
||||
4
Task/Function-definition/Boo/function-definition.boo
Normal file
4
Task/Function-definition/Boo/function-definition.boo
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
def multiply(x as int, y as int):
|
||||
return x * y
|
||||
|
||||
print multiply(3, 2)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
multiply=a b.!arg:(?a.?b)&!a*!b;
|
||||
out$multiply$(123456789.987654321); { writes 121932631112635269 to standard output }
|
||||
3
Task/Function-definition/Brat/function-definition.brat
Normal file
3
Task/Function-definition/Brat/function-definition.brat
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
multiply = { x, y | x * y }
|
||||
|
||||
p multiply 3 14 #Prints 42
|
||||
4
Task/Function-definition/C++/function-definition-1.cpp
Normal file
4
Task/Function-definition/C++/function-definition-1.cpp
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
inline double multiply(double a, double b)
|
||||
{
|
||||
return a*b;
|
||||
}
|
||||
5
Task/Function-definition/C++/function-definition-2.cpp
Normal file
5
Task/Function-definition/C++/function-definition-2.cpp
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
template<typename Number>
|
||||
Number multiply(Number a, Number b)
|
||||
{
|
||||
return a*b;
|
||||
}
|
||||
4
Task/Function-definition/C/function-definition-1.c
Normal file
4
Task/Function-definition/C/function-definition-1.c
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
double multiply(double a, double b)
|
||||
{
|
||||
return a * b;
|
||||
}
|
||||
1
Task/Function-definition/C/function-definition-2.c
Normal file
1
Task/Function-definition/C/function-definition-2.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define MULTIPLY(X, Y) ((X) * (Y))
|
||||
1
Task/Function-definition/C/function-definition-3.c
Normal file
1
Task/Function-definition/C/function-definition-3.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
x = MULTIPLY(x + z, y);
|
||||
1
Task/Function-definition/C/function-definition-4.c
Normal file
1
Task/Function-definition/C/function-definition-4.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
x = ((x + z) * (y));
|
||||
29
Task/Function-definition/COBOL/function-definition.cobol
Normal file
29
Task/Function-definition/COBOL/function-definition.cobol
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
* Multiply in COBOL
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. myTest.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 x PIC 9(3) VALUE 3.
|
||||
01 y PIC 9(3) VALUE 2.
|
||||
01 z PIC 9(9).
|
||||
PROCEDURE DIVISION.
|
||||
CALL "myMultiply" USING
|
||||
BY CONTENT x, BY CONTENT y,
|
||||
BY REFERENCE z.
|
||||
DISPLAY z.
|
||||
STOP RUN.
|
||||
END PROGRAM myTest.
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. myMultiply.
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
LINKAGE SECTION.
|
||||
01 x PIC 9(3).
|
||||
01 y PIC 9(3).
|
||||
01 z PIC 9(9).
|
||||
PROCEDURE DIVISION USING x, y, z.
|
||||
MULTIPLY x BY y GIVING z.
|
||||
EXIT PROGRAM.
|
||||
END PROGRAM myMultiply.
|
||||
1
Task/Function-definition/Clay/function-definition.clay
Normal file
1
Task/Function-definition/Clay/function-definition.clay
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply(x,y) = x * y;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(defn multiply [x y]
|
||||
(* x y))
|
||||
|
||||
(multiply 4 5)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(defn multiply
|
||||
([] 1)
|
||||
([x] x)
|
||||
([x y] (* x y))
|
||||
([x y & more]
|
||||
(reduce * (* x y) more)))
|
||||
|
||||
(multiply 2 3 4 5) ; 120
|
||||
|
|
@ -0,0 +1 @@
|
|||
multiply = (a, b) -> a * b
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<cffunction name="multiply" returntype="numeric">
|
||||
<cfargument name="a" type="numeric">
|
||||
<cfargument name="b" type="numeric">
|
||||
<cfreturn a * b>
|
||||
</cffunction>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(defun multiply (a b)
|
||||
(* a b))
|
||||
|
||||
(multiply 2 3)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(define-compiler-macro multiply (&whole expr a b)
|
||||
(if (and (constantp a) (constantp b))
|
||||
(* (eval a) (eval b))
|
||||
expr)) ;; no macro recursion if we just return expr; the job is done!
|
||||
|
|
@ -0,0 +1 @@
|
|||
;;; terrific example coming
|
||||
26
Task/Function-definition/D/function-definition.d
Normal file
26
Task/Function-definition/D/function-definition.d
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// A function:
|
||||
int multiply1(int a, int b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
// Functions like "multiply1" can be evaluated at compile time if
|
||||
// they are called where a compile-time constant result is asked for:
|
||||
enum result = multiply1(2, 3); // Evaluated at compile time.
|
||||
int[multiply1(2, 4)] array; // Evaluated at compile time.
|
||||
|
||||
// A templated function:
|
||||
T multiply2(T)(T a, T b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
// Compile-time multiplication can also be done using templates:
|
||||
template multiply3(int a, int b) {
|
||||
enum multiply3 = a * b;
|
||||
}
|
||||
|
||||
pragma(msg, multiply3!(2, 3)); // Prints "6" during compilation.
|
||||
|
||||
void main() {
|
||||
import std.stdio;
|
||||
writeln("2 * 3 = ", result);
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
function Multiply(a, b : Integer) : Integer;
|
||||
begin
|
||||
Result := a * b;
|
||||
end;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
function Multiply(a, b: Integer): Integer;
|
||||
begin
|
||||
Result := a * b;
|
||||
end;
|
||||
3
Task/Function-definition/E/function-definition-1.e
Normal file
3
Task/Function-definition/E/function-definition-1.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def multiply(a, b) {
|
||||
return a * b
|
||||
}
|
||||
1
Task/Function-definition/E/function-definition-2.e
Normal file
1
Task/Function-definition/E/function-definition-2.e
Normal file
|
|
@ -0,0 +1 @@
|
|||
def multiply := fn a, b { a * b }
|
||||
8
Task/Function-definition/Efene/function-definition.efene
Normal file
8
Task/Function-definition/Efene/function-definition.efene
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
multiply = fn (A, B) {
|
||||
A * B
|
||||
}
|
||||
|
||||
@public
|
||||
run = fn () {
|
||||
io.format("~p~n", [multiply(2, 5)])
|
||||
}
|
||||
1
Task/Function-definition/Ela/function-definition-1.ela
Normal file
1
Task/Function-definition/Ela/function-definition-1.ela
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply x y = x * y
|
||||
1
Task/Function-definition/Ela/function-definition-2.ela
Normal file
1
Task/Function-definition/Ela/function-definition-2.ela
Normal file
|
|
@ -0,0 +1 @@
|
|||
\x y -> x * y
|
||||
1
Task/Function-definition/Erlang/function-definition.erl
Normal file
1
Task/Function-definition/Erlang/function-definition.erl
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply(A,B) -> A*B.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
function multiply( atom a, atom b )
|
||||
return a * b
|
||||
end function
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
function multiply( object a, object b )
|
||||
return a * b
|
||||
end function
|
||||
|
||||
sequence a = {1,2,3,4}
|
||||
sequence b = {5,6,7,8}
|
||||
|
||||
? multiply( 9, 9 )
|
||||
? multiply( 3.14159, 3.14159 )
|
||||
? multiply( a, b )
|
||||
? multiply( a, 7 )
|
||||
? multiply( 10.39564, b )
|
||||
3
Task/Function-definition/FALSE/function-definition.false
Normal file
3
Task/Function-definition/FALSE/function-definition.false
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[*] {anonymous function to multiply the top two items on the stack}
|
||||
m: {binding the function to one of the 26 available symbol names}
|
||||
2 3m;! {executing the function, yielding 6}
|
||||
|
|
@ -0,0 +1 @@
|
|||
: multiply ( a b -- a*b ) * ;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
function sayHiTo( name )
|
||||
> "Hi ", name
|
||||
end
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
class FunctionDefinition
|
||||
{
|
||||
public static Void main ()
|
||||
{
|
||||
multiply := |Int a, Int b -> Int| { a * b }
|
||||
echo ("Multiply 2 and 4: ${multiply(2, 4)}")
|
||||
}
|
||||
}
|
||||
1
Task/Function-definition/Fexl/function-definition-1.fexl
Normal file
1
Task/Function-definition/Fexl/function-definition-1.fexl
Normal file
|
|
@ -0,0 +1 @@
|
|||
\multiply=(\x\y * x y)
|
||||
1
Task/Function-definition/Fexl/function-definition-2.fexl
Normal file
1
Task/Function-definition/Fexl/function-definition-2.fexl
Normal file
|
|
@ -0,0 +1 @@
|
|||
\multiply=*
|
||||
2
Task/Function-definition/Forth/function-definition.fth
Normal file
2
Task/Function-definition/Forth/function-definition.fth
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
: fmultiply ( F: a b -- F: c ) F* ;
|
||||
: multiply ( a b -- c ) * ;
|
||||
4
Task/Function-definition/Fortran/function-definition-1.f
Normal file
4
Task/Function-definition/Fortran/function-definition-1.f
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
FUNCTION MULTIPLY(X,Y)
|
||||
REAL MULTIPLY, X, Y
|
||||
MULTIPLY = X * Y
|
||||
END
|
||||
8
Task/Function-definition/Fortran/function-definition-2.f
Normal file
8
Task/Function-definition/Fortran/function-definition-2.f
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module elemFunc
|
||||
contains
|
||||
elemental function multiply(x, y)
|
||||
real, intent(in) :: x, y
|
||||
real :: multiply
|
||||
multiply = x * y
|
||||
end function multiply
|
||||
end module elemFunc
|
||||
10
Task/Function-definition/Fortran/function-definition-3.f
Normal file
10
Task/Function-definition/Fortran/function-definition-3.f
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
program funcDemo
|
||||
use elemFunc
|
||||
|
||||
real :: a = 20.0, b = 30.0, c
|
||||
real, dimension(5) :: x = (/ 1.0, 2.0, 3.0, 4.0, 5.0 /), y = (/ 32.0, 16.0, 8.0, 4.0, 2.0 /), z
|
||||
|
||||
c = multiply(a,b) ! works with either function definition above
|
||||
|
||||
z = multiply(x,y) ! element-wise invocation only works with elemental function
|
||||
end program funcDemo
|
||||
2
Task/Function-definition/Fortran/function-definition-4.f
Normal file
2
Task/Function-definition/Fortran/function-definition-4.f
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
c = multiply(y=b, x=a) ! the same as multiply(a, b)
|
||||
z = multiply(y=x, x=y) ! the same as multiply(y, x)
|
||||
8
Task/Function-definition/Fortran/function-definition-5.f
Normal file
8
Task/Function-definition/Fortran/function-definition-5.f
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
module elemFunc
|
||||
contains
|
||||
elemental function multiply(x, y) result(z)
|
||||
real, intent(in) :: x, y
|
||||
real :: z
|
||||
z = x * y
|
||||
end function multiply
|
||||
end module elemFunc
|
||||
1
Task/Function-definition/Frink/function-definition.frink
Normal file
1
Task/Function-definition/Frink/function-definition.frink
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply[x,y] := x*y
|
||||
4
Task/Function-definition/GML/function-definition.gml
Normal file
4
Task/Function-definition/GML/function-definition.gml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#define multiply
|
||||
a = argument0
|
||||
b = argument1
|
||||
return(a * b)
|
||||
3
Task/Function-definition/Go/function-definition-1.go
Normal file
3
Task/Function-definition/Go/function-definition-1.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
func multiply(a, b float64) float64 {
|
||||
return a * b
|
||||
}
|
||||
4
Task/Function-definition/Go/function-definition-2.go
Normal file
4
Task/Function-definition/Go/function-definition-2.go
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
func multiply(a, b float64) (z float64) {
|
||||
z = a * b
|
||||
return
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{*}:multiply;
|
||||
|
|
@ -0,0 +1 @@
|
|||
def multiply = { x, y -> x * y }
|
||||
|
|
@ -0,0 +1 @@
|
|||
println "x * y = 20 * 50 = ${multiply 20, 50}"
|
||||
|
|
@ -0,0 +1 @@
|
|||
multiply = (*)
|
||||
|
|
@ -0,0 +1 @@
|
|||
multiply = \ x y -> x*y
|
||||
3
Task/Function-definition/Haxe/function-definition.haxe
Normal file
3
Task/Function-definition/Haxe/function-definition.haxe
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply(x:Float, y:Float):Float{
|
||||
return x * y;
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
FUNCTION multiply(a, b)
|
||||
multiply = a * b
|
||||
END
|
||||
3
Task/Function-definition/IDL/function-definition-1.idl
Normal file
3
Task/Function-definition/IDL/function-definition-1.idl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply ,a,b
|
||||
return, a* b
|
||||
end
|
||||
3
Task/Function-definition/IDL/function-definition-2.idl
Normal file
3
Task/Function-definition/IDL/function-definition-2.idl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply ,a,b
|
||||
return, product([a, b])
|
||||
end
|
||||
3
Task/Function-definition/IDL/function-definition-3.idl
Normal file
3
Task/Function-definition/IDL/function-definition-3.idl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply ,a,b
|
||||
return, a # b
|
||||
end
|
||||
3
Task/Function-definition/Icon/function-definition.icon
Normal file
3
Task/Function-definition/Icon/function-definition.icon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
procedure multiply(a,b)
|
||||
return a * b
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
[ multiply a b;
|
||||
return a * b;
|
||||
];
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
To decide which number is (A - number) multiplied by (B - number):
|
||||
decide on A * B.
|
||||
1
Task/Function-definition/Io/function-definition.io
Normal file
1
Task/Function-definition/Io/function-definition.io
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply := method(a,b,a*b)
|
||||
1
Task/Function-definition/J/function-definition-1.j
Normal file
1
Task/Function-definition/J/function-definition-1.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply=: *
|
||||
3
Task/Function-definition/J/function-definition-2.j
Normal file
3
Task/Function-definition/J/function-definition-2.j
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
multiply=: dyad define
|
||||
x * y
|
||||
)
|
||||
5
Task/Function-definition/Java/function-definition.java
Normal file
5
Task/Function-definition/Java/function-definition.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
public class Math
|
||||
{
|
||||
public static int multiply( int a, int b) { return a*b; }
|
||||
public static double multiply(double a, double b) { return a*b; }
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
function multiply(a,b) { return a*b }
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
var multiply = function (a, b) {
|
||||
return a * b;
|
||||
};
|
||||
1
Task/Function-definition/Joy/function-definition.joy
Normal file
1
Task/Function-definition/Joy/function-definition.joy
Normal file
|
|
@ -0,0 +1 @@
|
|||
DEFINE multiply == * .
|
||||
3
Task/Function-definition/Julia/function-definition.julia
Normal file
3
Task/Function-definition/Julia/function-definition.julia
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply(a::Number,b::Number)
|
||||
return a*b
|
||||
end
|
||||
11
Task/Function-definition/Kaya/function-definition.kaya
Normal file
11
Task/Function-definition/Kaya/function-definition.kaya
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
program test;
|
||||
|
||||
// A function definition in Kaya:
|
||||
Int multiply(Int a, Int b) {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
// And calling a function:
|
||||
Void main() {
|
||||
putStrLn(string( multiply(2, 3) ));
|
||||
}
|
||||
2
Task/Function-definition/LSE64/function-definition.lse64
Normal file
2
Task/Function-definition/LSE64/function-definition.lse64
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
multiply : *
|
||||
multiply. : *. # floating point
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
' define & call a function
|
||||
|
||||
print multiply( 3, 1.23456)
|
||||
|
||||
wait
|
||||
|
||||
function multiply( m1, m2)
|
||||
multiply =m1 *m2
|
||||
end function
|
||||
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
10 DEF FNmultiply(x,y)=x*y
|
||||
20 PRINT FNmultiply(2,PI)
|
||||
3
Task/Function-definition/Logo/function-definition.logo
Normal file
3
Task/Function-definition/Logo/function-definition.logo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
to multiply :x :y
|
||||
output :x * :y
|
||||
end
|
||||
3
Task/Function-definition/Lua/function-definition.lua
Normal file
3
Task/Function-definition/Lua/function-definition.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function multiply( a, b )
|
||||
return a * b
|
||||
end
|
||||
1
Task/Function-definition/Lucid/function-definition.lucid
Normal file
1
Task/Function-definition/Lucid/function-definition.lucid
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply(x,y) = x * y
|
||||
3
Task/Function-definition/M4/function-definition.m4
Normal file
3
Task/Function-definition/M4/function-definition.m4
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
define(`multiply',`eval($1*$2)')
|
||||
|
||||
multiply(2,3)
|
||||
3
Task/Function-definition/MATLAB/function-definition.m
Normal file
3
Task/Function-definition/MATLAB/function-definition.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
function C = multiply(A,B)
|
||||
C = A*B;
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue