Source/Packages

Std.List

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

317 lines21 declarations13.5 KiBSHA-256 0d04bb5f90d2

def · lines 201–222

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).
201def stdListTake =
202  (lambda erased element : Type 0 .
203    unrestricted count : Nat .
204    unrestricted values : (family StdList element) .
205    app
206      (nat-eliminate
207        (lambda unrestricted current : Nat .
208          pi unrestricted remaining : (family StdList element) . family StdList element)
209        (lambda unrestricted remaining : (family StdList element) .
210          constructor StdList StdListEmpty element)
211        (lambda unrestricted predecessor : Nat .
212          unrestricted induction : (pi unrestricted remaining : (family StdList element) . family StdList element) .
213          unrestricted remaining : (family StdList element) .
214          eliminate
215            StdList
216            (lambda unrestricted current : (family StdList element) . family StdList element)
217            remaining
218            (branch StdListEmpty . constructor StdList StdListEmpty element)
219            (branch StdListCons head tail tailInduction .
220              constructor StdList StdListCons element head (induction tail)))
221        count)
222      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.