/Prelude-v20.0.0/List/indexed.dhall
Copy path to clipboardTag each element of the list with its index
Examples
indexed Bool [ True, False, True ]
≡ [ { index = 0, value = True }
, { index = 1, value = False }
, { index = 2, value = True }
]
indexed Bool ([] : List Bool) ≡ ([] : List { index : Natural, value : Bool })
Source
--| Tag each element of the list with its index
let indexed
: ∀(a : Type) → List a → List { index : Natural, value : a }
= List/indexed
let example0 =
assert
: indexed Bool [ True, False, True ]
≡ [ { index = 0, value = True }
, { index = 1, value = False }
, { index = 2, value = True }
]
let example1 =
assert
: indexed Bool ([] : List Bool)
≡ ([] : List { index : Natural, value : Bool })
in indexed