package bwd

  1. Overview
  2. Docs

Module Bwd.BwdLabelsSource

This module is similar to ListLabels but for backward lists.

Notes on the discrepancies with ListLabels:

  • Functions rev, rev_append, rev_map, and rev_map2 will never be included.
  • A new function prepend was added as the forward version of append.
  • A new module Notation was added for the infix notation.
  • Functions for association lists are currently missing, but might be added later.
  • Functions init, tl (as hd for lists), hd (as tl for lists), merge, to_seq, and of_seq are also missing, but might be added in the future.

Please open a GitHub issue if you want a function to be included. We want to make this library useful to you, too!

Sourcetype 'a t = 'a bwd =
  1. | Emp
  2. | Snoc of 'a bwd * 'a
Sourceval length : 'a bwd -> int
Sourceval compare_lengths : 'a bwd -> 'a bwd -> int
Sourceval compare_length_with : 'a bwd -> len:int -> int
Sourceval snoc : 'a bwd -> 'a -> 'a bwd
Sourceval nth : 'a bwd -> int -> 'a
Sourceval nth_opt : 'a bwd -> int -> 'a option
Sourceval append : 'a bwd -> 'a list -> 'a bwd
Sourceval prepend : 'a bwd -> 'a list -> 'a list

Comparison

Sourceval equal : eq:('a -> 'a -> bool) -> 'a bwd -> 'a bwd -> bool
Sourceval compare : cmp:('a -> 'a -> int) -> 'a bwd -> 'a bwd -> int

Iterators

Note that the iteration direction is from the right to the left, in the opposite direction of the corresponding functions in ListLabels.

Sourceval iter : f:('a -> unit) -> 'a bwd -> unit
Sourceval iteri : f:(int -> 'a -> unit) -> 'a bwd -> unit
Sourceval map : f:('a -> 'b) -> 'a bwd -> 'b bwd
Sourceval mapi : f:(int -> 'a -> 'b) -> 'a bwd -> 'b bwd
Sourceval filter_map : f:('a -> 'b option) -> 'a bwd -> 'b bwd
Sourceval fold_left : f:('a -> 'b -> 'a) -> init:'a -> 'b bwd -> 'a
Sourceval fold_right_map : f:('a -> 'b -> 'b * 'c) -> 'a bwd -> init:'b -> 'b * 'c bwd
Sourceval fold_right : f:('a -> 'b -> 'b) -> 'a bwd -> init:'b -> 'b

Iterators on two lists

Note that the iteration direction is from the right to the left, in the opposite direction of the corresponding functions in ListLabels.

Sourceval iter2 : f:('a -> 'b -> unit) -> 'a bwd -> 'b bwd -> unit
Sourceval map2 : f:('a -> 'b -> 'c) -> 'a bwd -> 'b bwd -> 'c bwd
Sourceval fold_left2 : f:('a -> 'b -> 'c -> 'a) -> init:'a -> 'b bwd -> 'c bwd -> 'a
Sourceval fold_right2 : f:('a -> 'b -> 'c -> 'c) -> 'a bwd -> 'b bwd -> init:'c -> 'c

List scanning

Note that the iteration direction is from the right to the left, in the opposite direction of the corresponding functions in ListLabels.

Sourceval for_all : f:('a -> bool) -> 'a bwd -> bool
Sourceval exists : f:('a -> bool) -> 'a bwd -> bool
Sourceval for_all2 : f:('a -> 'b -> bool) -> 'a bwd -> 'b bwd -> bool
Sourceval exists2 : f:('a -> 'b -> bool) -> 'a bwd -> 'b bwd -> bool
Sourceval mem : 'a -> set:'a bwd -> bool
Sourceval memq : 'a -> set:'a bwd -> bool

List searching

Note that the iteration direction is from the right to the left, in the opposite direction of the corresponding functions in ListLabels.

Sourceval find : f:('a -> bool) -> 'a bwd -> 'a
Sourceval find_opt : f:('a -> bool) -> 'a bwd -> 'a option
Sourceval find_map : f:('a -> 'b option) -> 'a bwd -> 'b option
Sourceval filter : f:('a -> bool) -> 'a bwd -> 'a bwd
Sourceval find_all : f:('a -> bool) -> 'a bwd -> 'a bwd
Sourceval filteri : f:(int -> 'a -> bool) -> 'a bwd -> 'a bwd
Sourceval partition : f:('a -> bool) -> 'a bwd -> 'a bwd * 'a bwd
Sourceval partition_map : f:('a -> ('b, 'c) Either.t) -> 'a bwd -> 'b bwd * 'c bwd

Lists of pairs

Sourceval split : ('a * 'b) bwd -> 'a bwd * 'b bwd
Sourceval combine : 'a bwd -> 'b bwd -> ('a * 'b) bwd

Backward and forward lists

Sourceval to_list : 'a bwd -> 'a list
Sourceval of_list : 'a list -> 'a bwd

Infix notation

Sourcemodule Infix : sig ... end

Notation inspired by Conor McBride.