Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,4 +1,4 @@
|
|||
* Multiply in COBOL
|
||||
* Multiply in COBOL
|
||||
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. myTest.
|
||||
|
|
|
|||
|
|
@ -14,9 +14,7 @@ T multiply2(T)(T a, T b) {
|
|||
}
|
||||
|
||||
// Compile-time multiplication can also be done using templates:
|
||||
template multiply3(int a, int b) {
|
||||
enum multiply3 = a * b;
|
||||
}
|
||||
enum multiply3(int a, int b) = a * b;
|
||||
|
||||
pragma(msg, multiply3!(2, 3)); // Prints "6" during compilation.
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
multiply = (*)
|
||||
multiply x y = x * y
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
multiply = \ x y -> x*y
|
||||
multiply = (*)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
multiply = \ x y -> x*y
|
||||
|
|
@ -0,0 +1 @@
|
|||
f(a, b):= a*b;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
% Module ceremony elided...
|
||||
:- func multiply(integer, integer) = integer.
|
||||
multiply(A, B) = A * B.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
public Multiply (a : int, b : int) : int // this is either a class or module method
|
||||
{
|
||||
def multiply(a, b) { return a * b } // this is a local function, can take advantage of type inference
|
||||
return multiply(a, b)
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
function multiply returns dec (a as dec , b as dec ):
|
||||
return a * b .
|
||||
end.
|
||||
|
|
@ -0,0 +1 @@
|
|||
multiply(A, B, P) :- P is A * B.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
go :-
|
||||
multiply(5, 2, P),
|
||||
format("The product is ~d.~n", [P]).
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
test_multiply :-
|
||||
multiply(5, 2, 10), % this will pass
|
||||
multiply(3, 4, 11). % this will not pass
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
:- use_module(library(function_expansion)).
|
||||
|
||||
user:function_expansion(multiply(A, B), P, P is A * B). % "function" definition
|
||||
|
||||
go :-
|
||||
format("The product is ~d.~n", [multiply(5, 2)]).
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
go :-
|
||||
A is 5*2,
|
||||
format('The product is ~d.~n', [A]).
|
||||
Loading…
Add table
Add a link
Reference in a new issue