Call a function: Difference between revisions
Content added Content deleted
(+Haskell) |
|||
Line 344: | Line 344: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
<lang haskell> |
|||
-- Calling a function with a fixed number of arguments |
|||
multiply x y = x * y |
|||
multiply 10 20 -- returns 200 |
|||
-- Calling a function that requires no arguments |
|||
-- Normally, you use constant instead of function without arguments: |
|||
twopi = 6.28 |
|||
-- But you can also pass special value as the first argument indicating function call: |
|||
twopi () = 6.28 -- definition |
|||
twopi :: Num a => () -> a -- its type |
|||
twopi () -- returns 6.28 |
|||
-- TODO: |
|||
-- Calling a function with optional arguments |
|||
-- Calling a function with a variable number of arguments |
|||
-- Calling a function with named arguments |
|||
-- Using a function in statement context |
|||
-- Using a function in first-class context within an expression |
|||
-- Obtaining the return value of a function |
|||
-- Distinguishing built-in functions and user-defined functions |
|||
-- Distinguishing subroutines and functions |
|||
-- Stating whether arguments are passed by value or by reference |
|||
-- Is partial application possible and how |
|||
</lang> |
|||
=={{header|J}}== |
=={{header|J}}== |