stan-0.2.0.0: Haskell STatic ANalyser

Copyright | (c) 2020 Kowainik
License | MPL-2.0
Maintainer | Kowainik <xrom.xkov@gmail.com>
Safe Haskell | None
Language | Haskell2010

Stan.Core.List

Description

Extra functions to work with lists.

Synopsis

- checkWith :: (a -> b -> Bool) -> [a] -> [b] -> Bool
- nonRepeatingPairs :: [a] -> [(a, a)]

# Documentation

checkWith :: (a -> b -> Bool) -> [a] -> [b] -> Bool #

Checks that two lists have the same length and that a given binary predicate returns `True` on each corresponding pair of elements.

    >>> checkWith (==) [] []
    True
    >>> checkWith (==) [1, 2] [1, 2]
    True
    >>> checkWith (==) [1, 2] [2, 1]
    False
    >>> checkWith (==) [1, 2] [1]
    False

nonRepeatingPairs :: [a] -> [(a, a)] #

Returns list all element pairs without the following properties:

- No element with itself: `(x, x)`
- Only one of `(x, y)` and `(y, x)` will be in the result

In other words, it's like taking the cross product of the list with itself and then keeping only the half of that without the diagonal.

    >>> foo [1..3]
    [(1, 2), (1, 3), (2, 3)]