aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Utils.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Utils.hs b/lib/Utils.hs
index 4319714..89b1bd3 100644
--- a/lib/Utils.hs
+++ b/lib/Utils.hs
@@ -5,11 +5,13 @@ module Utils ( binaryToInt
5 , bet 5 , bet
6 , (&+) 6 , (&+)
7 , howMany 7 , howMany
8 , sublists
8 ) where 9 ) where
9 10
10import Data.Char (digitToInt) 11import Data.Char (digitToInt)
11import Control.Monad 12import Control.Monad
12import Data.Either 13import Data.Either
14import Data.List (inits, tails)
13 15
14 16
15binaryToInt :: String -> Int 17binaryToInt :: String -> Int
@@ -34,3 +36,6 @@ bet k (l, u) = k >= l && k <= u
34 36
35howMany :: (a -> Bool) -> [a] -> Int 37howMany :: (a -> Bool) -> [a] -> Int
36howMany predicate = length . filter predicate 38howMany predicate = length . filter predicate
39
40sublists :: [a] -> [[a]]
41sublists = concatMap inits . tails