diff options
author | Camil Staps | 2016-11-07 22:36:40 +0000 |
---|---|---|
committer | Camil Staps | 2016-11-07 22:36:40 +0000 |
commit | 4e074b282a8236dcc3599f76ce85d7e52a24d408 (patch) | |
tree | e45d3c8c530ed796ea4d31185837f433f73db247 /hamming.icl | |
parent | Update gitignore (diff) |
Adapted more examples to be standalone
Diffstat (limited to 'hamming.icl')
-rw-r--r-- | hamming.icl | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/hamming.icl b/hamming.icl index e623d7b..2544b04 100644 --- a/hamming.icl +++ b/hamming.icl @@ -11,7 +11,35 @@ having only 2, 3 and 5 as prime factors. Result: Run the program with the Show Constructors option on (Application options) */ -import StdEnv +(<) infix 4 :: !Int !Int -> Bool +(<) a b = code inline { + ltI +} + +(-) infixl 6 :: !Int !Int -> Int +(-) a b = code inline { + subI +} + +(*) infixl 7 :: !Int !Int -> Int +(*) a b = code inline { + mulI +} + +(==) infix 4 :: !Int !Int -> Bool +(==) a b = code inline { + eqI +} + +map :: (a -> b) [a] -> [b] +map f [] = [] +map f [x:xs] = [f x:map f xs] + +take :: Int [a] -> [a] +take 0 _ = [] +take n [x:xs] = [x:take (n-1) xs] + +//import StdEnv /* Ham (the Hamming function) returns an infinite list of numbers having two, three and five as only prime factors by recursively |