Source/Packages

Std.List

packages/foundation/standard/src/Std/List.alpha

428 lines21 declarations14.7 KiBSHA-256 1d350bdfe159

def · lines 265–291

stdListTake

Full file
The first `count` elements (all of them when the list is shorter); the structural recursion is on the count, the list is eliminated one cell at a time under it (Language & Testing Evolution L5: shrinkers halve lists).
265def stdListTake =
266  (lambda erased element : Type 0 .
267    unrestricted count : Nat .
268    unrestricted values : (family StdList element) .
269    app
270      (nat-eliminate
271        (lambda unrestricted current : Nat . pi unrestricted remaining : (family StdList element) .
272          family StdList element)
273        (lambda unrestricted remaining : (family StdList element) .
274          constructor StdList StdListEmpty element)
275        (lambda unrestricted predecessor : Nat .
276          unrestricted induction : (pi unrestricted remaining : (family StdList element) . family StdList element) .
277          unrestricted remaining : (family StdList element) .
278          eliminate
279            StdList
280            (lambda unrestricted current : (family StdList element) . family StdList element)
281            remaining
282            (branch StdListEmpty . constructor StdList StdListEmpty element)
283            (branch
284              StdListCons
285              head
286              tail
287              tailInduction
288              .
289              constructor StdList StdListCons element head (induction tail)))
290        count)
291      values)

The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.