stan-0.1.2.1: Haskell STatic ANalyser
Copyright(c) 2020 Kowainik
LicenseMPL-2.0
MaintainerKowainik <xrom.xkov@gmail.com>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Stan.Core.List

Description

Extra functions to work with lists.

Synopsis

Documentation

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

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)] Source #

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)]