Methods
(static) drop(n, as) → {List}
Return the suffix of a List after discarding a specified number of values.
Haskell> drop :: Int -> [a] -> [a]
Parameters:
| Name | Type | Description | 
|---|---|---|
n | 
            
            number | The number of values to drop  | 
        
as | 
            
            List | The   | 
        
- Source:
 
Returns:
A new List, the desired suffix of the original list
- Type
 - List
 
Example
const lst = list(1,2,3);
drop(2, lst);            // => [3:[]]
        
            
    
    (static) dropWhile(p, as) → {List}
Drop values from a List while a given predicate function returns true for each value.
Haskell> dropWhile :: (a -> Bool) -> [a] -> [a]
Parameters:
| Name | Type | Description | 
|---|---|---|
p | 
            
            function | The predicate function (should return   | 
        
as | 
            
            List | The   | 
        
- Source:
 
Returns:
The List of values that do not satisfy the predicate function
- Type
 - List
 
Example
const lst = list(1,2,3,4,5,1,2,3);
const f = x => x < 3;
dropWhile(f, lst);                 // => [3:4:5:1:2:3:[]]
        
            
    
    (static) group(xs) → {List}
Take a List and return a List of lists such that the concatenation of the result is equal to
the argument. Each sublist in the result contains only equal values. Use groupBy to supply your
own equality function.
Haskell> group :: Eq a => [a] -> [[a]]
Parameters:
| Name | Type | Description | 
|---|---|---|
xs | 
            
            List | A   | 
        
- Source:
 
Returns:
- A 
Listof result lists 
- Type
 - List
 
Example
const str = fromStringToList(`Mississippi`);
group(str); // => [[M]:[i]:[ss]:[i]:[ss]:[i]:[pp]:[i]:[]]
        
            
    
    (static) groupBy(eq, as) → {List}
Take a List and return a List of lists such that the concatenation of the result is equal to
the argument. Each sublist in the result is grouped according to the the given equality function.
Haskell> groupBy :: (a -> a -> Bool) -> [a] -> [[a]]
Parameters:
| Name | Type | Description | 
|---|---|---|
eq | 
            
            function | A function to test the equality of elements (must return   | 
        
as | 
            
            List | A   | 
        
- Source:
 
Returns:
A List of result lists
- Type
 - List
 
(static) span(p, xs) → {Tuple}
Return a Tuple in which the first element is the longest prefix (possibly empty) of a List of
values that satisfy a predicate function and the second element is the rest of the list.
Haskell> span :: (a -> Bool) -> [a] -> ([a], [a])
Parameters:
| Name | Type | Description | 
|---|---|---|
p | 
            
            function | The predicate function (should return   | 
        
xs | 
            
            List | A   | 
        
- Source:
 
Returns:
The Tuple of results
- Type
 - Tuple
 
Example
const lst = list(1,2,3,4,1,2,3,4);
const f = x => x < 3;
span(f, lst);                      // => ([1:2:[]],[3:4:1:2:3:4:[]])
        
            
    
    (static) spanNot(p, xs) → {Tuple}
Return a Tuple in which the first element is the longest prefix (possibly empty) of a List of
values that do not satisfy a predicate function and the second element is the rest of the list.
Haskell> break :: (a -> Bool) -> [a] -> ([a], [a])
Parameters:
| Name | Type | Description | 
|---|---|---|
p | 
            
            function | The predicate function (should return   | 
        
xs | 
            
            List | A   | 
        
- Source:
 
Returns:
- The 
Tupleof results 
- Type
 - Tuple
 
Example
const lst = list(1,2,3,4,1,2,3,4);
const f = x => x > 3;
spanNot(f, lst);                   // => ([1:2:3:[]],[4:1:2:3:4:[]])
        
            
    
    (static) splitAt(n, xs) → {Tuple}
Return a Tuple in which the first element is the prefix of a List of a given length and the
second element is the remainder of the list.
Haskell> splitAt :: Int -> [a] -> ([a], [a])
Parameters:
| Name | Type | Description | 
|---|---|---|
n | 
            
            number | The length of the prefix  | 
        
xs | 
            
            List | The   | 
        
- Source:
 
Returns:
The split List
- Type
 - Tuple
 
Example
const lst = list(1,2,3);
splitAt(2, lst);         // => ([1:2:[]],[3:[]])
        
            
    
    (static) stripPrefix(as, bs) → {Maybe}
Drops the given prefix from a List. Returns Nothing if the list does not start with the given
prefix, or Just the List after the prefix, if it does.
Haskell> stripPrefix :: Eq a => [a] -> [a] -> Maybe [a]
Parameters:
| Name | Type | Description | 
|---|---|---|
as | 
            
            List | The prefix   | 
        
bs | 
            
            List | The   | 
        
- Source:
 
Returns:
- The result 
Listcontained in aJust, orNothing 
- Type
 - Maybe
 
Example
const prefix = fromStringToList(`foo`);
stripPrefix(prefix, fromStringToList(`foobar`));    // => Just [bar]
stripPrefix(prefix, fromStringToList(`foo`));       // => Just [[]]
stripPrefix(prefix, fromStringToList(`barfoo`));    // => Nothing
stripPrefix(prefix, fromStringToList(`barfoobaz`)); // => Nothing
        
            
    
    (static) take(n, as) → {List}
Return the prefix of a List of a given length.
Haskell> take :: Int -> [a] -> [a]
Parameters:
| Name | Type | Description | 
|---|---|---|
n | 
            
            number | The length of the prefix to take  | 
        
as | 
            
            List | The   | 
        
- Source:
 
Returns:
A new List, the desired prefix of the original list
- Type
 - List
 
Example
const lst = list(1,2,3);
take(2, lst);            // => [1:2:[]]
        
            
    
    (static) takeWhile(p, as) → {List}
Return the longest prefix (possibly empty) of a List of values that satisfy a predicate
function.
Haskell> takeWhile :: (a -> Bool) -> [a] -> [a]
Parameters:
| Name | Type | Description | 
|---|---|---|
p | 
            
            function | The predicate function (should return   | 
        
as | 
            
            List | The   | 
        
- Source:
 
Returns:
The List of values that satisfy the predicate function
- Type
 - List
 
Example
const lst = list(1,2,3,4,1,2,3,4);
const f = x => x < 3;
takeWhile(f, lst);                 // => [1:2:[]]