diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-04-13 15:52:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 15:52:48 +0100 |
| commit | 9e6aaa1a4cb45d2ab8d9d7833bbccdb09c27cb4b (patch) | |
| tree | 888532591b455c4460dda4faad84174f96919d8b | |
| parent | a71cbbc97f861fa97c2b323d27f8992f0a3ab811 (diff) | |
| parent | 1c6ccf451612ee41460111502869b9bf3c94a096 (diff) | |
| download | perlweeklychallenge-club-9e6aaa1a4cb45d2ab8d9d7833bbccdb09c27cb4b.tar.gz perlweeklychallenge-club-9e6aaa1a4cb45d2ab8d9d7833bbccdb09c27cb4b.tar.bz2 perlweeklychallenge-club-9e6aaa1a4cb45d2ab8d9d7833bbccdb09c27cb4b.zip | |
Merge pull request #3886 from stuart-little/stuart-little_108_haskell
1st commit on 108_haskell
| -rwxr-xr-x | challenge-108/stuart-little/haskell/ch-1.hs | 20 | ||||
| -rwxr-xr-x | challenge-108/stuart-little/haskell/ch-2.hs | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/challenge-108/stuart-little/haskell/ch-1.hs b/challenge-108/stuart-little/haskell/ch-1.hs new file mode 100755 index 0000000000..f74afd1560 --- /dev/null +++ b/challenge-108/stuart-little/haskell/ch-1.hs @@ -0,0 +1,20 @@ +#!/usr/bin/env runghc + +-- run <script> +-- ref: https://stackoverflow.com/a/18563789/11064961 + +{-# LANGUAGE MagicHash, BangPatterns #-} + +import GHC.Exts + +data Ptr' a = Ptr' a + +getIntAddr :: Int -> Int +getIntAddr x = let !y = Ptr' x in unsafeCoerce# y :: Int + +x :: Int +x=5 + +main :: IO () +main = do + putStrLn $ "The variable x has value " ++ (show x) ++ " and address " ++ (show . getIntAddr $! x) ++ "." diff --git a/challenge-108/stuart-little/haskell/ch-2.hs b/challenge-108/stuart-little/haskell/ch-2.hs new file mode 100755 index 0000000000..fc211e469c --- /dev/null +++ b/challenge-108/stuart-little/haskell/ch-2.hs @@ -0,0 +1,6 @@ +#!/usr/bin/env runghc + +-- run <script> + +main = do + putStrLn "1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147" |
