/*---------------------------------------------------------------------------
  Copyright 2012-2024, Microsoft Research, Daan Leijen.

  This is free software; you can redistribute it and/or modify it under the
  terms of the Apache License, Version 2.0. A copy of the License can be
  found in the LICENSE file at the root of this distribution.
---------------------------------------------------------------------------*/

// Standard `:list` functions.
module std/core/liststd/core/list

import std/core/typesstd/core/types
import std/core/undivstd/core/undiv
import std/core/hndstd/core/hnd
import std/core/exnstd/core/exn
import std/core/charstd/core/char
import std/core/stringstd/core/string
import std/core/intstd/core/int
import std/core/vectorstd/core/vector


// Return the head of list if the list is not empty.
pub fbip fun maybe/headstd/core/list/maybe/head: forall<a> (xs : list<a>) -> maybe<a>( xsxs: list<$561> : liststd/core/types/list: V -> V<aa: V> )result: -> total maybe<586> : maybestd/core/types/maybe: V -> V<aa: V>
  match xsxs: list<$561>
    Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $561) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $561)
    _       -> Nothingstd/core/types/Nothing: forall<a> maybe<a>

// Return the head of list with a default value in case the list is empty.
pub fbip fun headstd/core/list/head: forall<a> (xs : list<a>, default : a) -> a( xsxs: list<$591> : liststd/core/types/list: V -> V<aa: V>, defaultdefault: $591 : aa: V )result: -> total 607 : astd/core/types/total: E
  match xsxs: list<$591>
    Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $591) -> xx: $591
    _       -> defaultdefault: $591

// Return the tail of list. Returns the empty list if `xs` is empty.
pub fbip fun tailstd/core/list/tail: forall<a> (xs : list<a>) -> list<a>( xsxs: list<$612> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<630> : liststd/core/types/list: V -> V<aa: V>
  match xsxs: list<$612>
    Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,xxxx: list<$612>) -> xxxx: list<$612>
    _          -> [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>

// Is the list empty?
pub fip fun is-emptystd/core/list/is-empty: forall<a> (xs : list<a>) -> bool( ^xsxs: list<$635> : liststd/core/types/list: V -> V<aa: V> )result: -> total bool : boolstd/core/types/bool: V
  match xsxs: list<$635>
    Nilstd/core/types/Nil: forall<a> list<a> -> Truestd/core/types/True: bool
    _   -> Falsestd/core/types/False: bool


// ----------------------------------------------------------------------------
// List functions
// ----------------------------------------------------------------------------

// Returns a singleton list.
pub fip(1) fun singlestd/core/list/single: forall<a> (x : a) -> list<a>(xx: _656)result: -> total list<670>
  [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>xx: _656]std/core/types/Nil: forall<a> list<a>

// Returns the length of a list.
pub fun lengthstd/core/list/length: forall<a> (xs : list<a>) -> int(xsxs: list<_711>)result: -> total int
  fun lenlen: forall<a> (ys : list<a>, acc : int) -> int(ysys: list<_685>,accacc: int)result: -> total int
    match ysys: list<_685>
      Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,yyyy: list<_685>) -> yyyy: list<_685>.lenlen: (ys : list<_685>, acc : int) -> int(accacc: int+std/core/int/(+): (x : int, y : int) -> int1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
) Nilstd/core/types/Nil: forall<a> list<a> -> accacc: int
xsxs: list<_711>.lenlen: (ys : list<_711>, acc : int) -> int(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) // Returns an integer list of increasing elements from `lo` to `hi` // (including both `lo` and `hi` ). // If `lo > hi` the function returns the empty list. pub fun range/liststd/core/list/range/list: (lo : int, hi : int) -> list<int>( lolo: int: intstd/core/types/int: V, hihi: int: intstd/core/types/int: V )result: -> total list<int> : totalstd/core/types/total: E liststd/core/types/list: V -> V<intstd/core/types/int: V> if lolo: int <=std/core/int/(<=): (x : int, y : int) -> bool hihi: int then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( lolo: int, liststd/core/list/range/list: (lo : int, hi : int) -> list<int>( pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> int(lolo: int.incstd/core/int/inc: (i : int) -> int), hihi: int ) ) else Nilstd/core/types/Nil: forall<a> list<a> // Returns an integer list of increasing elements from `lo` to `hi` with stride `stride`. // If `lo > hi` the function returns the empty list. pub fun stride/liststd/core/list/stride/list: (lo : int, hi : int, stride : int) -> list<int>( lolo: int: intstd/core/types/int: V, hihi: int: intstd/core/types/int: V, stridestride: int : intstd/core/types/int: V )result: -> total list<int> : totalstd/core/types/total: E liststd/core/types/list: V -> V<intstd/core/types/int: V> if lolo: int <=std/core/int/(<=): (x : int, y : int) -> bool hihi: int then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( lolo: int, liststd/core/list/stride/list: (lo : int, hi : int, stride : int) -> list<int>( pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> int(lolo: int +std/core/int/(+): (x : int, y : int) -> int stridestride: int), hihi: int, stridestride: int )) else Nilstd/core/types/Nil: forall<a> list<a> // Applies a function `f` to list of increasing elements from `lo` to `hi` // (including both `lo` and `hi` ). // If `lo > hi` the function returns the empty list. pub fun function/liststd/core/list/function/list: forall<a,e> (lo : int, hi : int, f : (int) -> e a) -> e list<a>( lolo: int: intstd/core/types/int: V, hihi: int: intstd/core/types/int: V, ff: (int) -> $1868 $1867 : intstd/core/types/int: V -> ee: E aa: V )result: -> 1928 list<1927> : ee: E liststd/core/types/list: V -> V<aa: V> if lolo: int <=std/core/int/(<=): (x : int, y : int) -> $1868 bool hihi: int then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( ff: (int) -> $1868 $1867(lolo: int), liststd/core/list/function/list: (lo : int, hi : int, f : (int) -> $1868 $1867) -> $1868 list<$1867>( pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> $1868 int(lolo: int.incstd/core/int/inc: (i : int) -> $1868 int), hihi: int, ff: (int) -> $1868 $1867 )) else Nilstd/core/types/Nil: forall<a> list<a> // Returns an integer list of increasing elements from `lo` to `hi` with stride `stride`. // If `lo > hi` the function returns the empty list. pub fun stridefunction/liststd/core/list/stridefunction/list: forall<a,e> (lo : int, hi : int, stride : int, f : (int) -> e a) -> e list<a>( lolo: int: intstd/core/types/int: V, hihi: int: intstd/core/types/int: V, stridestride: int : intstd/core/types/int: V, ff: (int) -> $2046 $2045 : intstd/core/types/int: V -> ee: E aa: V )result: -> 2108 list<2107> : ee: E liststd/core/types/list: V -> V<aa: V> if lolo: int <=std/core/int/(<=): (x : int, y : int) -> $2046 bool hihi: int then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( ff: (int) -> $2046 $2045(lolo: int), liststd/core/list/stridefunction/list: (lo : int, hi : int, stride : int, f : (int) -> $2046 $2045) -> $2046 list<$2045>( pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> $2046 int(lolo: int +std/core/int/(+): (x : int, y : int) -> $2046 int stridestride: int), hihi: int, stridestride: int, ff: (int) -> $2046 $2045 )) else Nilstd/core/types/Nil: forall<a> list<a> // Create a list of characters from `lo` to `hi` (including `hi`). pub fun char/liststd/core/list/char/list: (lo : char, hi : char) -> list<char>( lolo: char : charstd/core/types/char: V, hihi: char : charstd/core/types/char: V )result: -> total list<char> : totalstd/core/types/total: E liststd/core/types/list: V -> V<charstd/core/types/char: V> liststd/core/list/range/list: (lo : int, hi : int) -> list<int>(lolo: char.intstd/core/char/int: (char) -> int, hihi: char.intstd/core/char/int: (char) -> int).mapstd/core/list/map: (xs : list<int>, f : (int) -> char) -> list<char>( charstd/core/char/int/char: (i : int) -> char ) // Element-wise list equality pub fun (==)std/core/list/(==): forall<a,e> (xs : list<a>, ys : list<a>, @implicit/(==) : (a, a) -> e bool) -> e bool( xsxs: list<$722> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$722> : liststd/core/types/list: V -> V<aa: V>, (@implicit/==)?(==): ($722, $722) -> $723 bool : (aa: V,aa: V) -> ee: E boolstd/core/types/bool: V )result: -> 803 bool : ee: E boolstd/core/types/bool: V match xsxs: list<$722> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $722,xxxx: list<$722>) -> match ysys: list<$722> Nilstd/core/types/Nil: forall<a> list<a> -> Falsestd/core/types/False: bool Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $722,yyyy: list<$722>) -> (xx: $722==?(==): ($722, $722) -> $723 boolyy: $722) &&std/core/types/(&&): (x : bool, y : bool) -> $723 bool (xxxx: list<$722>==std/core/list/(==): (xs : list<$722>, ys : list<$722>, @implicit/(==) : ($722, $722) -> $723 bool) -> $723 bool
?(==)=?(==)
yyyy: list<$722>) Nilstd/core/types/Nil: forall<a> list<a> -> match ysys: list<$722> Nilstd/core/types/Nil: forall<a> list<a> -> Truestd/core/types/True: bool Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a> -> Falsestd/core/types/False: bool
// Order on lists pub fun cmpstd/core/list/cmp: forall<a,e> (xs : list<a>, ys : list<a>, @implicit/cmp : (a, a) -> e order) -> e order( xsxs: list<$823> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$823> : liststd/core/types/list: V -> V<aa: V>, @implicit/cmp?cmp: ($823, $823) -> $824 order : (aa: V,aa: V) -> ee: E orderstd/core/types/order: V )result: -> 899 order : ee: E orderstd/core/types/order: V match xsxs: list<$823> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $823,xxxx: list<$823>) -> match ysys: list<$823> Nilstd/core/types/Nil: forall<a> list<a> -> Gtstd/core/types/Gt: order Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $823,yyyy: list<$823>) -> match cmp?cmp: ($823, $823) -> $824 order(xx: $823,yy: $823) Eqstd/core/types/Eq: order -> cmpstd/core/list/cmp: (xs : list<$823>, ys : list<$823>, @implicit/cmp : ($823, $823) -> $824 order) -> $824 order
?cmp=?cmp
(xxxx: list<$823>,yyyy: list<$823>) lglg: order -> lglg: order Nilstd/core/types/Nil: forall<a> list<a> -> match ysys: list<$823> Nilstd/core/types/Nil: forall<a> list<a> -> Eqstd/core/types/Eq: order Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a> -> Ltstd/core/types/Lt: order
// Show a list pub fun showstd/core/list/show: forall<a,e> (xs : list<a>, @implicit/show : (a) -> e string) -> e string( xsxs: list<$3458> : liststd/core/types/list: V -> V<aa: V>, @implicit/show?show: ($3458) -> $3459 string : aa: V -> ee: E stringstd/core/types/string: V )result: -> 3528 string : ee: E stringstd/core/types/string: V "["literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> $3459 string xsxs: list<$3458>.mapstd/core/list/map: (xs : list<$3458>, f : ($3458) -> $3459 string) -> $3459 list<string>(show?show: ($3458) -> $3459 string).joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> $3459 string(","literal: string
count= 1
) ++std/core/types/(++): (x : string, y : string) -> $3459 string "]"literal: string
count= 1
// _deprecated_, use `list/show` instead. pub fun show-liststd/core/list/show-list: forall<a,e> (xs : list<a>, show-elem : (a) -> e string) -> e string( xsxs: list<$3545> : liststd/core/types/list: V -> V<aa: V>, show-elemshow-elem: ($3545) -> $3546 string : (aa: V) -> ee: E stringstd/core/types/string: V )result: -> 3568 string : ee: E stringstd/core/types/string: V showstd/core/list/show: (xs : list<$3545>, @implicit/show : ($3545) -> $3546 string) -> $3546 string(xsxs: list<$3545>,@implicit/show=show-elemshow-elem: ($3545) -> $3546 string) // Zip two lists together by pairing the corresponding elements. // The returned list is only as long as the smallest input list. pub fbip fun zipstd/core/list/zip: forall<a,b> (xs : list<a>, ys : list<b>) -> list<(a, b)>( xsxs: list<$3575> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$3576> : liststd/core/types/list: V -> V<bb: V> )result: -> total list<(3644, 3645)> : liststd/core/types/list: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,bb: V)> match xsxs: list<$3575> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3575,xxxx: list<$3575>) -> match ysys: list<$3576> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3576,yyyy: list<$3576>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xx: $3575,yy: $3576)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b),zipstd/core/list/zip: (xs : list<$3575>, ys : list<$3576>) -> list<($3575, $3576)>(xxxx: list<$3575>,yyyy: list<$3576>)) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Zip two lists together by apply a function `f` to all corresponding elements. // The returned list is only as long as the smallest input list. pub fbip fun zipwithstd/core/list/zipwith: forall<a,b,c,e> (xs : list<a>, ys : list<b>, f : (a, b) -> e c) -> e list<c>( xsxs: list<$3653> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$3654> :liststd/core/types/list: V -> V<bb: V>, ^ff: ($3653, $3654) -> $3656 $3655 : (aa: V,bb: V) -> ee: E cc: V )result: -> 3728 list<3727> : ee: E liststd/core/types/list: V -> V<cc: V> match xsxs: list<$3653> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3653,xxxx: list<$3653>) -> match ysys: list<$3654> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3654,yyyy: list<$3654>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: ($3653, $3654) -> $3656 $3655(xx: $3653,yy: $3654),zipwithstd/core/list/zipwith: (xs : list<$3653>, ys : list<$3654>, f : ($3653, $3654) -> $3656 $3655) -> $3656 list<$3655>(xxxx: list<$3653>,yyyy: list<$3654>,ff: ($3653, $3654) -> $3656 $3655)) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> _ -> Nilstd/core/types/Nil: forall<a> list<a> // Zip two lists together by apply a function `f` to all corresponding elements // and their index in the list. // The returned list is only as long as the smallest input list. pub fbip fun zipwith-indexedstd/core/list/zipwith-indexed: forall<a,b,c,e> (xs0 : list<a>, ys0 : list<b>, f : (int, a, b) -> e c) -> e list<c>( xs0xs0: list<$3815> : liststd/core/types/list: V -> V<aa: V>, ys0ys0: list<$3816> :liststd/core/types/list: V -> V<bb: V>, ^ff: (int, $3815, $3816) -> $3818 $3817 : (intstd/core/types/int: V,aa: V,bb: V) -> ee: E cc: V )result: -> 3857 list<3856> : ee: E liststd/core/types/list: V -> V<cc: V> zipwith-iterstd/core/list/zipwith-iter: (i : int, xs : list<$3815>, ys : list<$3816>, f : (int, $3815, $3816) -> $3818 $3817) -> $3818 list<$3817>(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
,xs0xs0: list<$3815>,ys0ys0: list<$3816>,ff: (int, $3815, $3816) -> $3818 $3817
) fbip fun zipwith-iterstd/core/list/zipwith-iter: forall<a,b,c,e> (i : int, xs : list<a>, ys : list<b>, f : (int, a, b) -> e c) -> e list<c>( ii: int, xsxs: list<_3749>, ysys: list<_3754>, ^ff: (int, _3749, _3754) -> _3745 _3760 )result: -> _3745 list<_3760> match xsxs: list<_3749> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _3749,xxxx: list<_3749>) -> match ysys: list<_3754> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _3754,yyyy: list<_3754>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (int, _3749, _3754) -> _3745 _3760(ii: int,xx: _3749,yy: _3754),zipwith-iterstd/core/list/zipwith-iter: (i : int, xs : list<_3749>, ys : list<_3754>, f : (int, _3749, _3754) -> _3745 _3760) -> _3745 list<_3760>(ii: int+std/core/int/(+): (x : int, y : int) -> _3745 int1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
,xxxx: list<_3749>,yyyy: list<_3754>,ff: (int, _3749, _3754) -> _3745 _3760)) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a>
// Unzip a list of pairs into two lists pub fun unzipstd/core/list/unzip: forall<a,b> (xs : list<(a, b)>) -> (list<a>, list<b>)( xsxs: list<($3870, $3871)> : liststd/core/types/list: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,bb: V)> )result: -> total (list<4073>, list<4074>) : (std/core/types/tuple2: (V, V) -> Vliststd/core/types/list: V -> V<aa: V>,liststd/core/types/list: V -> V<bb: V>) fun iteriter: forall<a,b,c,d> (ys : list<(a, b)>, acc1 : cctx<c,list<a>>, acc2 : cctx<d,list<b>>) -> (c, d)( ysys: list<(_3883, _3884)>, acc1acc1: cctx<_3928,list<_3883>>, acc2acc2: cctx<_3971,list<_3884>> )result: -> total (_3928, _3971) match ysys: list<(_3883, _3884)> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>((std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xx: _3883,yy: _3884)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b),xxxx: list<(_3883, _3884)>) -> iteriter: (ys : list<(_3883, _3884)>, acc1 : cctx<_3928,list<_3883>>, acc2 : cctx<_3971,list<_3884>>) -> (_3928, _3971)(xxxx: list<(_3883, _3884)>,acc1acc1: cctx<_3928,list<_3883>> ++std/core/types/cctx/(++): (c1 : cctx<_3928,list<_3883>>, c2 : cctx<list<_3883>,list<_3883>>) -> cctx<_3928,list<_3883>> ctxctx: cctx<list<_3883>,list<_3883>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _3883,holehole: list<_3883>),acc2acc2: cctx<_3971,list<_3884>> ++std/core/types/cctx/(++): (c1 : cctx<_3971,list<_3884>>, c2 : cctx<list<_3884>,list<_3884>>) -> cctx<_3971,list<_3884>> ctxctx: cctx<list<_3884>,list<_3884>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _3884,holehole: list<_3884>)) Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)acc1acc1: cctx<_3928,list<_3883>> ++.std/core/types/cctx/(++.): (c : cctx<_3928,list<_3883>>, x : list<_3883>) -> _3928 Nilstd/core/types/Nil: forall<a> list<a>,acc2acc2: cctx<_3971,list<_3884>> ++.std/core/types/cctx/(++.): (c : cctx<_3971,list<_3884>>, x : list<_3884>) -> _3971 Nilstd/core/types/Nil: forall<a> list<a>)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) iteriter: (ys : list<($3870, $3871)>, acc1 : cctx<list<$3870>,list<$3870>>, acc2 : cctx<list<$3871>,list<$3871>>) -> (list<$3870>, list<$3871>)(xsxs: list<($3870, $3871)>,ctxctx: ctx<list<$3870>> holehole: list<$3870>,ctxctx: ctx<list<$3871>> holehole: list<$3871>) // Unzip a list of triples into three lists pub fun unzip3std/core/list/unzip3: forall<a,b,c> (xs : list<(a, b, c)>) -> (list<a>, list<b>, list<c>)( xsxs: list<($4082, $4083, $4084)> : liststd/core/types/list: V -> V<(std/core/types/tuple3: (V, V, V) -> Vaa: V,bb: V,cc: V)>)result: -> total (list<4372>, list<4373>, list<4374>) : (std/core/types/tuple3: (V, V, V) -> Vliststd/core/types/list: V -> V<aa: V>,liststd/core/types/list: V -> V<bb: V>,liststd/core/types/list: V -> V<cc: V>) fun iteriter: forall<a,b,c,d,a1,b1> (ys : list<(a, b, c)>, acc1 : cctx<d,list<a>>, acc2 : cctx<a1,list<b>>, acc3 : cctx<b1,list<c>>) -> (d, a1, b1)( ysys: list<(_4098, _4099, _4100)>, acc1acc1: cctx<_4144,list<_4098>>, acc2acc2: cctx<_4187,list<_4099>>, acc3acc3: cctx<_4230,list<_4100>> )result: -> total (_4144, _4187, _4230) match ysys: list<(_4098, _4099, _4100)> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>((std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)xx: _4098,yy: _4099,zz: _4100)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c),xxxx: list<(_4098, _4099, _4100)>) -> iteriter: (ys : list<(_4098, _4099, _4100)>, acc1 : cctx<_4144,list<_4098>>, acc2 : cctx<_4187,list<_4099>>, acc3 : cctx<_4230,list<_4100>>) -> (_4144, _4187, _4230)(xxxx: list<(_4098, _4099, _4100)>,acc1acc1: cctx<_4144,list<_4098>> ++std/core/types/cctx/(++): (c1 : cctx<_4144,list<_4098>>, c2 : cctx<list<_4098>,list<_4098>>) -> cctx<_4144,list<_4098>> ctxctx: cctx<list<_4098>,list<_4098>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _4098,holehole: list<_4098>),acc2acc2: cctx<_4187,list<_4099>> ++std/core/types/cctx/(++): (c1 : cctx<_4187,list<_4099>>, c2 : cctx<list<_4099>,list<_4099>>) -> cctx<_4187,list<_4099>> ctxctx: cctx<list<_4099>,list<_4099>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _4099,holehole: list<_4099>),acc3acc3: cctx<_4230,list<_4100>> ++std/core/types/cctx/(++): (c1 : cctx<_4230,list<_4100>>, c2 : cctx<list<_4100>,list<_4100>>) -> cctx<_4230,list<_4100>> ctxctx: cctx<list<_4100>,list<_4100>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: _4100,holehole: list<_4100>)) Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c)acc1acc1: cctx<_4144,list<_4098>> ++.std/core/types/cctx/(++.): (c : cctx<_4144,list<_4098>>, x : list<_4098>) -> _4144 Nilstd/core/types/Nil: forall<a> list<a>,acc2acc2: cctx<_4187,list<_4099>> ++.std/core/types/cctx/(++.): (c : cctx<_4187,list<_4099>>, x : list<_4099>) -> _4187 Nilstd/core/types/Nil: forall<a> list<a>,acc3acc3: cctx<_4230,list<_4100>> ++.std/core/types/cctx/(++.): (c : cctx<_4230,list<_4100>>, x : list<_4100>) -> _4230 Nilstd/core/types/Nil: forall<a> list<a>)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c) iteriter: (ys : list<($4082, $4083, $4084)>, acc1 : cctx<list<$4082>,list<$4082>>, acc2 : cctx<list<$4083>,list<$4083>>, acc3 : cctx<list<$4084>,list<$4084>>) -> (list<$4082>, list<$4083>, list<$4084>)(xsxs: list<($4082, $4083, $4084)>,ctxctx: ctx<list<$4082>> holehole: list<$4082>,ctxctx: ctx<list<$4083>> holehole: list<$4083>,ctxctx: ctx<list<$4084>> holehole: list<$4084>) // Unzip a list of quadruples into four lists pub fun unzip4std/core/list/unzip4: forall<a,b,c,d> (xs : list<(a, b, c, d)>) -> (list<a>, list<b>, list<c>, list<d>)( xsxs: list<($4385, $4386, $4387, $4388)> : liststd/core/types/list: V -> V<(std/core/types/tuple4: (V, V, V, V) -> Vaa: V,bb: V,cc: V,dd: V)>)result: -> total (list<4762>, list<4763>, list<4764>, list<4765>) : (std/core/types/tuple4: (V, V, V, V) -> Vliststd/core/types/list: V -> V<aa: V>,liststd/core/types/list: V -> V<bb: V>,liststd/core/types/list: V -> V<cc: V>,liststd/core/types/list: V -> V<dd: V>) fun iteriter: forall<a,b,c,d,a1,b1,c1,d1> (ys : list<(a, b, c, d)>, acc1 : cctx<a1,list<a>>, acc2 : cctx<b1,list<b>>, acc3 : cctx<c1,list<c>>, acc4 : cctx<d1,list<d>>) -> (a1, b1, c1, d1)( ysys: list<(_4404, _4405, _4406, _4407)>, acc1acc1: cctx<_4451,list<_4404>>, acc2acc2: cctx<_4494,list<_4405>>, acc3acc3: cctx<_4537,list<_4406>>, acc4acc4: cctx<_4580,list<_4407>> )result: -> total (_4451, _4494, _4537, _4580) match ysys: list<(_4404, _4405, _4406, _4407)> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>((std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)xx: _4404,yy: _4405,zz: _4406,ww: _4407)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d),xxxx: list<(_4404, _4405, _4406, _4407)>) -> iteriter: (ys : list<(_4404, _4405, _4406, _4407)>, acc1 : cctx<_4451,list<_4404>>, acc2 : cctx<_4494,list<_4405>>, acc3 : cctx<_4537,list<_4406>>, acc4 : cctx<_4580,list<_4407>>) -> (_4451, _4494, _4537, _4580)(xxxx: list<(_4404, _4405, _4406, _4407)>,acc1acc1: cctx<_4451,list<_4404>> ++std/core/types/cctx/(++): (c1 : cctx<_4451,list<_4404>>, c2 : cctx<list<_4404>,list<_4404>>) -> cctx<_4451,list<_4404>> ctxctx: cctx<list<_4404>,list<_4404>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _4404,holehole: list<_4404>),acc2acc2: cctx<_4494,list<_4405>> ++std/core/types/cctx/(++): (c1 : cctx<_4494,list<_4405>>, c2 : cctx<list<_4405>,list<_4405>>) -> cctx<_4494,list<_4405>> ctxctx: cctx<list<_4405>,list<_4405>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _4405,holehole: list<_4405>),acc3acc3: cctx<_4537,list<_4406>> ++std/core/types/cctx/(++): (c1 : cctx<_4537,list<_4406>>, c2 : cctx<list<_4406>,list<_4406>>) -> cctx<_4537,list<_4406>> ctxctx: cctx<list<_4406>,list<_4406>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: _4406,holehole: list<_4406>),acc4acc4: cctx<_4580,list<_4407>> ++std/core/types/cctx/(++): (c1 : cctx<_4580,list<_4407>>, c2 : cctx<list<_4407>,list<_4407>>) -> cctx<_4580,list<_4407>> ctxctx: cctx<list<_4407>,list<_4407>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ww: _4407,holehole: list<_4407>)) Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d)acc1acc1: cctx<_4451,list<_4404>> ++.std/core/types/cctx/(++.): (c : cctx<_4451,list<_4404>>, x : list<_4404>) -> _4451 Nilstd/core/types/Nil: forall<a> list<a>,acc2acc2: cctx<_4494,list<_4405>> ++.std/core/types/cctx/(++.): (c : cctx<_4494,list<_4405>>, x : list<_4405>) -> _4494 Nilstd/core/types/Nil: forall<a> list<a>,acc3acc3: cctx<_4537,list<_4406>> ++.std/core/types/cctx/(++.): (c : cctx<_4537,list<_4406>>, x : list<_4406>) -> _4537 Nilstd/core/types/Nil: forall<a> list<a>,acc4acc4: cctx<_4580,list<_4407>> ++.std/core/types/cctx/(++.): (c : cctx<_4580,list<_4407>>, x : list<_4407>) -> _4580 Nilstd/core/types/Nil: forall<a> list<a>)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d) iteriter: (ys : list<($4385, $4386, $4387, $4388)>, acc1 : cctx<list<$4385>,list<$4385>>, acc2 : cctx<list<$4386>,list<$4386>>, acc3 : cctx<list<$4387>,list<$4387>>, acc4 : cctx<list<$4388>,list<$4388>>) -> (list<$4385>, list<$4386>, list<$4387>, list<$4388>)(xsxs: list<($4385, $4386, $4387, $4388)>,ctxctx: ctx<list<$4385>> holehole: list<$4385>,ctxctx: ctx<list<$4386>> holehole: list<$4386>,ctxctx: ctx<list<$4387>> holehole: list<$4387>,ctxctx: ctx<list<$4388>> holehole: list<$4388>) // Take the first `n` elements of a list (or fewer if the list is shorter than `n`) pub fun takestd/core/list/take: forall<a> (xs : list<a>, n : int) -> list<a>( xsxs: list<$915> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total list<960> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$915> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $915,xxxx: list<$915>) | nn: int >std/core/int/(>): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
-> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $915, takestd/core/list/take: (xs : list<$915>, n : int) -> list<$915>(xxxx: list<$915>, nn: int -std/core/int/(-): (x : int, y : int) -> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
)) _ -> Nilstd/core/types/Nil: forall<a> list<a>
// Drop the first `n` elements of a list (or fewer if the list is shorter than `n`) pub fun dropstd/core/list/drop: forall<a> (xs : list<a>, n : int) -> list<a>( xsxs: list<$965> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total list<1000> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$965> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,xxxx: list<$965>) | nn: int >std/core/int/(>): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
-> dropstd/core/list/drop: (xs : list<$965>, n : int) -> list<$965>(xxxx: list<$965>, nn: int -std/core/int/(-): (x : int, y : int) -> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
) _ -> xsxs: list<$965>
// Apply a function `f` to each element of the input list in sequence. pub fip fun mapstd/core/list/map: forall<a,b,e> (xs : list<a>, f : (a) -> e b) -> e list<b>(xsxs: list<$2161> : liststd/core/types/list: V -> V<aa: V>, ^ff: ($2161) -> $2163 $2162 : aa: V -> ee: E bb: V)result: -> 2219 list<2218> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$2161> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2161,xxxx: list<$2161>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: ($2161) -> $2163 $2162(xx: $2161), xxxx: list<$2161>.mapstd/core/list/map: (xs : list<$2161>, f : ($2161) -> $2163 $2162) -> $2163 list<$2162>(ff: ($2161) -> $2163 $2162)) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Apply a function `f` to each element of the input list in sequence where takes // both the index of the current element and the element itself as arguments. pub fun map-indexedstd/core/list/map-indexed: forall<a,b,e> (xs : list<a>, f : (idx : int, value : a) -> e b) -> e list<b>(xsxs: list<$2257> : liststd/core/types/list: V -> V<aa: V>, ff: (idx : int, value : $2257) -> $2259 $2258 : (idx : intstd/core/types/int: V, value : aa: V) -> ee: E bb: V)result: -> 2317 list<2316> : ee: E liststd/core/types/list: V -> V<bb: V> fun map-idxmap-idx: (ys : list<$2257>, i : int) -> $2259 list<$2258>(ysys: list<$2257>,ii: int)result: -> $2259 list<$2258> match ysys: list<$2257> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2257,yyyy: list<$2257>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (idx : int, value : $2257) -> $2259 $2258(ii: int,yy: $2257), map-idxmap-idx: (ys : list<$2257>, i : int) -> $2259 list<$2258>(yyyy: list<$2257>,ii: int+std/core/int/(+): (x : int, y : int) -> $2259 int1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
)) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a>
map-idxmap-idx: (ys : list<$2257>, i : int) -> $2259 list<$2258>(xsxs: list<$2257>,0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) // Apply a function `f` to each element of the input list in sequence where `f` takes // both the current element and the tail list as arguments. pub fun map-peekstd/core/list/map-peek: forall<a,b,e> (xs : list<a>, f : (value : a, rest : list<a>) -> e b) -> e list<b>(xsxs: list<$2327> : liststd/core/types/list: V -> V<aa: V>, ff: (value : $2327, rest : list<$2327>) -> $2329 $2328 : (value : aa: V, rest : liststd/core/types/list: V -> V<aa: V>) -> ee: E bb: V)result: -> 2379 list<2378> : ee: E liststd/core/types/list: V -> V<bb: V> fun mappeekmappeek: (ys : list<$2327>) -> $2329 list<$2328>(ysys: list<$2327>)result: -> $2329 list<$2328> match ysys: list<$2327> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2327,yyyy: list<$2327>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (value : $2327, rest : list<$2327>) -> $2329 $2328(yy: $2327,yyyy: list<$2327>), yyyy: list<$2327>.mappeekmappeek: (ys : list<$2327>) -> $2329 list<$2328>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> mappeekmappeek: (ys : list<$2327>) -> $2329 list<$2328>(xsxs: list<$2327>) // Apply a function `f` to each element of the input list in sequence where takes // both the index of the current element, the element itself, and the tail list as arguments. pub fun map-indexed-peekstd/core/list/map-indexed-peek: forall<a,b,e> (xs : list<a>, f : (idx : int, value : a, rest : list<a>) -> e b) -> e list<b>(xsxs: list<$2389> : liststd/core/types/list: V -> V<aa: V>, ff: (idx : int, value : $2389, rest : list<$2389>) -> $2391 $2390 : (idx : intstd/core/types/int: V, value : aa: V, rest : liststd/core/types/list: V -> V<aa: V> ) -> ee: E bb: V)result: -> 2450 list<2449> : ee: E liststd/core/types/list: V -> V<bb: V> fun mapidxmapidx: (ys : list<$2389>, i : int) -> $2391 list<$2390>(ysys: list<$2389>,ii: int)result: -> $2391 list<$2390> match ysys: list<$2389> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2389,yyyy: list<$2389>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (idx : int, value : $2389, rest : list<$2389>) -> $2391 $2390(ii: int,yy: $2389,yyyy: list<$2389>), mapidxmapidx: (ys : list<$2389>, i : int) -> $2391 list<$2390>(yyyy: list<$2389>,ii: int+std/core/int/(+): (x : int, y : int) -> $2391 int1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
)) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a>
mapidxmapidx: (ys : list<$2389>, i : int) -> $2391 list<$2390>(xsxs: list<$2389>,0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) // Reverse a list. pub fip fun reversestd/core/list/reverse: forall<a> (xs : list<a>) -> list<a>(xsxs: list<$1063> : liststd/core/types/list: V -> V<aa: V>)result: -> total list<1081> : liststd/core/types/list: V -> V<aa: V> reverse-appendstd/core/list/reverse-append: (xs : list<$1063>, tl : list<$1063>) -> list<$1063>( xsxs: list<$1063>, Nilstd/core/types/Nil: forall<a> list<a> ) // Efficiently reverse a list `xs` and append it to `tl`: // `reverse-append(xs,tl) == reverse(xs) ++ tl pub fip fun reverse-appendstd/core/list/reverse-append: forall<a> (xs : list<a>, tl : list<a>) -> list<a>( xsxs: list<$1042> : liststd/core/types/list: V -> V<aa: V>, tltl: list<$1042> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1058> : liststd/core/types/list: V -> V<aa: V> reverse-accstd/core/list/reverse-acc: (acc : list<$1042>, ys : list<$1042>) -> list<$1042>(tltl: list<$1042>,xsxs: list<$1042>) fip fun reverse-accstd/core/list/reverse-acc: forall<a> (acc : list<a>, ys : list<a>) -> list<a>(accacc: list<$1005> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$1005> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1037> : liststd/core/types/list: V -> V<aa: V> match ysys: list<$1005> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1005,xxxx: list<$1005>) -> reverse-accstd/core/list/reverse-acc: (acc : list<$1005>, ys : list<$1005>) -> list<$1005>(Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1005,accacc: list<$1005>),xxxx: list<$1005>) _ -> accacc: list<$1005> // Append two lists. pub fip fun (++)std/core/list/(++): forall<a> (xs : list<a>, ys : list<a>) -> list<a>(xsxs: list<$1126> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$1126> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1142> : liststd/core/types/list: V -> V<aa: V> appendstd/core/list/append: (xs : list<$1126>, ys : list<$1126>) -> list<$1126>(xsxs: list<$1126>,ysys: list<$1126>) // Append two lists. pub fip fun appendstd/core/list/append: forall<a> (xs : list<a>, ys : list<a>) -> list<a>(xsxs: list<$1086> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$1086> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1121> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$1086> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1086,xxxx: list<$1086>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1086,appendstd/core/list/append: (xs : list<$1086>, ys : list<$1086>) -> list<$1086>(xxxx: list<$1086>,ysys: list<$1086>)) Nilstd/core/types/Nil: forall<a> list<a> -> ysys: list<$1086> // Fold a list from the right, i.e. `foldr([1,2],0,(+)) == 1+(2+0)` // Note, `foldr` is less efficient than `foldl` as it reverses the list first. pub fun foldrstd/core/list/foldr: forall<a,b,e> (xs : list<a>, z : b, f : (a, b) -> e b) -> e b(xsxs: list<$1203> : liststd/core/types/list: V -> V<aa: V>, zz: $1204 : bb: V, ff: ($1203, $1204) -> $1205 $1204 : (aa: V, bb: V) -> ee: E bb: V)result: -> 1246 1245 : ee: E bb: V xsxs: list<$1203>.reversestd/core/list/reverse: (xs : list<$1203>) -> $1205 list<$1203>.foldlstd/core/list/foldl: (xs : list<$1203>, z : $1204, f : ($1204, $1203) -> $1205 $1204) -> $1205 $1204(zz: $1204) fnfn: (x : $1204, y : $1203) -> $1205 $1204(xx: $1204,yy: $1203) ff: ($1203, $1204) -> $1205 $1204(yy: $1203,xx: $1204) // Fold a list from the left, i.e. `foldl([1,2],0,(+)) == (0+1)+2` // Since `foldl` is tail recursive, it is preferred over `foldr` when using an associative function `f` pub fun foldlstd/core/list/foldl: forall<a,b,e> (xs : list<a>, z : b, f : (b, a) -> e b) -> e b(xsxs: list<$1147> : liststd/core/types/list: V -> V<aa: V>, zz: $1148 : bb: V, ff: ($1148, $1147) -> $1149 $1148 : (bb: V, aa: V) -> ee: E bb: V)result: -> 1193 1192 : ee: E bb: V match xsxs: list<$1147> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1147,xxxx: list<$1147>) -> foldlstd/core/list/foldl: (xs : list<$1147>, z : $1148, f : ($1148, $1147) -> $1149 $1148) -> $1149 $1148(xxxx: list<$1147>,ff: ($1148, $1147) -> $1149 $1148(zz: $1148,xx: $1147),ff: ($1148, $1147) -> $1149 $1148) Nilstd/core/types/Nil: forall<a> list<a> -> zz: $1148 pub fun foldl1std/core/list/foldl1: forall<a,e> (xs : list<a>, f : (a, a) -> <exn|e> a) -> <exn|e> a(xsxs: list<$1256> : liststd/core/types/list: V -> V<aa: V>, ff: ($1256, $1256) -> <exn|$1257> $1256 : (aa: V,aa: V) -> <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V)result: -> <exn|1303> 1302 : <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V match xsxs: list<$1256> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1256,xxxx: list<$1256>) -> xxxx: list<$1256>.foldlstd/core/list/foldl: (xs : list<$1256>, z : $1256, f : ($1256, $1256) -> <exn|$1257> $1256) -> <exn|$1257> $1256(xx: $1256,ff: ($1256, $1256) -> <exn|$1257> $1256) Nilstd/core/types/Nil: forall<a> list<a> -> throwstd/core/exn/throw: (message : string, info : ? exception-info) -> <exn|$1257> $1256("unexpected Nil in std/core/foldl1"literal: string
count= 33
) pub fun foldr1std/core/list/foldr1: forall<a,e> (xs : list<a>, f : (a, a) -> <exn|e> a) -> <exn|e> a(xsxs: list<$1310> : liststd/core/types/list: V -> V<aa: V>, ff: ($1310, $1310) -> <exn|$1311> $1310 : (aa: V,aa: V) -> <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V)result: -> <exn|1339> 1338 : <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V xsxs: list<$1310>.reversestd/core/list/reverse: (xs : list<$1310>) -> <exn|$1311> list<$1310>.foldl1std/core/list/foldl1: (xs : list<$1310>, f : ($1310, $1310) -> <exn|$1311> $1310) -> <exn|$1311> $1310(ff: ($1310, $1310) -> <exn|$1311> $1310) // Create a list of `n` repeated elements `x` pub fun replicatestd/core/list/replicate: forall<a> (x : a, n : int) -> list<a>( xx: $2460 : aa: V, nn: int : intstd/core/types/int: V )result: -> total list<2508> : liststd/core/types/list: V -> V<aa: V> if nn: int >std/core/int/(>): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2460, replicatestd/core/list/replicate: (x : $2460, n : int) -> list<$2460>(xx: $2460,pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> int(nn: int.decstd/core/int/dec: (i : int) -> int))) else Nilstd/core/types/Nil: forall<a> list<a>
// split a list at position `n` pub fun splitstd/core/list/split: forall<a> (xs : list<a>, n : int) -> (list<a>, list<a>)( xsxs: list<$1346> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total (list<1381>, list<1381>) : (std/core/types/tuple2: (V, V) -> Vliststd/core/types/list: V -> V<aa: V>, liststd/core/types/list: V -> V<aa: V>) (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)xsxs: list<$1346>.takestd/core/list/take: (xs : list<$1346>, n : int) -> list<$1346>(nn: int), xsxs: list<$1346>.dropstd/core/list/drop: (xs : list<$1346>, n : int) -> list<$1346>(nn: int))std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) pub fun spanstd/core/list/span: forall<a,e> (xs : list<a>, predicate : (a) -> e bool) -> e (list<a>, list<a>)( xsxs: list<$4779> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($4779) -> $4780 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 4922 (list<4921>, list<4921>) : ee: E (std/core/types/tuple2: (V, V) -> Vliststd/core/types/list: V -> V<aa: V>,liststd/core/types/list: V -> V<aa: V>) fun span-accspan-acc: forall<a> (ys : list<$4779>, acc : cctx<a,list<$4779>>) -> $4780 (a, list<$4779>)( ysys: list<$4779>, accacc: cctx<_4835,list<$4779>> )result: -> $4780 (_4835, list<$4779>) match ysys: list<$4779> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4779,yyyy: list<$4779>) -> if yy: $4779.predicatepredicate: ($4779) -> $4780 bool then yyyy: list<$4779>.span-accspan-acc: (ys : list<$4779>, acc : cctx<_4835,list<$4779>>) -> $4780 (_4835, list<$4779>)(accacc: cctx<_4835,list<$4779>> ++std/core/types/cctx/(++): (c1 : cctx<_4835,list<$4779>>, c2 : cctx<list<$4779>,list<$4779>>) -> $4780 cctx<_4835,list<$4779>> ctxctx: cctx<list<$4779>,list<$4779>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4779, holehole: list<$4779>)) else (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)accacc: cctx<_4835,list<$4779>> ++.std/core/types/cctx/(++.): (c : cctx<_4835,list<$4779>>, x : list<$4779>) -> $4780 _4835 [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,ysys: list<$4779>)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) _ -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)accacc: cctx<_4835,list<$4779>> ++.std/core/types/cctx/(++.): (c : cctx<_4835,list<$4779>>, x : list<$4779>) -> $4780 _4835 [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>, ysys: list<$4779>)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) xsxs: list<$4779>.span-accspan-acc: (ys : list<$4779>, acc : cctx<list<$4779>,list<$4779>>) -> $4780 (list<$4779>, list<$4779>)( ctxctx: ctx<list<$4779>> holehole: list<$4779> ) // Keep only those initial elements that satisfy `predicate` pub fun take-whilestd/core/list/take-while: forall<a,e> (xs : list<a>, predicate : (a) -> e bool) -> e list<a>( xsxs: list<$4929> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($4929) -> $4930 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 4981 list<4980> : ee: E liststd/core/types/list: V -> V<aa: V> match xsxs: list<$4929> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $4929,xxxx: list<$4929>) -> if xx: $4929.predicatepredicate: ($4929) -> $4930 bool then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $4929, xxxx: list<$4929>.take-whilestd/core/list/take-while: (xs : list<$4929>, predicate : ($4929) -> $4930 bool) -> $4930 list<$4929>(predicatepredicate: ($4929) -> $4930 bool) ) else Nilstd/core/types/Nil: forall<a> list<a> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Drop all initial elements that satisfy `predicate` pub fun drop-whilestd/core/list/drop-while: forall<a,e> (xs : list<a>, predicate : (a) -> e bool) -> e list<a>( xsxs: list<$1386> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($1386) -> $1387 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 1428 list<1427> : ee: E liststd/core/types/list: V -> V<aa: V> match xsxs: list<$1386> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1386,xxxx: list<$1386>) -> if xx: $1386.predicatepredicate: ($1386) -> $1387 bool then xxxx: list<$1386>.drop-whilestd/core/list/drop-while: (xs : list<$1386>, predicate : ($1386) -> $1387 bool) -> $1387 list<$1386>(predicatepredicate: ($1386) -> $1387 bool) else xsxs: list<$1386> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Retain only those elements of a list that satisfy the given predicate `pred`. // For example: `filter([1,2,3],odd?) == [1,3]` pub fun filterstd/core/list/filter: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e list<a>( xsxs: list<$1435> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1435) -> $1436 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 1494 list<1493> : ee: E liststd/core/types/list: V -> V<aa: V> match xsxs: list<$1435> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1435,xxxx: list<$1435>) -> if predpred: ($1435) -> $1436 bool(xx: $1435) then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1435,xxxx: list<$1435>.filterstd/core/list/filter: (xs : list<$1435>, pred : ($1435) -> $1436 bool) -> $1436 list<$1435>(predpred: ($1435) -> $1436 bool)) else xxxx: list<$1435>.filterstd/core/list/filter: (xs : list<$1435>, pred : ($1435) -> $1436 bool) -> $1436 list<$1435>(predpred: ($1435) -> $1436 bool) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Remove those elements of a list that satisfy the given predicate `pred`. // For example: `remove([1,2,3],odd?) == [2]` pub fun removestd/core/list/remove: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e list<a>( xsxs: list<$2513> : liststd/core/types/list: V -> V<aa: V>, predpred: ($2513) -> $2514 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2549 list<2548> : ee: E liststd/core/types/list: V -> V<aa: V> xsxs: list<$2513>.filterstd/core/list/filter: (xs : list<$2513>, pred : ($2513) -> $2514 bool) -> $2514 list<$2513>( fnfn: (x : $2513) -> $2514 bool(xx: $2513) !std/core/types/bool/(!): (b : bool) -> $2514 boolpredpred: ($2513) -> $2514 bool(xx: $2513) ) // Partition a list in two lists where the first list contains // those elements that satisfy the given predicate `pred`. // For example: `partition([1,2,3],odd?) == ([1,3],[2])` pub fun partitionstd/core/list/partition: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e (list<a>, list<a>)( xsxs: list<$2719> : liststd/core/types/list: V -> V<aa: V>, ^predpred: ($2719) -> $2720 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2759 (list<2758>, list<2758>) : ee: E (std/core/types/tuple2: (V, V) -> Vliststd/core/types/list: V -> V<aa: V>,liststd/core/types/list: V -> V<aa: V>) partition-accstd/core/list/partition-acc: (xs : list<$2719>, pred : ($2719) -> $2720 bool, acc1 : ctx<list<$2719>>, acc2 : ctx<list<$2719>>) -> $2720 (list<$2719>, list<$2719>)(xsxs: list<$2719>, predpred: ($2719) -> $2720 bool, ctxctx: ctx<list<$2719>> holehole: list<$2719>, ctxctx: ctx<list<$2719>> holehole: list<$2719>) fun partition-accstd/core/list/partition-acc: forall<a,e> (xs : list<a>, pred : (a) -> e bool, acc1 : ctx<list<a>>, acc2 : ctx<list<a>>) -> e (list<a>, list<a>)(xsxs: list<$2556> : liststd/core/types/list: V -> V<aa: V>, ^predpred: ($2556) -> $2557 bool : aa: V -> ee: E boolstd/core/types/bool: V, acc1acc1: ctx<list<$2556>> : ctxstd/core/types/ctx: V -> V<liststd/core/types/list: V -> V<aa: V>>, acc2acc2: ctx<list<$2556>> : ctxstd/core/types/ctx: V -> V<liststd/core/types/list: V -> V<aa: V>>)result: -> 2712 (list<2711>, list<2711>): ee: E (std/core/types/tuple2: (V, V) -> Vliststd/core/types/list: V -> V<aa: V>, liststd/core/types/list: V -> V<aa: V>) match xsxs: list<$2556> Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)acc1acc1: ctx<list<$2556>> ++.std/core/types/cctx/(++.): (c : cctx<list<$2556>,list<$2556>>, x : list<$2556>) -> $2557 list<$2556> Nilstd/core/types/Nil: forall<a> list<a>, acc2acc2: ctx<list<$2556>> ++.std/core/types/cctx/(++.): (c : cctx<list<$2556>,list<$2556>>, x : list<$2556>) -> $2557 list<$2556> Nilstd/core/types/Nil: forall<a> list<a>)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2556,xxxx: list<$2556>) -> if predpred: ($2556) -> $2557 bool(xx: $2556) then partition-accstd/core/list/partition-acc: (xs : list<$2556>, pred : ($2556) -> $2557 bool, acc1 : ctx<list<$2556>>, acc2 : ctx<list<$2556>>) -> $2557 (list<$2556>, list<$2556>)(xxxx: list<$2556>,predpred: ($2556) -> $2557 bool,acc1acc1: ctx<list<$2556>> ++std/core/types/cctx/(++): (c1 : cctx<list<$2556>,list<$2556>>, c2 : cctx<list<$2556>,list<$2556>>) -> $2557 cctx<list<$2556>,list<$2556>> ctxctx: cctx<list<$2556>,list<$2556>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2556,holehole: list<$2556>),acc2acc2: ctx<list<$2556>>) else partition-accstd/core/list/partition-acc: (xs : list<$2556>, pred : ($2556) -> $2557 bool, acc1 : ctx<list<$2556>>, acc2 : ctx<list<$2556>>) -> $2557 (list<$2556>, list<$2556>)(xxxx: list<$2556>,predpred: ($2556) -> $2557 bool,acc1acc1: ctx<list<$2556>>,acc2acc2: ctx<list<$2556>> ++std/core/types/cctx/(++): (c1 : cctx<list<$2556>,list<$2556>>, c2 : cctx<list<$2556>,list<$2556>>) -> $2557 cctx<list<$2556>,list<$2556>> ctxctx: cctx<list<$2556>,list<$2556>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2556,holehole: list<$2556>)) // Retain only those elements of a list that satisfy the given predicate `pred`. // For example: `filterMap([1,2,3],fn(i) { if i.odd? then Nothing else Just(i*i) }) == [4]` pub fun filter-mapstd/core/list/filter-map: forall<a,b,e> (xs : list<a>, pred : (a) -> e maybe<b>) -> e list<b>( xsxs: list<$1501> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1501) -> $1503 maybe<$1502> : aa: V -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 1578 list<1577> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$1501> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1501,xxxx: list<$1501>) -> match predpred: ($1501) -> $1503 maybe<$1502>(xx: $1501) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<$1501>.filter-mapstd/core/list/filter-map: (xs : list<$1501>, pred : ($1501) -> $1503 maybe<$1502>) -> $1503 list<$1502>(predpred: ($1501) -> $1503 maybe<$1502>) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $1502) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $1502,xxxx: list<$1501>.filter-mapstd/core/list/filter-map: (xs : list<$1501>, pred : ($1501) -> $1503 maybe<$1502>) -> $1503 list<$1502>(predpred: ($1501) -> $1503 maybe<$1502>)) // Find the first element satisfying some predicate pub fun findstd/core/list/find: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e maybe<a>( xsxs: list<$1668> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1668) -> $1669 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 1720 maybe<1719> : ee: E maybestd/core/types/maybe: V -> V<aa: V> xsxs: list<$1668>.foreach-whilestd/core/list/foreach-while: (xs : list<$1668>, action : ($1668) -> $1669 maybe<$1668>) -> $1669 maybe<$1668> fnfn: (x : $1668) -> $1669 maybe<$1668>(xx: $1668) if predpred: ($1668) -> $1669 bool(xx: $1668) then Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $1668) else Nothingstd/core/types/Nothing: forall<a> maybe<a> // Find the first element satisfying some predicate and return it. pub fun find-maybestd/core/list/find-maybe: forall<a,b,e> (xs : list<a>, pred : (a) -> e maybe<b>) -> e maybe<b>( xsxs: list<$1727> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1727) -> $1729 maybe<$1728> : aa: V -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 1768 maybe<1767> : ee: E maybestd/core/types/maybe: V -> V<bb: V> xsxs: list<$1727>.foreach-whilestd/core/list/foreach-while: (xs : list<$1727>, action : ($1727) -> $1729 maybe<$1728>) -> $1729 maybe<$1728>(predpred: ($1727) -> $1729 maybe<$1728>) // Lookup the first element satisfying some predicate pub fun lookupstd/core/list/lookup: forall<a,b,e> (xs : list<(a, b)>, pred : (a) -> e bool) -> e maybe<b>( xsxs: list<($2766, $2767)> : liststd/core/types/list: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,bb: V)>, predpred: ($2766) -> $2768 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2896 maybe<2895> : ee: E maybestd/core/types/maybe: V -> V<bb: V> xsxs: list<($2766, $2767)>.foreach-whilestd/core/list/foreach-while: (xs : list<($2766, $2767)>, action : (($2766, $2767)) -> $2768 maybe<$2767>) -> $2768 maybe<$2767> fnfn: (kv : ($2766, $2767)) -> $2768 maybe<$2767>(kvkv: ($2766, $2767)) if predpred: ($2766) -> $2768 bool(kvkv: ($2766, $2767).fststd/core/types/tuple2/fst: (tuple2 : ($2766, $2767)) -> $2768 $2766) then Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(kvkv: ($2766, $2767).sndstd/core/types/tuple2/snd: (tuple2 : ($2766, $2767)) -> $2768 $2767) else Nothingstd/core/types/Nothing: forall<a> maybe<a> // Convert a `:maybe` type to a list type. pub fun maybe/liststd/core/list/maybe/list: forall<a> (m : maybe<a>) -> list<a>( mm: maybe<$1778> : maybestd/core/types/maybe: V -> V<aa: V> )result: -> total list<1809> : liststd/core/types/list: V -> V<aa: V> match mm: maybe<$1778> Nothingstd/core/types/Nothing: forall<a> maybe<a> -> Nilstd/core/types/Nil: forall<a> list<a> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $1778) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1778,Nilstd/core/types/Nil: forall<a> list<a>) fun index-of-accstd/core/list/index-of-acc: forall<a,e> (xs : list<a>, pred : (a) -> e bool, idx : int) -> e int( xsxs: list<$2906> : liststd/core/types/list: V -> V<aa: V>, predpred: ($2906) -> $2907 bool : aa: V -> ee: E boolstd/core/types/bool: V, idxidx: int : intstd/core/types/int: V )result: -> 2952 int : ee: E intstd/core/types/int: V match xsxs: list<$2906> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2906,xxxx: list<$2906>) -> if predpred: ($2906) -> $2907 bool(xx: $2906) then idxidx: int else index-of-accstd/core/list/index-of-acc: (xs : list<$2906>, pred : ($2906) -> $2907 bool, idx : int) -> $2907 int(xxxx: list<$2906>,predpred: ($2906) -> $2907 bool,idxidx: int+std/core/int/(+): (x : int, y : int) -> $2907 int1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
) Nilstd/core/types/Nil: forall<a> list<a> -> -1literal: int
dec = -1
hex8 = 0xFF
bit8 = 0b11111111
// Returns the index of the first element where `pred` holds, or `-1` if no such element exists. pub fun index-ofstd/core/list/index-of: forall<a,e> (xs : list<a>, pred : (a) -> e bool) -> e int( xsxs: list<$2959> : liststd/core/types/list: V -> V<aa: V>, predpred: ($2959) -> $2960 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2982 int : ee: E intstd/core/types/int: V index-of-accstd/core/list/index-of-acc: (xs : list<$2959>, pred : ($2959) -> $2960 bool, idx : int) -> $2960 int( xsxs: list<$2959>, predpred: ($2959) -> $2960 bool, 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
) // Invoke `action` for each element of a list pub fun foreachstd/core/list/foreach: forall<a,e> (xs : list<a>, action : (a) -> e ()) -> e ()( xsxs: list<$2989> : liststd/core/types/list: V -> V<aa: V>, actionaction: ($2989) -> $2990 () : (aa: V) -> ee: E (std/core/types/unit: V)std/core/types/unit: V )result: -> 3032 () : ee: E (std/core/types/unit: V)std/core/types/unit: V match xsxs: list<$2989> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2989,xxxx: list<$2989>) -> { actionaction: ($2989) -> $2990 ()(xx: $2989); xxxx: list<$2989>.foreachstd/core/list/foreach: (xs : list<$2989>, action : ($2989) -> $2990 ()) -> $2990 ()(actionaction: ($2989) -> $2990 ()) } Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Unit: ())std/core/types/Unit: () // Invoke `action` for each element of a list while `action` return `Nothing` pub fun foreach-whilestd/core/list/foreach-while: forall<a,b,e> (xs : list<a>, action : (a) -> e maybe<b>) -> e maybe<b>( xsxs: list<$1588> : liststd/core/types/list: V -> V<aa: V>, actionaction: ($1588) -> $1590 maybe<$1589> : (aa: V) -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 1652 maybe<1651> : ee: E maybestd/core/types/maybe: V -> V<bb: V> match xsxs: list<$1588> Nilstd/core/types/Nil: forall<a> list<a> -> Nothingstd/core/types/Nothing: forall<a> maybe<a> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1588,xxxx: list<$1588>) -> match actionaction: ($1588) -> $1590 maybe<$1589>(xx: $1588) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<$1588>.foreach-whilestd/core/list/foreach-while: (xs : list<$1588>, action : ($1588) -> $1590 maybe<$1589>) -> $1590 maybe<$1589>(actionaction: ($1588) -> $1590 maybe<$1589>) justjust: maybe<$1589> -> justjust: maybe<$1589> // Invoke `action` on each element of a list while `action` returns `Just` pub fun map-whilestd/core/list/map-while: forall<a,b,e> (xs : list<a>, action : (a) -> e maybe<b>) -> e list<b>( xsxs: list<$3043> : liststd/core/types/list: V -> V<aa: V>, actionaction: ($3043) -> $3045 maybe<$3044> : (aa: V) -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 3110 list<3109> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$3043> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3043,xxxx: list<$3043>) -> match actionaction: ($3043) -> $3045 maybe<$3044>(xx: $3043) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $3044) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3044,xxxx: list<$3043>.map-whilestd/core/list/map-while: (xs : list<$3043>, action : ($3043) -> $3045 maybe<$3044>) -> $3045 list<$3044>(actionaction: ($3043) -> $3045 maybe<$3044>)) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Invoke `action` for each element of a list, passing also the position of the element. pub fun foreach-indexedstd/core/list/foreach-indexed: forall<a,e> (xs : list<a>, action : (int, a) -> e ()) -> e ()( xsxs: list<$3120> : liststd/core/types/list: V -> V<aa: V>, actionaction: (int, $3120) -> $3121 () : (intstd/core/types/int: V,aa: V) -> ee: E (std/core/types/unit: V)std/core/types/unit: V )result: -> 3248 () : ee: E (std/core/types/unit: V)std/core/types/unit: V var ii: local-var<$3131,int> := 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
xsxs: list<$3120>.foreachstd/core/list/foreach: (xs : list<$3120>, action : ($3120) -> <local<$3131>|$3121> ()) -> <local<$3131>|$3121> () fnfn: (x : $3120) -> <local<$3131>|$3121> ()(xx: $3120) val jj: int = ii: int
?hdiv=iev@3166
// don't dereference `i` inside the inject actionaction: (int, $3120) -> $3121 ()(jj: int,xx: $3120) ii: local-var<$3131,int> :=std/core/types/local-set: (v : local-var<$3131,int>, assigned : int) -> <local<$3131>|$3121> () ii: int
?hdiv=iev@3218
+std/core/int/(+): (x : int, y : int) -> <local<$3131>|$3121> int
1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
// Insert a separator `sep` between all elements of a list `xs` . pub fun interspersestd/core/list/intersperse: forall<a> (xs : list<a>, sep : a) -> list<a>( xsxs: list<$3255> : liststd/core/types/list: V -> V<aa: V>, sepsep: $3255 : aa: V )result: -> total list<3324> : liststd/core/types/list: V -> V<aa: V> fun beforebefore: (ys : list<$3255>) -> list<$3255>(ysys: list<$3255>)result: -> total list<$3255> match ysys: list<$3255> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3255,yyyy: list<$3255>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(sepsep: $3255,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3255,beforebefore: (ys : list<$3255>) -> list<$3255>(yyyy: list<$3255>))) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> match xsxs: list<$3255> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3255,xxxx: list<$3255>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3255, xxxx: list<$3255>.beforebefore: (ys : list<$3255>) -> list<$3255>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Concatenate all strings in a list fun joinsepstd/core/list/joinsep: (xs : list<string>, sep : string) -> string( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V>, sepsep: string : stringstd/core/types/string: V )result: -> total string : stringstd/core/types/string: V match xsxs: list<string> Nilstd/core/types/Nil: forall<a> list<a> -> ""literal: string
count= 0
Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: string,Nilstd/core/types/Nil: forall<a> list<a>) -> xx: string Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: string,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: string,Nilstd/core/types/Nil: forall<a> list<a>)) | sepsep: string.is-emptystd/core/string/is-empty: (s : string) -> bool -> xx: string ++std/core/types/(++): (x : string, y : string) -> string yy: string _ -> xsxs: list<string>.vectorstd/core/vector/list/vector: (xs : list<string>) -> vector<string>.joinstd/core/string/vectorsep/join: (v : vector<string>, sep : string) -> string(sepsep: string
) // Concatenate all strings in a list pub fun concat/joinstd/core/list/concat/join: (xs : list<string>) -> string( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> )result: -> total string : stringstd/core/types/string: V match xsxs: list<string> Nilstd/core/types/Nil: forall<a> list<a> -> ""literal: string
count= 0
Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: string,Nilstd/core/types/Nil: forall<a> list<a>) -> xx: string Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: string,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: string,Nilstd/core/types/Nil: forall<a> list<a>)) -> xx: string ++std/core/types/(++): (x : string, y : string) -> string yy: string _ -> xsxs: list<string>.vectorstd/core/vector/list/vector: (xs : list<string>) -> vector<string>.joinstd/core/string/vector/join: (v : vector<string>) -> string(
) // Concatenate all strings in a list using a specific separator pub fun joinsep/joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> string( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V>, sepsep: string : stringstd/core/types/string: V )result: -> total string : stringstd/core/types/string: V xsxs: list<string>.joinsepstd/core/list/joinsep: (xs : list<string>, sep : string) -> string(sepsep: string) // Concatenate all strings in a list in reverse order pub fun reverse-joinstd/core/list/reverse-join: (xs : list<string>) -> string( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> )result: -> total string : stringstd/core/types/string: V xsxs: list<string>.reversestd/core/list/reverse: (xs : list<string>) -> list<string>.joinstd/core/list/concat/join: (xs : list<string>) -> string // Append `end` to each string in the list `xs` and join them all together.\ // `join-end([],end) === ""`\ // `join-end(["a","b"],"/") === "a/b/"` pub fun join-endstd/core/list/join-end: (xs : list<string>, end : string) -> string( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V>, endend: string : stringstd/core/types/string: V)result: -> total string : stringstd/core/types/string: V match xsxs: list<string> Nilstd/core/types/Nil: forall<a> list<a> -> ""literal: string
count= 0
_ -> xsxs: list<string>.joinsepstd/core/list/joinsep: (xs : list<string>, sep : string) -> string(endend: string) ++std/core/types/(++): (x : string, y : string) -> string endend: string
// Concatenate all lists in a list (e.g. flatten the list). (tail-recursive) pub fun concatstd/core/list/concat: forall<a> (xss : list<list<a>>) -> list<a>( xssxss: list<list<$5029>> : liststd/core/types/list: V -> V<liststd/core/types/list: V -> V<aa: V>> )result: -> total list<5108> : liststd/core/types/list: V -> V<aa: V> fun concat-preconcat-pre: forall<a> (ys : list<a>, zss : list<list<a>>) -> list<a>( ysys: list<$5030> : liststd/core/types/list: V -> V<aa: V>, zsszss: list<list<$5030>> : liststd/core/types/list: V -> V<liststd/core/types/list: V -> V<aa: V>> )result: -> total list<5086> : liststd/core/types/list: V -> V<aa: V> match ysys: list<$5030> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $5030,yyyy: list<$5030>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $5030,concat-preconcat-pre: (ys : list<$5030>, zss : list<list<$5030>>) -> list<$5030>(yyyy: list<$5030>,zsszss: list<list<$5030>>)) Nilstd/core/types/Nil: forall<a> list<a> -> match zsszss: list<list<$5030>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zszs: list<$5030>,zzszzs: list<list<$5030>>) -> concat-preconcat-pre: (ys : list<$5030>, zss : list<list<$5030>>) -> list<$5030>(zszs: list<$5030>,zzszzs: list<list<$5030>>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> concat-preconcat-pre: (ys : list<$5029>, zss : list<list<$5029>>) -> list<$5029>([std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,xssxss: list<list<$5029>>) // Concatenate the result lists from applying a function to all elements. pub fun flatmapstd/core/list/flatmap: forall<a,b,e> (xs : list<a>, f : (a) -> e list<b>) -> e list<b>( xsxs: list<$5113>: liststd/core/types/list: V -> V<aa: V>, ff: ($5113) -> $5115 list<$5114> : aa: V -> ee: E liststd/core/types/list: V -> V<bb: V> )result: -> 5183 list<5182> : ee: E liststd/core/types/list: V -> V<bb: V> fun flatmap-preflatmap-pre: (ys : list<$5114>, zs : list<$5113>) -> $5115 list<$5114>( ysys: list<$5114>, zszs: list<$5113> )result: -> $5115 list<$5114> match ysys: list<$5114> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $5114,yyyy: list<$5114>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $5114,flatmap-preflatmap-pre: (ys : list<$5114>, zs : list<$5113>) -> $5115 list<$5114>(yyyy: list<$5114>,zszs: list<$5113>)) Nilstd/core/types/Nil: forall<a> list<a> -> match zszs: list<$5113> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: $5113,zzzz: list<$5113>) -> flatmap-preflatmap-pre: (ys : list<$5114>, zs : list<$5113>) -> $5115 list<$5114>(ff: ($5113) -> $5115 list<$5114>(zz: $5113),zzzz: list<$5113>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> flatmap-preflatmap-pre: (ys : list<$5114>, zs : list<$5113>) -> $5115 list<$5114>([std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,xsxs: list<$5113>) // Concatenate the `Just` result elements from applying a function to all elements. pub fun flatmap-maybestd/core/list/flatmap-maybe: forall<a,b,e> (xs : list<a>, f : (a) -> e maybe<b>) -> e list<b>( xsxs: list<$5193> : liststd/core/types/list: V -> V<aa: V>, ff: ($5193) -> $5195 maybe<$5194> : aa: V -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 5270 list<5269> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$5193> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5193,xxxx: list<$5193>) -> match ff: ($5193) -> $5195 maybe<$5194>(xx: $5193) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $5194) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $5194, xxxx: list<$5193>.flatmap-maybestd/core/list/flatmap-maybe: (xs : list<$5193>, f : ($5193) -> $5195 maybe<$5194>) -> $5195 list<$5194>(ff: ($5193) -> $5195 maybe<$5194>)) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<$5193>.flatmap-maybestd/core/list/flatmap-maybe: (xs : list<$5193>, f : ($5193) -> $5195 maybe<$5194>) -> $5195 list<$5194>(ff: ($5193) -> $5195 maybe<$5194>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Concatenate a list of `:maybe` values pub fun concat-maybestd/core/list/concat-maybe: forall<a> (xs : list<maybe<a>>) -> list<a>( xsxs: list<maybe<$5280>> : liststd/core/types/list: V -> V<maybestd/core/types/maybe: V -> V<aa: V>> )result: -> total list<5334> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<maybe<$5280>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: maybe<$5280>,xxxx: list<maybe<$5280>>) -> match xx: maybe<$5280> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $5280) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $5280, xxxx: list<maybe<$5280>>.concat-maybestd/core/list/concat-maybe: (xs : list<maybe<$5280>>) -> list<$5280>) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<maybe<$5280>>.concat-maybestd/core/list/concat-maybe: (xs : list<maybe<$5280>>) -> list<$5280> Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> // Return the last element of a list (or `Nothing` for the empty list) pub fun laststd/core/list/last: forall<a> (xs : list<a>) -> maybe<a>( xsxs: list<$5339> : liststd/core/types/list: V -> V<aa: V> )result: -> total maybe<5382> : maybestd/core/types/maybe: V -> V<aa: V> match xsxs: list<$5339> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5339,Nilstd/core/types/Nil: forall<a> list<a>) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $5339) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,xxxx: list<$5339>) -> laststd/core/list/last: (xs : list<$5339>) -> maybe<$5339>(xxxx: list<$5339>) Nilstd/core/types/Nil: forall<a> list<a> -> Nothingstd/core/types/Nothing: forall<a> maybe<a> // Return the list without its last element. // Return an empty list for an empty list. pub fun initstd/core/list/init: forall<a> (xs : list<a>) -> list<a>( xsxs: list<$5387> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<5425> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$5387> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5387, xxxx: list<$5387> as Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5387,initstd/core/list/init: (xs : list<$5387>) -> list<$5387>(xxxx: list<$5387>)) _ -> Nilstd/core/types/Nil: forall<a> list<a> // Get (zero-based) element `n` of a list. Return a `:maybe` type. pub fun @index( xsxs: list<$5430> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total maybe<5511> : maybestd/core/types/maybe: V -> V<aa: V> match xsxs: list<$5430> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5430,xxxx: list<$5430>) -> if nn: int>std/core/int/(>): (x : int, y : int) -> bool0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
then xxxx: list<$5430>[nn: int -std/core/int/(-): (x : int, y : int) -> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
] // == @index(xx,n-1) elif nn: int==std/core/int/(==): (x : int, y : int) -> bool0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
then Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $5430) else Nothingstd/core/types/Nothing: forall<a> maybe<a> Nilstd/core/types/Nil: forall<a> list<a> -> Nothingstd/core/types/Nothing: forall<a> maybe<a> // Do all elements satisfy a predicate ? pub fun allstd/core/list/all: forall<a,e> (xs : list<a>, predicate : (a) -> e bool) -> e bool( xsxs: list<$5523> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($5523) -> $5524 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 5563 bool : ee: E boolstd/core/types/bool: V match xsxs: list<$5523> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5523,xxxx: list<$5523>) -> if predicatepredicate: ($5523) -> $5524 bool(xx: $5523) then xxxx: list<$5523>.allstd/core/list/all: (xs : list<$5523>, predicate : ($5523) -> $5524 bool) -> $5524 bool(predicatepredicate: ($5523) -> $5524 bool) else Falsestd/core/types/False: bool Nilstd/core/types/Nil: forall<a> list<a> -> Truestd/core/types/True: bool // Are there any elements in a list that satisfy a predicate ? pub fun anystd/core/list/any: forall<a,e> (xs : list<a>, predicate : (a) -> e bool) -> e bool( xsxs: list<$5570> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($5570) -> $5571 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 5610 bool : ee: E boolstd/core/types/bool: V match xsxs: list<$5570> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5570,xxxx: list<$5570>) -> if predicatepredicate: ($5570) -> $5571 bool(xx: $5570) then Truestd/core/types/True: bool else xxxx: list<$5570>.anystd/core/list/any: (xs : list<$5570>, predicate : ($5570) -> $5571 bool) -> $5571 bool(predicatepredicate: ($5570) -> $5571 bool) Nilstd/core/types/Nil: forall<a> list<a> -> Falsestd/core/types/False: bool // Return the sum of a list of integers pub fun sumstd/core/list/sum: (xs : list<int>) -> int( xsxs: list<int> : liststd/core/types/list: V -> V<intstd/core/types/int: V> )result: -> total int : intstd/core/types/int: V xsxs: list<int>.foldlstd/core/list/foldl: (xs : list<int>, z : int, f : (int, int) -> int) -> int( 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
, fnfn: (x : int, y : int) -> int(xx: int,yy: int) { xx: int +std/core/int/(+): (x : int, y : int) -> int yy: int }
) // Returns the smallest element of a list of integers (or `default` (=`0`) for the empty list) pub fun minimumstd/core/list/minimum: (xs : list<int>, default : ? int) -> int( xsxs: list<int> : liststd/core/types/list: V -> V<intstd/core/types/int: V>, defaultdefault: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)result: -> total int : intstd/core/types/int: V match xsxs: list<int> Nilstd/core/types/Nil: forall<a> list<a> -> defaultdefault: int Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: int,xxxx: list<int>) -> xxxx: list<int>.foldlstd/core/list/foldl: (xs : list<int>, z : int, f : (int, int) -> int) -> int( xx: int, minstd/core/int/min: (i : int, j : int) -> int
) // Returns the largest element of a list of integers (or `default` (=`0`) for the empty list) pub fun maximumstd/core/list/maximum: (xs : list<int>, default : ? int) -> int( xsxs: list<int> : liststd/core/types/list: V -> V<intstd/core/types/int: V>, defaultdefault: ? int : intstd/core/types/int: V = 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
)result: -> total int : intstd/core/types/int: V match xsxs: list<int> Nilstd/core/types/Nil: forall<a> list<a> -> defaultdefault: int Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: int,xxxx: list<int>) -> xxxx: list<int>.foldlstd/core/list/foldl: (xs : list<int>, z : int, f : (int, int) -> int) -> int( xx: int, maxstd/core/int/max: (i : int, j : int) -> int
) // Split a string into a list of lines pub fun linesstd/core/list/lines: (s : string) -> list<string>( ss: string : stringstd/core/types/string: V )result: -> total list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> ss: string.splitstd/core/string/sep/split: (s : string, sep : string) -> list<string>("\n"literal: string
count= 1
) // Join a list of strings with newlines pub fun unlinesstd/core/list/unlines: (xs : list<string>) -> string( xsxs: list<string> : liststd/core/types/list: V -> V<stringstd/core/types/string: V> )result: -> total string : stringstd/core/types/string: V xsxs: list<string>.joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> string("\n"literal: string
count= 1
) // Apply a function `f` to each character in a string pub fun string/mapstd/core/list/string/map: forall<e> (s : string, f : (char) -> e char) -> e string( ss: string : stringstd/core/types/string: V, ff: (char) -> $2109 char : charstd/core/types/char: V -> ee: E charstd/core/types/char: V )result: -> 2160 string : ee: E stringstd/core/types/string: V ss: string.liststd/core/string/list: (s : string) -> $2109 list<char>.mapstd/core/list/map: (xs : list<char>, f : (char) -> $2109 char) -> $2109 list<char>(ff: (char) -> $2109 char).stringstd/core/string/listchar/string: (cs : list<char>) -> $2109 string // todo: optimize