aboutsummaryrefslogtreecommitdiff
path: root/challenge-015/stuart-little/haskell/ch-1.hs
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-015/stuart-little/haskell/ch-1.hs')
-rwxr-xr-xchallenge-015/stuart-little/haskell/ch-1.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-015/stuart-little/haskell/ch-1.hs b/challenge-015/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..b28f56137d
--- /dev/null
+++ b/challenge-015/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,15 @@
+#!/usr/bin/env runghc
+
+-- run <script>
+
+import Data.Numbers.Primes (primes,)
+import Data.List (transpose,)
+
+sprimes = map (\(x:y:z:_) -> y) $ filter (\(x:y:z:_)-> x+z < 2*y) $ transpose $ take 3 $ iterate tail primes
+
+wprimes = map (\(x:y:z:_) -> y) $ filter (\(x:y:z:_)-> x+z > 2*y) $ transpose $ take 3 $ iterate tail primes
+
+main = do
+ let n = 10
+ putStrLn ("Strong primes: " ++ (unwords $ map show $ take n sprimes))
+ putStrLn ("Weak primes: " ++ (unwords $ map show $ take n wprimes))