aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2021-01-14 20:52:15 +0000
committerGitHub <noreply@github.com>2021-01-14 20:52:15 +0000
commitcebbd79c18a3d0716dbbabc0d696c1df5994039a (patch)
tree82d0f769095082cb54eb9007e7c6e65959390df8
parent18d14d5ae5d5569ad075fac98c113a36226addb0 (diff)
parent9ef588dec5a05c6f29ccdc13f08e333a23ff20f9 (diff)
downloadperlweeklychallenge-club-cebbd79c18a3d0716dbbabc0d696c1df5994039a.tar.gz
perlweeklychallenge-club-cebbd79c18a3d0716dbbabc0d696c1df5994039a.tar.bz2
perlweeklychallenge-club-cebbd79c18a3d0716dbbabc0d696c1df5994039a.zip
Merge pull request #3263 from stuart-little/stuart-little_029_haskell
1st commit on 029_haskell
-rwxr-xr-xchallenge-029/stuart-little/haskell/ch-1.hs11
-rwxr-xr-xchallenge-029/stuart-little/haskell/ch-2.hs19
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-029/stuart-little/haskell/ch-1.hs b/challenge-029/stuart-little/haskell/ch-1.hs
new file mode 100755
index 0000000000..5d33e5bbaa
--- /dev/null
+++ b/challenge-029/stuart-little/haskell/ch-1.hs
@@ -0,0 +1,11 @@
+#!/usr/bin/env runghc
+
+-- run <script> <space-separated strings, with no whitespace between braces>
+
+import System.Environment (getArgs,)
+import Data.List.Extra (notNull,)
+import Data.List.Split (splitOneOf,)
+
+main = do
+ wordchains <- getArgs >>= return.(map ((filter notNull).(splitOneOf "{,}")))
+ mapM_ putStrLn $ map unwords $ sequence wordchains
diff --git a/challenge-029/stuart-little/haskell/ch-2.hs b/challenge-029/stuart-little/haskell/ch-2.hs
new file mode 100755
index 0000000000..ea38562d5d
--- /dev/null
+++ b/challenge-029/stuart-little/haskell/ch-2.hs
@@ -0,0 +1,19 @@
+#!/usr/bin/env runghc
+
+{-
+run <script>
+
+ref:
+http://book.realworldhaskell.org/read/interfacing-with-c-the-ffi.html
+-}
+
+{-# LANGUAGE ForeignFunctionInterface #-}
+
+import Foreign
+import Foreign.C.Types
+
+foreign import ccall "math.h exp"
+ c_exp :: CDouble -> CDouble
+
+main = do
+ mapM_ (print . c_exp) [1..10]