summaryrefslogtreecommitdiff
path: root/hamming.icl
diff options
context:
space:
mode:
Diffstat (limited to 'hamming.icl')
-rw-r--r--hamming.icl30
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