Clean (programming language)
Clean | |
---|---|
Paradigms : | functional , non-strict , modular , declarative |
Publishing year: | 1987 |
Current version : | 2.4 (December 23, 2011) |
Influenced by: | Haskell |
Operating system : | Windows , Linux , Mac OS X , Solaris etc. |
License : | LGPL , commercial |
http://www.cs.ru.nl/~clean/ |
Clean is a functional programming language.
Clean is characterized by referential transparency , which means that the result of a function call only depends on the input parameters. With the same input parameters, you always get the same result.
Clean has similar properties to the Haskell programming language . The most striking difference is the use of uniqueness typing for input and output instead of a monad .
Examples
module hallo
Start = "Hallo Welt!"
module fakultaet
fak 0 = 1
fak n = n * fak (n-1)
// Berechne den Wert von 10 Fakultät
Start = fak 10
module fibonacci
fib 0 = 0
fib 1 = 1
fib n = fib (n - 2) + fib (n - 1)
// Berechne den Wert der siebten Fibonacci-Zahl
Start = fib 7
(^) infixr 8 :: Int Int -> Int
(^) x 0 = 1
(^) x n = x * x ^ (n-1)
The given type declaration defines the function (^)
as a right-associative infix operator with priority 8. This means that it is x*x^(n-1)
equivalent to x*(x^(n-1))
, and not to (x*x)^(n-1)
. The (^)
operator is predefined in the clean standard environment.
module sort
qsort :: [a] -> [a] | Ord a
qsort [] = []
qsort [a:xs] = qsort [x \\ x <- xs | x < a] ++ [a] ++ qsort [x \\ x <-xs | x >= a]
// sortiere Liste
Start = qsort [5,4,3,2,1]
Web links
- Website of Clean (English)