setgame-1.1: A console interface to the game of Set

Safe HaskellSafe
LanguageHaskell98

Set.Utils

Synopsis

Documentation

groups :: Int -> [a] -> [[a]] Source

groups breaks a list into sublists of the given size. The final resulting group may contain fewer elements than the given size. Property: For all positive n. concat (groups n xs) == xs

delete1 :: Eq a => a -> [a] -> Maybe [a] Source

delete1 returns a list with the first occurrence of @x removed. If there is no occurrence Nothing is returned.

index :: Int -> [a] -> Maybe a Source

index returns the element at the given 0-based index and returns Nothing on failure.

select :: Int -> [a] -> (a, [a]) Source

Extract an element from a list by index returning that element and the remaining list.

init' :: [a] -> [a] Source

Drop last element of list if there is an element to drop.

chooseTwo :: [a] -> [(a, a)] Source

chooseTwo returns all combinations of two elements.

seconds :: Int -> Int Source

seconds converts seconds to microseconds for use in threadDelay.

shuffleIO :: [a] -> IO [a] Source

shuffleIO calls shuffle using a generator from newStdGen.

shuffle :: RandomGen g => [a] -> g -> ([a], g) Source

shuffle shuffles the elements of a list using the given random generator.

shuffle' :: RandomGen g => Int -> [a] -> g -> ([a], g) Source

centerText :: Int -> String -> String Source

centerText centers the given string in a field of @width characters.

leftPadText :: Int -> String -> String Source

centerText right-aligns the given string in a field of @width characters.

rightPadText :: Int -> String -> String Source

centerText left-aligns the given string in a field of @width characters.