September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,5 @@
|
|||
INTEGER FUNCTION MULTIPLY( A, B );
|
||||
INTEGER A, B;
|
||||
BEGIN
|
||||
MULTIPLY := A * B;
|
||||
END;
|
||||
3
Task/Function-definition/Bc/function-definition.bc
Normal file
3
Task/Function-definition/Bc/function-definition.bc
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
define multiply(a, b) { return a*b }
|
||||
|
||||
print multiply(2, 3)
|
||||
1
Task/Function-definition/Dc/function-definition-1.dc
Normal file
1
Task/Function-definition/Dc/function-definition-1.dc
Normal file
|
|
@ -0,0 +1 @@
|
|||
[*] sm
|
||||
2
Task/Function-definition/Dc/function-definition-2.dc
Normal file
2
Task/Function-definition/Dc/function-definition-2.dc
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
3 4 lm x f
|
||||
= 12
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
real multiply(RealNumber a, RealNumber b)
|
||||
= a * b.
|
||||
|
|
@ -0,0 +1 @@
|
|||
symbol f := (:x:y)(x * y).
|
||||
7
Task/Function-definition/Elm/function-definition.elm
Normal file
7
Task/Function-definition/Elm/function-definition.elm
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--There are multiple ways to create a function in Elm
|
||||
|
||||
--This is a named function
|
||||
multiply x y = x*y
|
||||
|
||||
--This is an anonymous function
|
||||
\x y -> x*y
|
||||
11
Task/Function-definition/Gambas/function-definition.gambas
Normal file
11
Task/Function-definition/Gambas/function-definition.gambas
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Public Sub Main()
|
||||
|
||||
Print Multiply(56, 4.66)
|
||||
|
||||
End
|
||||
|
||||
Public Sub Multiply(f1 As Float, f2 As Float) As Float
|
||||
|
||||
Return f1 * f2
|
||||
|
||||
End
|
||||
4
Task/Function-definition/Halon/function-definition.halon
Normal file
4
Task/Function-definition/Halon/function-definition.halon
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
function multiply( $a, $b )
|
||||
{
|
||||
return $a * $b;
|
||||
}
|
||||
2
Task/Function-definition/Hy/function-definition-1.hy
Normal file
2
Task/Function-definition/Hy/function-definition-1.hy
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defn multiply [a b]
|
||||
(* a b))
|
||||
1
Task/Function-definition/Hy/function-definition-2.hy
Normal file
1
Task/Function-definition/Hy/function-definition-2.hy
Normal file
|
|
@ -0,0 +1 @@
|
|||
(def multiply (fn [a b] (* a b)))
|
||||
96
Task/Function-definition/IWBASIC/function-definition.iwbasic
Normal file
96
Task/Function-definition/IWBASIC/function-definition.iwbasic
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
'1. Not Object Oriented Program
|
||||
|
||||
DECLARE Multiply(N1:INT,N2:INT),INT
|
||||
|
||||
DEF A,B:INT
|
||||
|
||||
A=2:B=2
|
||||
|
||||
OPENCONSOLE
|
||||
|
||||
PRINT Multiply(A,B)
|
||||
|
||||
PRINT
|
||||
|
||||
'When compiled as a console only program, a press any key to continue is automatic.
|
||||
CLOSECONSOLE
|
||||
|
||||
END
|
||||
|
||||
SUB Multiply(N1:INT,N2:INT),INT
|
||||
|
||||
DEF Product:INT
|
||||
|
||||
Product=N1*N2
|
||||
|
||||
RETURN Product
|
||||
ENDSUB
|
||||
|
||||
'Can also be written with no code in the subroutine and just RETURN N1*N2.
|
||||
|
||||
----
|
||||
|
||||
'2. Not Object Oriented Program Using A Macro
|
||||
|
||||
$MACRO Multiply (N1,N2) (N1*N2)
|
||||
|
||||
DEF A,B:INT
|
||||
|
||||
A=5:B=5
|
||||
|
||||
OPENCONSOLE
|
||||
|
||||
PRINT Multiply (A,B)
|
||||
|
||||
PRINT
|
||||
|
||||
'When compiled as a console only program, a press any key to continue is automatic.
|
||||
CLOSECONSOLE
|
||||
|
||||
END
|
||||
|
||||
----
|
||||
|
||||
'3. In An Object Oriented Program
|
||||
|
||||
CLASS Associate
|
||||
'functions/methods
|
||||
DECLARE Associate:'object constructor
|
||||
DECLARE _Associate:'object destructor
|
||||
'***Multiply declared***
|
||||
DECLARE Multiply(UnitsSold:UINT),UINT
|
||||
'members
|
||||
DEF m_Price:UINT
|
||||
DEF m_UnitsSold:UINT
|
||||
DEF m_SalesTotal:UINT
|
||||
ENDCLASS
|
||||
|
||||
DEF Emp:Associate
|
||||
|
||||
m_UnitsSold=10
|
||||
|
||||
Ass.Multiply(m_UnitsSold)
|
||||
|
||||
OPENCONSOLE
|
||||
|
||||
PRINT"Sales total: ",:PRINT"$"+LTRIM$(STR$(Emp.m_SalesTotal))
|
||||
|
||||
PRINT
|
||||
|
||||
CLOSECONSOLE
|
||||
|
||||
END
|
||||
|
||||
'm_price is set in constructor
|
||||
SUB Associate::Multiply(UnitsSold:UINT),UINT
|
||||
m_SalesTotal=m_Price*UnitsSold
|
||||
RETURN m_SalesTotal
|
||||
ENDSUB
|
||||
|
||||
SUB Associate::Associate()
|
||||
m_Price=10
|
||||
ENDSUB
|
||||
|
||||
SUB Associate::_Associate()
|
||||
'Nothing to cleanup
|
||||
ENDSUB
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
function C = multiply(A,B)
|
||||
C = A*B;
|
||||
end
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
proc multiply(a, b: Int): Int =
|
||||
result = a * b
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
proc multiply(a, b: Int): Int =
|
||||
return a * b
|
||||
|
|
@ -0,0 +1 @@
|
|||
[&MULTIPLY#,A#,B#],A#<,B#<MUL RF
|
||||
3
Task/Function-definition/OASYS/function-definition.oasys
Normal file
3
Task/Function-definition/OASYS/function-definition.oasys
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
method int multiply int x int y {
|
||||
return x * y
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
SAY multiply(5, 6)
|
||||
EXIT
|
||||
|
||||
multiply:
|
||||
PROCEDURE
|
||||
PARSE ARG x, y
|
||||
RETURN x*y
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
say multiply(5, 6)
|
||||
|
||||
::routine multiply
|
||||
use arg x, y
|
||||
return x *y
|
||||
1
Task/Function-definition/SPL/function-definition-1.spl
Normal file
1
Task/Function-definition/SPL/function-definition-1.spl
Normal file
|
|
@ -0,0 +1 @@
|
|||
multiply(a,b) <= a*b
|
||||
4
Task/Function-definition/SPL/function-definition-2.spl
Normal file
4
Task/Function-definition/SPL/function-definition-2.spl
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
multiply(a,b)=
|
||||
x = a*b
|
||||
<= x
|
||||
.
|
||||
1
Task/Function-definition/Zkl/function-definition-1.zkl
Normal file
1
Task/Function-definition/Zkl/function-definition-1.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
fcn multiply(x,y){x*y}
|
||||
1
Task/Function-definition/Zkl/function-definition-2.zkl
Normal file
1
Task/Function-definition/Zkl/function-definition-2.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
fcn(x,y){x*y}(4.5,3) // --> 13.5
|
||||
2
Task/Function-definition/Zkl/function-definition-3.zkl
Normal file
2
Task/Function-definition/Zkl/function-definition-3.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fcn multiply{vm.arglist.reduce('*)}
|
||||
multiply(1,2,3,4,5) //--> 120
|
||||
1
Task/Function-definition/Zkl/function-definition-4.zkl
Normal file
1
Task/Function-definition/Zkl/function-definition-4.zkl
Normal file
|
|
@ -0,0 +1 @@
|
|||
var mul=Op("*"); mul(4,5) //-->20
|
||||
Loading…
Add table
Add a link
Reference in a new issue