Source/Packages

Std.List

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

428 lines21 declarations14.7 KiBSHA-256 1d350bdfe159

def · lines 212–260

stdListZipWith

Full file
Combine two lists position by position, keeping their order; the result is as long as the SHORTER list (the rest of the longer one is dropped -- callers that need equal lengths must establish them). The left list is eliminated into a function of the right one, so both spines are walked together.
212def stdListZipWith =
213  (lambda erased left : Type 0 .
214    erased right : Type 0 .
215    erased result : Type 0 .
216    unrestricted combine : (pi unrestricted l : left . unrestricted r : right . result) .
217    unrestricted lefts : (family StdList left) .
218    unrestricted rights : (family StdList right) .
219    app
220      (eliminate
221        StdList
222        (lambda unrestricted current : (family StdList left) .
223          pi unrestricted others : (family StdList right) .
224          family StdList result)
225        lefts
226        (branch
227          StdListEmpty
228          .
229          lambda
230          unrestricted
231          others
232          :
233          (family StdList right)
234          .
235          constructor StdList StdListEmpty result)
236        (branch
237          StdListCons
238          head
239          tail
240          induction
241          .
242          lambda
243          unrestricted
244          others
245          :
246          (family StdList right)
247          .
248          eliminate
249            StdList
250            (lambda unrestricted inner : (family StdList right) . family StdList result)
251            others
252            (branch StdListEmpty . constructor StdList StdListEmpty result)
253            (branch
254              StdListCons
255              otherHead
256              otherTail
257              otherInduction
258              .
259              constructor StdList StdListCons result (combine head otherHead) (induction otherTail))))
260      rights)

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.