We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d5d7ca3 commit fb0117eCopy full SHA for fb0117e
readme.md
@@ -3,6 +3,21 @@
3
## Day 1:
4
5
The `windows` function from last year (day 9) ended up being useful already!
6
+It bothers me a little that I have two very similar functions, though, `pairs`
7
+differing from `windows 2` only in its result being a list of tuples instead of
8
+a list of lists:
9
+
10
+```haskell
11
+pairs :: [a] -> [(a,a)]
12
+pairs xs@(_:xs') = zip xs xs'
13
14
+windows :: Int -> [a] -> [[a]]
15
+windows m = foldr (zipWith (:)) (repeat []) . take m . tails
16
+```
17
18
+I could write a filtering function to work on the first two list items, but
19
+tuples' ability to use `uncurry :: (a -> b -> c) -> (a, b) -> c` is cool, and
20
+sticking with a 2-element data structure seems like the better thing to do.
21
22
23
## Day 2:
0 commit comments