Useful-0.0.3: Some useful functions and shorthands.

Useful.List

Description

Useful List operations, part of the Useful module.

Synopsis

Documentation

explodeI :: Eq a => [a] -> a -> [[a]]Source

Takes a list item and splits a list around it, removing the item.

 $ explodeI "Hello there people" ' '
 ["Hello","there","people"]

splitI :: Eq a => [a] -> a -> [[a]]Source

Alias of explodeI

implodeI :: Eq a => [a] -> a -> [a]Source

Take a list item and concatinates each element of it around another given item.

 $implodeI "askjdnaskd" '!'
 "a!s!k!j!d!n!a!s!k!d"

joinI :: Eq a => [a] -> a -> [a]Source

alias of implodeI

explode :: Eq a => [a] -> [a] -> [[a]]Source

Takes a two lists and explodes the first into a new list, around the second. Removing the second list where it occurs.

THIS NEEDS FIXING

split :: Eq a => [a] -> [a] -> [[a]]Source

alias of explode

implode :: Eq a => [[a]] -> [a] -> [a]Source

Takes a list of lists and an extra list and concatinates the list of lists with the second list inbetween. When used with the empty list mimics concat

 $ implode ["helloasdad","asd hello","hello"] "!!"
 "helloasdad!!asd hello!!hello"

join :: Eq a => [[a]] -> [a] -> [a]Source

Alias of implode

takeFor :: Eq a => Int -> [a] -> [a]Source

takes n number of items from the front of a list, alias of take

 $ takeFor 5 "Hello there people"
 "Hello"

dropFor :: Eq a => Int -> [a] -> [a]Source

drops n number of items from the front of a list, alias of drop

 $ dropFor 5 "Hello there people"
 " there people"

takeBefore :: Eq a => Int -> [a] -> [a]Source

takes a number of items from a list before it reaches the index n

 $ takeBefore 5 "Hello there people"
 "Hello there p"

dropBefore :: Eq a => Int -> [a] -> [a]Source

drops a number of items from a list before it reaches the index n

 $ dropBefore 5 "Hello there people"
 "eople"

rmEmptyList :: Eq a => [[a]] -> [[a]]Source

In a list of lists this removes any occurances of the empty list. Can also be used to remove occurances of the empty string.

map2 :: (a -> b) -> [[a]] -> [[b]]Source

maps a function in depth N to the given list. map3, map4, map5 are also defined.

 $ map2 (*2) [[1,2,3,4],[1,1,1,2]]
 [[2,4,6,8],[2,2,2,4]]

replace :: Eq a => [a] -> [a] -> [a] -> [a]Source

Replaces any occuranses of the second list, with the third list, in the first list.

 $ replace "why hello hello there" "hello" "bonjour"
 "why bonjour bonjour there"

each :: [a] -> [[a]]Source

Takes a list of items and returns a list with each element in it's own single list.

 $ each "hello"
 ["h","e","l","l","o"]