identity is of type for all types A, A to A.
define function identity of x:
return x.
end.
constant is of type for all types A and B, A to B to A.
define function constant of x of y:
return x.
end.
define factorial of type int to int of n:
if n equals 0, then: return 1.
else: return n times factorial of (n minus 1).
end.
Name:
Anonymous2012-01-25 0:57
>>23 define foo of type int and float to float of a and b:
return 2 times b plus a.
end
Maybe integer and binary could be integer types and real and computational could be floating-point types to make it more COBOL like. I think as 'type' would be a good syntax for casts, like b as integer.
foo is of type int and float to float.
define function foo of a and b:
return the addition of the multiplication of two point oh and b and a.
end.
?
foo is of type int and float to float.
define function foo of a and b:
let two b be the multiplication of two point oh and b, in the following:
return the addition of two b and a.
end.
?
foo is of type int and float to float.
define function foo of a and b:
return the multiplication of two point oh and b, followed by an addition by a.
end.
?
Name:
Anonymous2012-01-25 1:11
dot product is of type for all types satisfying multiplication and addition A, ordered collection of A and ordered collection of A to A:
define function dot product of X and Y:
reduce using addition of map using multiplication of X and Y.
end.