Skip to content

Commit 8f6bd39

Browse files
committed
fiddle with gray code
1 parent 13f3be8 commit 8f6bd39

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

execs/Day25.hs

+4-5
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,10 @@ graycode ::
6060
(a -> a) {- inverse action -} ->
6161
[a] {- items -} ->
6262
[a] {- search instructions -}
63-
graycode tick _ _ [] = [tick]
64-
graycode tick f1 f2 (x:xs) =
65-
graycode tick f1 f2 xs ++
66-
[f1 x] ++
67-
reverse (graycode tick f2 f1 xs)
63+
graycode tick f1 f2 xs = foldr step base xs f1 []
64+
where
65+
base = \_ -> (tick:)
66+
step x go = \f -> go f1 . (f x :) . go f2
6867

6968
items :: [String]
7069
items =

0 commit comments

Comments
 (0)