File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change 1
1
module Main where
2
2
3
+ import Prelude
4
+
3
5
import Data.Tuple
4
6
import Data.Maybe
5
7
import Data.Array
@@ -8,7 +10,7 @@ import Data.Int
8
10
9
11
import Console
10
12
11
- collatz :: Int -> [ Int ]
13
+ collatz :: Int -> Array Int
12
14
collatz = unfoldr step
13
15
where
14
16
step n | n == one = Nothing
Original file line number Diff line number Diff line change 6
6
7
7
module Data.Unfoldable where
8
8
9
+ import Prelude
10
+
9
11
import Data.Maybe
10
12
import Data.Tuple
11
13
import Data.Array.ST
@@ -23,7 +25,7 @@ import Control.Monad.ST
23
25
class Unfoldable t where
24
26
unfoldr :: forall a b . (b -> Maybe (Tuple a b )) -> b -> t a
25
27
26
- instance unfoldableArray :: Unfoldable [] where
28
+ instance unfoldableArray :: Unfoldable Array where
27
29
unfoldr f b = runPure (runSTArray (do
28
30
arr <- emptySTArray
29
31
seed <- newSTRef b
You can’t perform that action at this time.
0 commit comments