diff options
author | Akshay <[email protected]> | 2020-12-09 06:13:55 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-09 06:13:55 +0000 |
commit | ac3191ae40b8df0873f2e04f5bc1017322941b5d (patch) | |
tree | 88e845ae69db0beb70c6e1b0d9d96b3699a77774 /lib | |
parent | 644c38de8b633dc5e03bff5216f68b2bfde4a645 (diff) |
be more <<<functional>>>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Utils.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Utils.hs b/lib/Utils.hs index 89b1bd3..1381f16 100644 --- a/lib/Utils.hs +++ b/lib/Utils.hs | |||
@@ -6,6 +6,7 @@ module Utils ( binaryToInt | |||
6 | , (&+) | 6 | , (&+) |
7 | , howMany | 7 | , howMany |
8 | , sublists | 8 | , sublists |
9 | , windows | ||
9 | ) where | 10 | ) where |
10 | 11 | ||
11 | import Data.Char (digitToInt) | 12 | import Data.Char (digitToInt) |
@@ -39,3 +40,6 @@ howMany predicate = length . filter predicate | |||
39 | 40 | ||
40 | sublists :: [a] -> [[a]] | 41 | sublists :: [a] -> [[a]] |
41 | sublists = concatMap inits . tails | 42 | sublists = concatMap inits . tails |
43 | |||
44 | windows :: Int -> [a] -> [[a]] | ||
45 | windows m = foldr (zipWith (:)) (repeat []) . take m . tails | ||