Skip to content

List functions

The luego.list package contains utility functions to work with lists.

luego.list

append

append(li: List[A], e: A) => NonEmptyList[A]

Return a new list with an element appended, i.e. added at the end

arrayFill

arrayFill(size: Integer, x: X) => NonEmptyList[X]

Returns a array of the specified size filled with passed value (Boolean, Int, Long or Double)

arrayFill2

arrayFill2(numLines: Integer, numCols: Integer, x: X) => NonEmptyList[NonEmptyList[X]]

Returns a 2D array of the specified size filled with passed value (Boolean, Int, Long or Double)

arrayFill3

arrayFill3(numLines: Integer, numCols: Integer, numZ: Integer, x: X) => NonEmptyList[NonEmptyList[X]]

Returns a 3D array of the specified size filled with passed value (Boolean, Int, Long or Double)

concatList

concatList(li1: List[A], li2: List[A]) => List[A]

Concatenate two lists

distinct

distinct(li: List[X]) => List[X]

Selects all the elements of this list ignoring the duplicates.

headTail

headTail(li: NonEmptyList[X]) => (X,List[X])

Decompose a non empty list into a head and a tail.

headTailOption

headTailOption(li: List[X]) => Option[(X,List[X])]

Decompose a list into an head and a tail, wrapped in an option.

headTailUnsafe

headTailUnsafe(li: List[X]) => (X,List[X])

Decompose a list into an head and a tail. It will fail and raise an exception if the list is empty.

nonEmptyListOption

nonEmptyListOption(li: List[X]) => Option[NonEmptyList[X]]

Return a list wrapped in a Some if it is not empty, otherwise return None.

prepend

prepend(e: A, li: List[A]) => NonEmptyList[A]

Return a new list with the element e prepended, i.e. added at the beginning

reverse

reverse(li: List[X]) => List[X]

Returns a new list with the elements in reversed order.

tail

tail(li: NonEmptyList[X]) => List[X]

Returns the tail of the non empty collection.

zip

zip(li1: List[A], li2: List[B]) => List[(A,B)]

Returns a list formed from two lists by combining corresponding elements in pairs.

zipNEL

zipNEL(li1: NonEmptyList[A], li2: NonEmptyList[B]) => NonEmptyList[(A,B)]

Returns a non empty list formed from two non empty lists by combining corresponding elements in pairs.