Logo

Programming-Idioms

  • Scheme
square = lambda x: x * x
def square(x):
    return x*x

You don't have to explicitly write the return type
def square(x):
    return x**2

You can use power operator
(define (square x)
    (* x x))

This is a short syntax for a lambda definition.
(define square
    (lambda (x)
        (* x x)))
function Square (X : Integer) return Integer is
begin
   return X * X;
end Square;

New implementation...
< >
programming-idioms.org