Comparisment

   - compare programming languages by example

10

Multiplication

Multiply two numbers.

Created by sam

Add a new answer

Either add an answer for a new language or add an alternative solution.
A description is only necessary when the code is not suitably 'obvious' or to justify an alternative approach.

Haskell

multiply :: Int -> Int -> Int
multiply x y = x * y

'*' is the infix multiplication operator between two arguments of type "Num a => a" of which "Int" is a defined instance.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Haskell

multiply :: Num a => a -> a -> a
multiply x y = x * y

Any instance of the "Num" typeclass can be multiplied together.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.

Python

def multiply(x, y): return x * y

* is the infix multiplication operator.

Created by: sam

Edit this answer

Edit the language, code and description simultaneously.