From 4e074b282a8236dcc3599f76ce85d7e52a24d408 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 7 Nov 2016 22:36:40 +0000 Subject: Adapted more examples to be standalone --- hamming.icl | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'hamming.icl') 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 -- cgit v1.2.3