Created
April 10, 2016 14:37
-
-
Save wikjez/3cdd8b4b9f62645a529837337924716c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getFactors :: Integer -> [Integer] | |
getFactors n = filter (\x -> n `mod` x == 0) [2..n] | |
isPrime :: Integer -> Bool | |
isPrime n = n > 1 && (head . getFactors) n == n | |
occurs :: Integer -> [Integer] -> Integer | |
occurs _ [] = 0 | |
occurs n (x:xs) = if n == x | |
then 1 + occurs n xs | |
else occurs n xs | |
listWithout :: [Integer] -> [Integer] -> [Integer] | |
listWithout a b = filter isNotPrimeQuantity a | |
where isNotPrimeQuantity x = not $ isPrime $ occurs x b | |
-- uruchamianie uzywajac interpretera haskella: | |
-- >:load zad.hs | |
-- >listWithout [2,3,9,2,5,1,3,7,10] [2,1,3,4,3,10,6,6,1,7,10,10,10] | |
-- [2,9,2,5,7,10] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment