/*---------------------------------------------------------------------------
  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<$557> : liststd/core/types/list: V -> V<aa: V> )result: -> total maybe<581> : maybestd/core/types/maybe: V -> V<aa: V>
  match xsxs: list<$557>
    Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $557) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $557)
    _       -> 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 default/headstd/core/list/default/head: forall<a> (xs : list<a>, default : a) -> a( xsxs: list<$586> : liststd/core/types/list: V -> V<aa: V>, defaultdefault: $586 : aa: V )result: -> total 602 : astd/core/types/total: E
  match xsxs: list<$586>
    Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $586) -> xx: $586
    _       -> defaultdefault: $586

// 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<$607> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<625> : liststd/core/types/list: V -> V<aa: V>
  match xsxs: list<$607>
    Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,xxxx: list<$607>) -> xxxx: list<$607>
    _          -> [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<$630> : liststd/core/types/list: V -> V<aa: V> )result: -> total bool : boolstd/core/types/bool: V
  match xsxs: list<$630>
    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: _651)result: -> total list<664>
  [std/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>xx: _651]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<_703>)result: -> total int
  fun lenlen: forall<a> (ys : list<a>, acc : int) -> int(ysys: list<_679>,accacc: int)result: -> total int
    match ysys: list<_679>
      Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,yyyy: list<_679>) -> yyyy: list<_679>.lenlen: (ys : list<_679>, 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<_703>.lenlen: (ys : list<_703>, 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) -> $1784 $1783 : intstd/core/types/int: V -> ee: E aa: V )result: -> 1838 list<1837> : ee: E liststd/core/types/list: V -> V<aa: V> if lolo: int <=std/core/int/(<=): (x : int, y : int) -> $1784 bool hihi: int then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( ff: (int) -> $1784 $1783(lolo: int), liststd/core/list/function/list: (lo : int, hi : int, f : (int) -> $1784 $1783) -> $1784 list<$1783>( pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> $1784 int(lolo: int.incstd/core/int/inc: (i : int) -> $1784 int), hihi: int, ff: (int) -> $1784 $1783 )) 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) -> $1946 $1945 : intstd/core/types/int: V -> ee: E aa: V )result: -> 2002 list<2001> : ee: E liststd/core/types/list: V -> V<aa: V> if lolo: int <=std/core/int/(<=): (x : int, y : int) -> $1946 bool hihi: int then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>( ff: (int) -> $1946 $1945(lolo: int), liststd/core/list/stridefunction/list: (lo : int, hi : int, stride : int, f : (int) -> $1946 $1945) -> $1946 list<$1945>( pretend-decreasingstd/core/undiv/pretend-decreasing: (x : int) -> $1946 int(lolo: int +std/core/int/(+): (x : int, y : int) -> $1946 int stridestride: int), hihi: int, stridestride: int, ff: (int) -> $1946 $1945 )) 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> (xs : list<a>, ys : list<a>, @implicit/(==) : (a, a) -> bool) -> bool( xsxs: list<$713> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$713> : liststd/core/types/list: V -> V<aa: V>, (@implicit/==)?(==): ($713, $713) -> bool : (aa: V,aa: V) -> boolstd/core/types/bool: V )result: -> total bool : boolstd/core/types/bool: V match xsxs: list<$713> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $713,xxxx: list<$713>) -> match ysys: list<$713> 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: $713,yyyy: list<$713>) -> (xx: $713==?(==): ($713, $713) -> boolyy: $713) &&std/core/types/(&&): (x : bool, y : bool) -> bool (xxxx: list<$713>==std/core/list/(==): (xs : list<$713>, ys : list<$713>, @implicit/(==) : ($713, $713) -> bool) -> bool
?(==)=?(==)
yyyy: list<$713>) Nilstd/core/types/Nil: forall<a> list<a> -> match ysys: list<$713> 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> (xs : list<a>, ys : list<a>, @implicit/cmp : (a, a) -> order) -> order( xsxs: list<$799> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$799> : liststd/core/types/list: V -> V<aa: V>, @implicit/cmp?cmp: ($799, $799) -> order : (aa: V,aa: V) -> orderstd/core/types/order: V )result: -> total order : orderstd/core/types/order: V match xsxs: list<$799> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $799,xxxx: list<$799>) -> match ysys: list<$799> 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: $799,yyyy: list<$799>) -> match cmp?cmp: ($799, $799) -> order(xx: $799,yy: $799) Eqstd/core/types/Eq: order -> cmpstd/core/list/cmp: (xs : list<$799>, ys : list<$799>, @implicit/cmp : ($799, $799) -> order) -> order
?cmp=?cmp
(xxxx: list<$799>,yyyy: list<$799>) lglg: order -> lglg: order Nilstd/core/types/Nil: forall<a> list<a> -> match ysys: list<$799> 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<$3276> : liststd/core/types/list: V -> V<aa: V>, @implicit/show?show: ($3276) -> $3277 string : aa: V -> ee: E stringstd/core/types/string: V )result: -> 3342 string : ee: E stringstd/core/types/string: V "["literal: string
count= 1
++std/core/types/(++): (x : string, y : string) -> $3277 string xsxs: list<$3276>.mapstd/core/list/map: (xs : list<$3276>, f : ($3276) -> $3277 string) -> $3277 list<string>(show?show: ($3276) -> $3277 string).joinstd/core/list/joinsep/join: (xs : list<string>, sep : string) -> $3277 string(","literal: string
count= 1
) ++std/core/types/(++): (x : string, y : string) -> $3277 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<$3359> : liststd/core/types/list: V -> V<aa: V>, show-elemshow-elem: ($3359) -> $3360 string : (aa: V) -> ee: E stringstd/core/types/string: V )result: -> 3381 string : ee: E stringstd/core/types/string: V showstd/core/list/show: (xs : list<$3359>, @implicit/show : ($3359) -> $3360 string) -> $3360 string(xsxs: list<$3359>,@implicit/show=show-elemshow-elem: ($3359) -> $3360 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<$3388> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$3389> : liststd/core/types/list: V -> V<bb: V> )result: -> total list<(3454, 3455)> : liststd/core/types/list: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,bb: V)> match xsxs: list<$3388> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3388,xxxx: list<$3388>) -> match ysys: list<$3389> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3389,yyyy: list<$3389>) -> 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: $3388,yy: $3389)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b),zipstd/core/list/zip: (xs : list<$3388>, ys : list<$3389>) -> list<($3388, $3389)>(xxxx: list<$3388>,yyyy: list<$3389>)) 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<$3463> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$3464> :liststd/core/types/list: V -> V<bb: V>, ^ff: ($3463, $3464) -> $3466 $3465 : (aa: V,bb: V) -> ee: E cc: V )result: -> 3535 list<3534> : ee: E liststd/core/types/list: V -> V<cc: V> match xsxs: list<$3463> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3463,xxxx: list<$3463>) -> match ysys: list<$3464> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3464,yyyy: list<$3464>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: ($3463, $3464) -> $3466 $3465(xx: $3463,yy: $3464),zipwithstd/core/list/zipwith: (xs : list<$3463>, ys : list<$3464>, f : ($3463, $3464) -> $3466 $3465) -> $3466 list<$3465>(xxxx: list<$3463>,yyyy: list<$3464>,ff: ($3463, $3464) -> $3466 $3465)) 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<$3618> : liststd/core/types/list: V -> V<aa: V>, ys0ys0: list<$3619> :liststd/core/types/list: V -> V<bb: V>, ^ff: (int, $3618, $3619) -> $3621 $3620 : (intstd/core/types/int: V,aa: V,bb: V) -> ee: E cc: V )result: -> 3659 list<3658> : ee: E liststd/core/types/list: V -> V<cc: V> zipwith-iterstd/core/list/zipwith-iter: (i : int, xs : list<$3618>, ys : list<$3619>, f : (int, $3618, $3619) -> $3621 $3620) -> $3621 list<$3620>(0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
,xs0xs0: list<$3618>,ys0ys0: list<$3619>,ff: (int, $3618, $3619) -> $3621 $3620
) 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<_3556>, ysys: list<_3561>, ^ff: (int, _3556, _3561) -> _3552 _3567 )result: -> _3552 list<_3567> match xsxs: list<_3556> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _3556,xxxx: list<_3556>) -> match ysys: list<_3561> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _3561,yyyy: list<_3561>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (int, _3556, _3561) -> _3552 _3567(ii: int,xx: _3556,yy: _3561),zipwith-iterstd/core/list/zipwith-iter: (i : int, xs : list<_3556>, ys : list<_3561>, f : (int, _3556, _3561) -> _3552 _3567) -> _3552 list<_3567>(ii: int+std/core/int/(+): (x : int, y : int) -> _3552 int1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
,xxxx: list<_3556>,yyyy: list<_3561>,ff: (int, _3556, _3561) -> _3552 _3567)) 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<($3672, $3673)> : liststd/core/types/list: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,bb: V)> )result: -> total (list<3862>, list<3863>) : (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<(_3685, _3686)>, acc1acc1: cctx<_3727,list<_3685>>, acc2acc2: cctx<_3767,list<_3686>> )result: -> total (_3727, _3767) match ysys: list<(_3685, _3686)> 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: _3685,yy: _3686)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b),xxxx: list<(_3685, _3686)>) -> iteriter: (ys : list<(_3685, _3686)>, acc1 : cctx<_3727,list<_3685>>, acc2 : cctx<_3767,list<_3686>>) -> (_3727, _3767)(xxxx: list<(_3685, _3686)>,acc1acc1: cctx<_3727,list<_3685>> ++std/core/types/cctx/(++): (c1 : cctx<_3727,list<_3685>>, c2 : cctx<list<_3685>,list<_3685>>) -> cctx<_3727,list<_3685>> ctxctx: cctx<list<_3685>,list<_3685>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _3685,_hole: list<_3685>),acc2acc2: cctx<_3767,list<_3686>> ++std/core/types/cctx/(++): (c1 : cctx<_3767,list<_3686>>, c2 : cctx<list<_3686>,list<_3686>>) -> cctx<_3767,list<_3686>> ctxctx: cctx<list<_3686>,list<_3686>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _3686,_hole: list<_3686>)) Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)acc1acc1: cctx<_3727,list<_3685>> ++.std/core/types/cctx/(++.): (c : cctx<_3727,list<_3685>>, x : list<_3685>) -> _3727 Nilstd/core/types/Nil: forall<a> list<a>,acc2acc2: cctx<_3767,list<_3686>> ++.std/core/types/cctx/(++.): (c : cctx<_3767,list<_3686>>, x : list<_3686>) -> _3767 Nilstd/core/types/Nil: forall<a> list<a>)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) iteriter: (ys : list<($3672, $3673)>, acc1 : cctx<list<$3672>,list<$3672>>, acc2 : cctx<list<$3673>,list<$3673>>) -> (list<$3672>, list<$3673>)(xsxs: list<($3672, $3673)>,ctxctx: ctx<list<$3672>> _hole: list<$3672>,ctxctx: ctx<list<$3673>> _hole: list<$3673>) // 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<($3871, $3872, $3873)> : liststd/core/types/list: V -> V<(std/core/types/tuple3: (V, V, V) -> Vaa: V,bb: V,cc: V)>)result: -> total (list<4143>, list<4144>, list<4145>) : (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<(_3887, _3888, _3889)>, acc1acc1: cctx<_3930,list<_3887>>, acc2acc2: cctx<_3970,list<_3888>>, acc3acc3: cctx<_4010,list<_3889>> )result: -> total (_3930, _3970, _4010) match ysys: list<(_3887, _3888, _3889)> 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: _3887,yy: _3888,zz: _3889)std/core/types/Tuple3: forall<a,b,c> (fst : a, snd : b, thd : c) -> (a, b, c),xxxx: list<(_3887, _3888, _3889)>) -> iteriter: (ys : list<(_3887, _3888, _3889)>, acc1 : cctx<_3930,list<_3887>>, acc2 : cctx<_3970,list<_3888>>, acc3 : cctx<_4010,list<_3889>>) -> (_3930, _3970, _4010)(xxxx: list<(_3887, _3888, _3889)>,acc1acc1: cctx<_3930,list<_3887>> ++std/core/types/cctx/(++): (c1 : cctx<_3930,list<_3887>>, c2 : cctx<list<_3887>,list<_3887>>) -> cctx<_3930,list<_3887>> ctxctx: cctx<list<_3887>,list<_3887>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _3887,_hole: list<_3887>),acc2acc2: cctx<_3970,list<_3888>> ++std/core/types/cctx/(++): (c1 : cctx<_3970,list<_3888>>, c2 : cctx<list<_3888>,list<_3888>>) -> cctx<_3970,list<_3888>> ctxctx: cctx<list<_3888>,list<_3888>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _3888,_hole: list<_3888>),acc3acc3: cctx<_4010,list<_3889>> ++std/core/types/cctx/(++): (c1 : cctx<_4010,list<_3889>>, c2 : cctx<list<_3889>,list<_3889>>) -> cctx<_4010,list<_3889>> ctxctx: cctx<list<_3889>,list<_3889>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: _3889,_hole: list<_3889>)) 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<_3930,list<_3887>> ++.std/core/types/cctx/(++.): (c : cctx<_3930,list<_3887>>, x : list<_3887>) -> _3930 Nilstd/core/types/Nil: forall<a> list<a>,acc2acc2: cctx<_3970,list<_3888>> ++.std/core/types/cctx/(++.): (c : cctx<_3970,list<_3888>>, x : list<_3888>) -> _3970 Nilstd/core/types/Nil: forall<a> list<a>,acc3acc3: cctx<_4010,list<_3889>> ++.std/core/types/cctx/(++.): (c : cctx<_4010,list<_3889>>, x : list<_3889>) -> _4010 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<($3871, $3872, $3873)>, acc1 : cctx<list<$3871>,list<$3871>>, acc2 : cctx<list<$3872>,list<$3872>>, acc3 : cctx<list<$3873>,list<$3873>>) -> (list<$3871>, list<$3872>, list<$3873>)(xsxs: list<($3871, $3872, $3873)>,ctxctx: ctx<list<$3871>> _hole: list<$3871>,ctxctx: ctx<list<$3872>> _hole: list<$3872>,ctxctx: ctx<list<$3873>> _hole: list<$3873>) // 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<($4156, $4157, $4158, $4159)> : 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<4510>, list<4511>, list<4512>, list<4513>) : (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<(_4175, _4176, _4177, _4178)>, acc1acc1: cctx<_4219,list<_4175>>, acc2acc2: cctx<_4259,list<_4176>>, acc3acc3: cctx<_4299,list<_4177>>, acc4acc4: cctx<_4339,list<_4178>> )result: -> total (_4219, _4259, _4299, _4339) match ysys: list<(_4175, _4176, _4177, _4178)> 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: _4175,yy: _4176,zz: _4177,ww: _4178)std/core/types/Tuple4: forall<a,b,c,d> (fst : a, snd : b, thd : c, field4 : d) -> (a, b, c, d),xxxx: list<(_4175, _4176, _4177, _4178)>) -> iteriter: (ys : list<(_4175, _4176, _4177, _4178)>, acc1 : cctx<_4219,list<_4175>>, acc2 : cctx<_4259,list<_4176>>, acc3 : cctx<_4299,list<_4177>>, acc4 : cctx<_4339,list<_4178>>) -> (_4219, _4259, _4299, _4339)(xxxx: list<(_4175, _4176, _4177, _4178)>,acc1acc1: cctx<_4219,list<_4175>> ++std/core/types/cctx/(++): (c1 : cctx<_4219,list<_4175>>, c2 : cctx<list<_4175>,list<_4175>>) -> cctx<_4219,list<_4175>> ctxctx: cctx<list<_4175>,list<_4175>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: _4175,_hole: list<_4175>),acc2acc2: cctx<_4259,list<_4176>> ++std/core/types/cctx/(++): (c1 : cctx<_4259,list<_4176>>, c2 : cctx<list<_4176>,list<_4176>>) -> cctx<_4259,list<_4176>> ctxctx: cctx<list<_4176>,list<_4176>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: _4176,_hole: list<_4176>),acc3acc3: cctx<_4299,list<_4177>> ++std/core/types/cctx/(++): (c1 : cctx<_4299,list<_4177>>, c2 : cctx<list<_4177>,list<_4177>>) -> cctx<_4299,list<_4177>> ctxctx: cctx<list<_4177>,list<_4177>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: _4177,_hole: list<_4177>),acc4acc4: cctx<_4339,list<_4178>> ++std/core/types/cctx/(++): (c1 : cctx<_4339,list<_4178>>, c2 : cctx<list<_4178>,list<_4178>>) -> cctx<_4339,list<_4178>> ctxctx: cctx<list<_4178>,list<_4178>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ww: _4178,_hole: list<_4178>)) 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<_4219,list<_4175>> ++.std/core/types/cctx/(++.): (c : cctx<_4219,list<_4175>>, x : list<_4175>) -> _4219 Nilstd/core/types/Nil: forall<a> list<a>,acc2acc2: cctx<_4259,list<_4176>> ++.std/core/types/cctx/(++.): (c : cctx<_4259,list<_4176>>, x : list<_4176>) -> _4259 Nilstd/core/types/Nil: forall<a> list<a>,acc3acc3: cctx<_4299,list<_4177>> ++.std/core/types/cctx/(++.): (c : cctx<_4299,list<_4177>>, x : list<_4177>) -> _4299 Nilstd/core/types/Nil: forall<a> list<a>,acc4acc4: cctx<_4339,list<_4178>> ++.std/core/types/cctx/(++.): (c : cctx<_4339,list<_4178>>, x : list<_4178>) -> _4339 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<($4156, $4157, $4158, $4159)>, acc1 : cctx<list<$4156>,list<$4156>>, acc2 : cctx<list<$4157>,list<$4157>>, acc3 : cctx<list<$4158>,list<$4158>>, acc4 : cctx<list<$4159>,list<$4159>>) -> (list<$4156>, list<$4157>, list<$4158>, list<$4159>)(xsxs: list<($4156, $4157, $4158, $4159)>,ctxctx: ctx<list<$4156>> _hole: list<$4156>,ctxctx: ctx<list<$4157>> _hole: list<$4157>,ctxctx: ctx<list<$4158>> _hole: list<$4158>,ctxctx: ctx<list<$4159>> _hole: list<$4159>) // 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<$878> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total list<919> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$878> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $878,xxxx: list<$878>) | 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: $878, takestd/core/list/take: (xs : list<$878>, n : int) -> list<$878>(xxxx: list<$878>, 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<$924> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total list<956> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$924> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,xxxx: list<$924>) | nn: int >std/core/int/(>): (x : int, y : int) -> bool 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
-> dropstd/core/list/drop: (xs : list<$924>, n : int) -> list<$924>(xxxx: list<$924>, nn: int -std/core/int/(-): (x : int, y : int) -> int 1literal: int
dec = 1
hex8 = 0x01
bit8 = 0b00000001
) _ -> xsxs: list<$924>
// 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<$2052> : liststd/core/types/list: V -> V<aa: V>, ^ff: ($2052) -> $2054 $2053 : aa: V -> ee: E bb: V)result: -> 2107 list<2106> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$2052> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2052,xxxx: list<$2052>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: ($2052) -> $2054 $2053(xx: $2052), xxxx: list<$2052>.mapstd/core/list/map: (xs : list<$2052>, f : ($2052) -> $2054 $2053) -> $2054 list<$2053>(ff: ($2052) -> $2054 $2053)) 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<$2145> : liststd/core/types/list: V -> V<aa: V>, ff: (idx : int, value : $2145) -> $2147 $2146 : (idx : intstd/core/types/int: V, value : aa: V) -> ee: E bb: V)result: -> 2200 list<2199> : ee: E liststd/core/types/list: V -> V<bb: V> fun map-idxmap-idx: (ys : list<$2145>, i : int) -> $2147 list<$2146>(ysys: list<$2145>,ii: int)result: -> $2147 list<$2146> match ysys: list<$2145> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2145,yyyy: list<$2145>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (idx : int, value : $2145) -> $2147 $2146(ii: int,yy: $2145), map-idxmap-idx: (ys : list<$2145>, i : int) -> $2147 list<$2146>(yyyy: list<$2145>,ii: int+std/core/int/(+): (x : int, y : int) -> $2147 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<$2145>, i : int) -> $2147 list<$2146>(xsxs: list<$2145>,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<$2210> : liststd/core/types/list: V -> V<aa: V>, ff: (value : $2210, rest : list<$2210>) -> $2212 $2211 : (value : aa: V, rest : liststd/core/types/list: V -> V<aa: V>) -> ee: E bb: V)result: -> 2258 list<2257> : ee: E liststd/core/types/list: V -> V<bb: V> fun mappeekmappeek: (ys : list<$2210>) -> $2212 list<$2211>(ysys: list<$2210>)result: -> $2212 list<$2211> match ysys: list<$2210> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2210,yyyy: list<$2210>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (value : $2210, rest : list<$2210>) -> $2212 $2211(yy: $2210,yyyy: list<$2210>), yyyy: list<$2210>.mappeekmappeek: (ys : list<$2210>) -> $2212 list<$2211>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> mappeekmappeek: (ys : list<$2210>) -> $2212 list<$2211>(xsxs: list<$2210>) // 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<$2268> : liststd/core/types/list: V -> V<aa: V>, ff: (idx : int, value : $2268, rest : list<$2268>) -> $2270 $2269 : (idx : intstd/core/types/int: V, value : aa: V, rest : liststd/core/types/list: V -> V<aa: V> ) -> ee: E bb: V)result: -> 2324 list<2323> : ee: E liststd/core/types/list: V -> V<bb: V> fun mapidxmapidx: (ys : list<$2268>, i : int) -> $2270 list<$2269>(ysys: list<$2268>,ii: int)result: -> $2270 list<$2269> match ysys: list<$2268> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2268,yyyy: list<$2268>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(ff: (idx : int, value : $2268, rest : list<$2268>) -> $2270 $2269(ii: int,yy: $2268,yyyy: list<$2268>), mapidxmapidx: (ys : list<$2268>, i : int) -> $2270 list<$2269>(yyyy: list<$2268>,ii: int+std/core/int/(+): (x : int, y : int) -> $2270 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<$2268>, i : int) -> $2270 list<$2269>(xsxs: list<$2268>,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<$1016> : liststd/core/types/list: V -> V<aa: V>)result: -> total list<1033> : liststd/core/types/list: V -> V<aa: V> reverse-appendstd/core/list/reverse-append: (xs : list<$1016>, tl : list<$1016>) -> list<$1016>( xsxs: list<$1016>, 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<$996> : liststd/core/types/list: V -> V<aa: V>, tltl: list<$996> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1011> : liststd/core/types/list: V -> V<aa: V> reverse-accstd/core/list/reverse-acc: (acc : list<$996>, ys : list<$996>) -> list<$996>(tltl: list<$996>,xsxs: list<$996>) fip fun reverse-accstd/core/list/reverse-acc: forall<a> (acc : list<a>, ys : list<a>) -> list<a>(accacc: list<$961> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$961> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<991> : liststd/core/types/list: V -> V<aa: V> match ysys: list<$961> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $961,xxxx: list<$961>) -> reverse-accstd/core/list/reverse-acc: (acc : list<$961>, ys : list<$961>) -> list<$961>(Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $961,accacc: list<$961>),xxxx: list<$961>) _ -> accacc: list<$961> // Append two lists. pub fip fun (++)std/core/list/(++): forall<a> (xs : list<a>, ys : list<a>) -> list<a>(xsxs: list<$1076> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$1076> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1091> : liststd/core/types/list: V -> V<aa: V> appendstd/core/list/append: (xs : list<$1076>, ys : list<$1076>) -> list<$1076>(xsxs: list<$1076>,ysys: list<$1076>) // Append two lists. pub fip fun appendstd/core/list/append: forall<a> (xs : list<a>, ys : list<a>) -> list<a>(xsxs: list<$1038> : liststd/core/types/list: V -> V<aa: V>, ysys: list<$1038> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<1071> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$1038> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1038,xxxx: list<$1038>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1038,appendstd/core/list/append: (xs : list<$1038>, ys : list<$1038>) -> list<$1038>(xxxx: list<$1038>,ysys: list<$1038>)) Nilstd/core/types/Nil: forall<a> list<a> -> ysys: list<$1038> // 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<$1150> : liststd/core/types/list: V -> V<aa: V>, zz: $1151 : bb: V, ff: ($1150, $1151) -> $1152 $1151 : (aa: V, bb: V) -> ee: E bb: V)result: -> 1190 1189 : ee: E bb: V xsxs: list<$1150>.reversestd/core/list/reverse: (xs : list<$1150>) -> $1152 list<$1150>.foldlstd/core/list/foldl: (xs : list<$1150>, z : $1151, f : ($1151, $1150) -> $1152 $1151) -> $1152 $1151(zz: $1151) fnfn: (x : $1151, y : $1150) -> $1152 $1151(xx: $1151,yy: $1150) ff: ($1150, $1151) -> $1152 $1151(yy: $1150,xx: $1151) // 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<$1096> : liststd/core/types/list: V -> V<aa: V>, zz: $1097 : bb: V, ff: ($1097, $1096) -> $1098 $1097 : (bb: V, aa: V) -> ee: E bb: V)result: -> 1140 1139 : ee: E bb: V match xsxs: list<$1096> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1096,xxxx: list<$1096>) -> foldlstd/core/list/foldl: (xs : list<$1096>, z : $1097, f : ($1097, $1096) -> $1098 $1097) -> $1098 $1097(xxxx: list<$1096>,ff: ($1097, $1096) -> $1098 $1097(zz: $1097,xx: $1096),ff: ($1097, $1096) -> $1098 $1097) Nilstd/core/types/Nil: forall<a> list<a> -> zz: $1097 pub fun foldl1std/core/list/foldl1: forall<a,e> (xs : list<a>, f : (a, a) -> <exn|e> a) -> <exn|e> a(xsxs: list<$1200> : liststd/core/types/list: V -> V<aa: V>, ff: ($1200, $1200) -> <exn|$1201> $1200 : (aa: V,aa: V) -> <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V)result: -> <exn|1245> 1244 : <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V match xsxs: list<$1200> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1200,xxxx: list<$1200>) -> xxxx: list<$1200>.foldlstd/core/list/foldl: (xs : list<$1200>, z : $1200, f : ($1200, $1200) -> <exn|$1201> $1200) -> <exn|$1201> $1200(xx: $1200,ff: ($1200, $1200) -> <exn|$1201> $1200) Nilstd/core/types/Nil: forall<a> list<a> -> throwstd/core/exn/throw: (message : string, info : ? exception-info) -> <exn|$1201> $1200("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<$1252> : liststd/core/types/list: V -> V<aa: V>, ff: ($1252, $1252) -> <exn|$1253> $1252 : (aa: V,aa: V) -> <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V)result: -> <exn|1279> 1278 : <exnstd/core/exn/exn: (E, V) -> V|std/core/types/effect-extend: (X, E) -> Eee: E> aa: V xsxs: list<$1252>.reversestd/core/list/reverse: (xs : list<$1252>) -> <exn|$1253> list<$1252>.foldl1std/core/list/foldl1: (xs : list<$1252>, f : ($1252, $1252) -> <exn|$1253> $1252) -> <exn|$1253> $1252(ff: ($1252, $1252) -> <exn|$1253> $1252) // Create a list of `n` repeated elements `x` pub fun replicatestd/core/list/replicate: forall<a> (x : a, n : int) -> list<a>( xx: $2334 : aa: V, nn: int : intstd/core/types/int: V )result: -> total list<2377> : 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: $2334, replicatestd/core/list/replicate: (x : $2334, n : int) -> list<$2334>(xx: $2334,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<$1286> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total (list<1318>, list<1318>) : (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<$1286>.takestd/core/list/take: (xs : list<$1286>, n : int) -> list<$1286>(nn: int), xsxs: list<$1286>.dropstd/core/list/drop: (xs : list<$1286>, n : int) -> list<$1286>(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<$4527> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($4527) -> $4528 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 4659 (list<4658>, list<4658>) : 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<$4527>, acc : cctx<a,list<$4527>>) -> $4528 (a, list<$4527>)( ysys: list<$4527>, accacc: cctx<_4579,list<$4527>> )result: -> $4528 (_4579, list<$4527>) match ysys: list<$4527> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4527,yyyy: list<$4527>) -> if yy: $4527.predicatepredicate: ($4527) -> $4528 bool then yyyy: list<$4527>.span-accspan-acc: (ys : list<$4527>, acc : cctx<_4579,list<$4527>>) -> $4528 (_4579, list<$4527>)(accacc: cctx<_4579,list<$4527>> ++std/core/types/cctx/(++): (c1 : cctx<_4579,list<$4527>>, c2 : cctx<list<$4527>,list<$4527>>) -> $4528 cctx<_4579,list<$4527>> ctxctx: cctx<list<$4527>,list<$4527>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4527, _hole: list<$4527>)) else (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)accacc: cctx<_4579,list<$4527>> ++.std/core/types/cctx/(++.): (c : cctx<_4579,list<$4527>>, x : list<$4527>) -> $4528 _4579 [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,ysys: list<$4527>)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<_4579,list<$4527>> ++.std/core/types/cctx/(++.): (c : cctx<_4579,list<$4527>>, x : list<$4527>) -> $4528 _4579 [std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>, ysys: list<$4527>)std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b) xsxs: list<$4527>.span-accspan-acc: (ys : list<$4527>, acc : cctx<list<$4527>,list<$4527>>) -> $4528 (list<$4527>, list<$4527>)( ctxctx: ctx<list<$4527>> _hole: list<$4527> ) // 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<$4666> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($4666) -> $4667 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 4715 list<4714> : ee: E liststd/core/types/list: V -> V<aa: V> match xsxs: list<$4666> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $4666,xxxx: list<$4666>) -> if xx: $4666.predicatepredicate: ($4666) -> $4667 bool then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $4666, xxxx: list<$4666>.take-whilestd/core/list/take-while: (xs : list<$4666>, predicate : ($4666) -> $4667 bool) -> $4667 list<$4666>(predicatepredicate: ($4666) -> $4667 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<$1323> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($1323) -> $1324 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 1363 list<1362> : ee: E liststd/core/types/list: V -> V<aa: V> match xsxs: list<$1323> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1323,xxxx: list<$1323>) -> if xx: $1323.predicatepredicate: ($1323) -> $1324 bool then xxxx: list<$1323>.drop-whilestd/core/list/drop-while: (xs : list<$1323>, predicate : ($1323) -> $1324 bool) -> $1324 list<$1323>(predicatepredicate: ($1323) -> $1324 bool) else xsxs: list<$1323> 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<$1370> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1370) -> $1371 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 1425 list<1424> : ee: E liststd/core/types/list: V -> V<aa: V> match xsxs: list<$1370> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1370,xxxx: list<$1370>) -> if predpred: ($1370) -> $1371 bool(xx: $1370) then Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1370,xxxx: list<$1370>.filterstd/core/list/filter: (xs : list<$1370>, pred : ($1370) -> $1371 bool) -> $1371 list<$1370>(predpred: ($1370) -> $1371 bool)) else xxxx: list<$1370>.filterstd/core/list/filter: (xs : list<$1370>, pred : ($1370) -> $1371 bool) -> $1371 list<$1370>(predpred: ($1370) -> $1371 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<$2382> : liststd/core/types/list: V -> V<aa: V>, predpred: ($2382) -> $2383 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2416 list<2415> : ee: E liststd/core/types/list: V -> V<aa: V> xsxs: list<$2382>.filterstd/core/list/filter: (xs : list<$2382>, pred : ($2382) -> $2383 bool) -> $2383 list<$2382>( fnfn: (x : $2382) -> $2383 bool(xx: $2382) !std/core/types/bool/(!): (b : bool) -> $2383 boolpredpred: ($2382) -> $2383 bool(xx: $2382) ) // 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<$2574> : liststd/core/types/list: V -> V<aa: V>, ^predpred: ($2574) -> $2575 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2611 (list<2610>, list<2610>) : 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<$2574>, pred : ($2574) -> $2575 bool, acc1 : ctx<list<$2574>>, acc2 : ctx<list<$2574>>) -> $2575 (list<$2574>, list<$2574>)(xsxs: list<$2574>, predpred: ($2574) -> $2575 bool, ctxctx: ctx<list<$2574>> _hole: list<$2574>, ctxctx: ctx<list<$2574>> _hole: list<$2574>) 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<$2423> : liststd/core/types/list: V -> V<aa: V>, ^predpred: ($2423) -> $2424 bool : aa: V -> ee: E boolstd/core/types/bool: V, acc1acc1: ctx<list<$2423>> : ctxstd/core/types/ctx: V -> V<liststd/core/types/list: V -> V<aa: V>>, acc2acc2: ctx<list<$2423>> : ctxstd/core/types/ctx: V -> V<liststd/core/types/list: V -> V<aa: V>>)result: -> 2567 (list<2566>, list<2566>): 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<$2423> Nilstd/core/types/Nil: forall<a> list<a> -> (std/core/types/Tuple2: forall<a,b> (fst : a, snd : b) -> (a, b)acc1acc1: ctx<list<$2423>> ++.std/core/types/cctx/(++.): (c : cctx<list<$2423>,list<$2423>>, x : list<$2423>) -> $2424 list<$2423> Nilstd/core/types/Nil: forall<a> list<a>, acc2acc2: ctx<list<$2423>> ++.std/core/types/cctx/(++.): (c : cctx<list<$2423>,list<$2423>>, x : list<$2423>) -> $2424 list<$2423> 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: $2423,xxxx: list<$2423>) -> if predpred: ($2423) -> $2424 bool(xx: $2423) then partition-accstd/core/list/partition-acc: (xs : list<$2423>, pred : ($2423) -> $2424 bool, acc1 : ctx<list<$2423>>, acc2 : ctx<list<$2423>>) -> $2424 (list<$2423>, list<$2423>)(xxxx: list<$2423>,predpred: ($2423) -> $2424 bool,acc1acc1: ctx<list<$2423>> ++std/core/types/cctx/(++): (c1 : cctx<list<$2423>,list<$2423>>, c2 : cctx<list<$2423>,list<$2423>>) -> $2424 cctx<list<$2423>,list<$2423>> ctxctx: cctx<list<$2423>,list<$2423>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2423,_hole: list<$2423>),acc2acc2: ctx<list<$2423>>) else partition-accstd/core/list/partition-acc: (xs : list<$2423>, pred : ($2423) -> $2424 bool, acc1 : ctx<list<$2423>>, acc2 : ctx<list<$2423>>) -> $2424 (list<$2423>, list<$2423>)(xxxx: list<$2423>,predpred: ($2423) -> $2424 bool,acc1acc1: ctx<list<$2423>>,acc2acc2: ctx<list<$2423>> ++std/core/types/cctx/(++): (c1 : cctx<list<$2423>,list<$2423>>, c2 : cctx<list<$2423>,list<$2423>>) -> $2424 cctx<list<$2423>,list<$2423>> ctxctx: cctx<list<$2423>,list<$2423>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2423,_hole: list<$2423>)) // 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<$1432> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1432) -> $1434 maybe<$1433> : aa: V -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 1505 list<1504> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$1432> 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: $1432,xxxx: list<$1432>) -> match predpred: ($1432) -> $1434 maybe<$1433>(xx: $1432) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<$1432>.filter-mapstd/core/list/filter-map: (xs : list<$1432>, pred : ($1432) -> $1434 maybe<$1433>) -> $1434 list<$1433>(predpred: ($1432) -> $1434 maybe<$1433>) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $1433) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $1433,xxxx: list<$1432>.filter-mapstd/core/list/filter-map: (xs : list<$1432>, pred : ($1432) -> $1434 maybe<$1433>) -> $1434 list<$1433>(predpred: ($1432) -> $1434 maybe<$1433>)) // 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<$1593> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1593) -> $1594 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 1642 maybe<1641> : ee: E maybestd/core/types/maybe: V -> V<aa: V> xsxs: list<$1593>.foreach-whilestd/core/list/foreach-while: (xs : list<$1593>, action : ($1593) -> $1594 maybe<$1593>) -> $1594 maybe<$1593> fnfn: (x : $1593) -> $1594 maybe<$1593>(xx: $1593) if predpred: ($1593) -> $1594 bool(xx: $1593) then Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $1593) 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<$1649> : liststd/core/types/list: V -> V<aa: V>, predpred: ($1649) -> $1651 maybe<$1650> : aa: V -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 1689 maybe<1688> : ee: E maybestd/core/types/maybe: V -> V<bb: V> xsxs: list<$1649>.foreach-whilestd/core/list/foreach-while: (xs : list<$1649>, action : ($1649) -> $1651 maybe<$1650>) -> $1651 maybe<$1650>(predpred: ($1649) -> $1651 maybe<$1650>) // 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<($2618, $2619)> : liststd/core/types/list: V -> V<(std/core/types/tuple2: (V, V) -> Vaa: V,bb: V)>, predpred: ($2618) -> $2620 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2743 maybe<2742> : ee: E maybestd/core/types/maybe: V -> V<bb: V> xsxs: list<($2618, $2619)>.foreach-whilestd/core/list/foreach-while: (xs : list<($2618, $2619)>, action : (($2618, $2619)) -> $2620 maybe<$2619>) -> $2620 maybe<$2619> fnfn: (kv : ($2618, $2619)) -> $2620 maybe<$2619>(kvkv: ($2618, $2619)) if predpred: ($2618) -> $2620 bool(kvkv: ($2618, $2619).fststd/core/types/tuple2/fst: (tuple2 : ($2618, $2619)) -> $2620 $2618) then Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(kvkv: ($2618, $2619).sndstd/core/types/tuple2/snd: (tuple2 : ($2618, $2619)) -> $2620 $2619) 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<$1699> : maybestd/core/types/maybe: V -> V<aa: V> )result: -> total list<1729> : liststd/core/types/list: V -> V<aa: V> match mm: maybe<$1699> 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: $1699) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $1699,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<$2753> : liststd/core/types/list: V -> V<aa: V>, predpred: ($2753) -> $2754 bool : aa: V -> ee: E boolstd/core/types/bool: V, idxidx: int : intstd/core/types/int: V )result: -> 2796 int : ee: E intstd/core/types/int: V match xsxs: list<$2753> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2753,xxxx: list<$2753>) -> if predpred: ($2753) -> $2754 bool(xx: $2753) then idxidx: int else index-of-accstd/core/list/index-of-acc: (xs : list<$2753>, pred : ($2753) -> $2754 bool, idx : int) -> $2754 int(xxxx: list<$2753>,predpred: ($2753) -> $2754 bool,idxidx: int+std/core/int/(+): (x : int, y : int) -> $2754 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<$2803> : liststd/core/types/list: V -> V<aa: V>, predpred: ($2803) -> $2804 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 2825 int : ee: E intstd/core/types/int: V index-of-accstd/core/list/index-of-acc: (xs : list<$2803>, pred : ($2803) -> $2804 bool, idx : int) -> $2804 int( xsxs: list<$2803>, predpred: ($2803) -> $2804 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<$2832> : liststd/core/types/list: V -> V<aa: V>, actionaction: ($2832) -> $2833 () : (aa: V) -> ee: E (std/core/types/unit: V)std/core/types/unit: V )result: -> 2873 () : ee: E (std/core/types/unit: V)std/core/types/unit: V match xsxs: list<$2832> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $2832,xxxx: list<$2832>) -> { actionaction: ($2832) -> $2833 ()(xx: $2832); xxxx: list<$2832>.foreachstd/core/list/foreach: (xs : list<$2832>, action : ($2832) -> $2833 ()) -> $2833 ()(actionaction: ($2832) -> $2833 ()) } 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<$1515> : liststd/core/types/list: V -> V<aa: V>, actionaction: ($1515) -> $1517 maybe<$1516> : (aa: V) -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 1577 maybe<1576> : ee: E maybestd/core/types/maybe: V -> V<bb: V> match xsxs: list<$1515> 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: $1515,xxxx: list<$1515>) -> match actionaction: ($1515) -> $1517 maybe<$1516>(xx: $1515) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<$1515>.foreach-whilestd/core/list/foreach-while: (xs : list<$1515>, action : ($1515) -> $1517 maybe<$1516>) -> $1517 maybe<$1516>(actionaction: ($1515) -> $1517 maybe<$1516>) justjust: maybe<$1516> -> justjust: maybe<$1516> // 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<$2884> : liststd/core/types/list: V -> V<aa: V>, actionaction: ($2884) -> $2886 maybe<$2885> : (aa: V) -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 2948 list<2947> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$2884> 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: $2884,xxxx: list<$2884>) -> match actionaction: ($2884) -> $2886 maybe<$2885>(xx: $2884) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $2885) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $2885,xxxx: list<$2884>.map-whilestd/core/list/map-while: (xs : list<$2884>, action : ($2884) -> $2886 maybe<$2885>) -> $2886 list<$2885>(actionaction: ($2884) -> $2886 maybe<$2885>)) 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<$2958> : liststd/core/types/list: V -> V<aa: V>, actionaction: (int, $2958) -> $2959 () : (intstd/core/types/int: V,aa: V) -> ee: E (std/core/types/unit: V)std/core/types/unit: V )result: -> 3079 () : ee: E (std/core/types/unit: V)std/core/types/unit: V var ii: local-var<$2968,int> := 0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
xsxs: list<$2958>.foreachstd/core/list/foreach: (xs : list<$2958>, action : ($2958) -> <local<$2968>|$2959> ()) -> <local<$2968>|$2959> () fnfn: (x : $2958) -> <local<$2968>|$2959> ()(xx: $2958) val jj: int = ii: int // don't dereference `i` inside the inject actionaction: (int, $2958) -> $2959 ()(jj: int,xx: $2958) ii: local-var<$2968,int> :=std/core/types/local-set: (v : local-var<$2968,int>, assigned : int) -> <local<$2968>|$2959> () ii: int+std/core/int/(+): (x : int, y : int) -> <local<$2968>|$2959> 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<$3086> : liststd/core/types/list: V -> V<aa: V>, sepsep: $3086 : aa: V )result: -> total list<3150> : liststd/core/types/list: V -> V<aa: V> fun beforebefore: (ys : list<$3086>) -> list<$3086>(ysys: list<$3086>)result: -> total list<$3086> match ysys: list<$3086> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3086,yyyy: list<$3086>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(sepsep: $3086,Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $3086,beforebefore: (ys : list<$3086>) -> list<$3086>(yyyy: list<$3086>))) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> match xsxs: list<$3086> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3086,xxxx: list<$3086>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $3086, xxxx: list<$3086>.beforebefore: (ys : list<$3086>) -> list<$3086>) 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<$4759>> : liststd/core/types/list: V -> V<liststd/core/types/list: V -> V<aa: V>> )result: -> total list<4834> : 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<$4760> : liststd/core/types/list: V -> V<aa: V>, zsszss: list<list<$4760>> : liststd/core/types/list: V -> V<liststd/core/types/list: V -> V<aa: V>> )result: -> total list<4813> : liststd/core/types/list: V -> V<aa: V> match ysys: list<$4760> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4760,yyyy: list<$4760>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4760,concat-preconcat-pre: (ys : list<$4760>, zss : list<list<$4760>>) -> list<$4760>(yyyy: list<$4760>,zsszss: list<list<$4760>>)) Nilstd/core/types/Nil: forall<a> list<a> -> match zsszss: list<list<$4760>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zszs: list<$4760>,zzszzs: list<list<$4760>>) -> concat-preconcat-pre: (ys : list<$4760>, zss : list<list<$4760>>) -> list<$4760>(zszs: list<$4760>,zzszzs: list<list<$4760>>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> concat-preconcat-pre: (ys : list<$4759>, zss : list<list<$4759>>) -> list<$4759>([std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,xssxss: list<list<$4759>>) // 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<$4839>: liststd/core/types/list: V -> V<aa: V>, ff: ($4839) -> $4841 list<$4840> : aa: V -> ee: E liststd/core/types/list: V -> V<bb: V> )result: -> 4904 list<4903> : ee: E liststd/core/types/list: V -> V<bb: V> fun flatmap-preflatmap-pre: (ys : list<$4840>, zs : list<$4839>) -> $4841 list<$4840>( ysys: list<$4840>, zszs: list<$4839> )result: -> $4841 list<$4840> match ysys: list<$4840> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4840,yyyy: list<$4840>) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4840,flatmap-preflatmap-pre: (ys : list<$4840>, zs : list<$4839>) -> $4841 list<$4840>(yyyy: list<$4840>,zszs: list<$4839>)) Nilstd/core/types/Nil: forall<a> list<a> -> match zszs: list<$4839> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(zz: $4839,zzzz: list<$4839>) -> flatmap-preflatmap-pre: (ys : list<$4840>, zs : list<$4839>) -> $4841 list<$4840>(ff: ($4839) -> $4841 list<$4840>(zz: $4839),zzzz: list<$4839>) Nilstd/core/types/Nil: forall<a> list<a> -> Nilstd/core/types/Nil: forall<a> list<a> flatmap-preflatmap-pre: (ys : list<$4840>, zs : list<$4839>) -> $4841 list<$4840>([std/core/types/Nil: forall<a> list<a>]std/core/types/Nil: forall<a> list<a>,xsxs: list<$4839>) // 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<$4914> : liststd/core/types/list: V -> V<aa: V>, ff: ($4914) -> $4916 maybe<$4915> : aa: V -> ee: E maybestd/core/types/maybe: V -> V<bb: V> )result: -> 4987 list<4986> : ee: E liststd/core/types/list: V -> V<bb: V> match xsxs: list<$4914> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $4914,xxxx: list<$4914>) -> match ff: ($4914) -> $4916 maybe<$4915>(xx: $4914) Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $4915) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4915, xxxx: list<$4914>.flatmap-maybestd/core/list/flatmap-maybe: (xs : list<$4914>, f : ($4914) -> $4916 maybe<$4915>) -> $4916 list<$4915>(ff: ($4914) -> $4916 maybe<$4915>)) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<$4914>.flatmap-maybestd/core/list/flatmap-maybe: (xs : list<$4914>, f : ($4914) -> $4916 maybe<$4915>) -> $4916 list<$4915>(ff: ($4914) -> $4916 maybe<$4915>) 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<$4997>> : liststd/core/types/list: V -> V<maybestd/core/types/maybe: V -> V<aa: V>> )result: -> total list<5048> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<maybe<$4997>> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: maybe<$4997>,xxxx: list<maybe<$4997>>) -> match xx: maybe<$4997> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(yy: $4997) -> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(yy: $4997, xxxx: list<maybe<$4997>>.concat-maybestd/core/list/concat-maybe: (xs : list<maybe<$4997>>) -> list<$4997>) Nothingstd/core/types/Nothing: forall<a> maybe<a> -> xxxx: list<maybe<$4997>>.concat-maybestd/core/list/concat-maybe: (xs : list<maybe<$4997>>) -> list<$4997> 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<$5053> : liststd/core/types/list: V -> V<aa: V> )result: -> total maybe<5094> : maybestd/core/types/maybe: V -> V<aa: V> match xsxs: list<$5053> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5053,Nilstd/core/types/Nil: forall<a> list<a>) -> Juststd/core/types/Just: forall<a> (value : a) -> maybe<a>(xx: $5053) Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(_,xxxx: list<$5053>) -> laststd/core/list/last: (xs : list<$5053>) -> maybe<$5053>(xxxx: list<$5053>) 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<$5099> : liststd/core/types/list: V -> V<aa: V> )result: -> total list<5135> : liststd/core/types/list: V -> V<aa: V> match xsxs: list<$5099> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5099, xxxx: list<$5099> 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: $5099,initstd/core/list/init: (xs : list<$5099>) -> list<$5099>(xxxx: list<$5099>)) _ -> 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<$5140> : liststd/core/types/list: V -> V<aa: V>, nn: int : intstd/core/types/int: V )result: -> total maybe<5214> : maybestd/core/types/maybe: V -> V<aa: V> match xsxs: list<$5140> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5140,xxxx: list<$5140>) -> if nn: int>std/core/int/(>): (x : int, y : int) -> bool0literal: int
dec = 0
hex8 = 0x00
bit8 = 0b00000000
then xxxx: list<$5140>[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: $5140) 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<$5226> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($5226) -> $5227 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 5264 bool : ee: E boolstd/core/types/bool: V match xsxs: list<$5226> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5226,xxxx: list<$5226>) -> if predicatepredicate: ($5226) -> $5227 bool(xx: $5226) then xxxx: list<$5226>.allstd/core/list/all: (xs : list<$5226>, predicate : ($5226) -> $5227 bool) -> $5227 bool(predicatepredicate: ($5226) -> $5227 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<$5271> : liststd/core/types/list: V -> V<aa: V>, predicatepredicate: ($5271) -> $5272 bool : aa: V -> ee: E boolstd/core/types/bool: V )result: -> 5309 bool : ee: E boolstd/core/types/bool: V match xsxs: list<$5271> Consstd/core/types/Cons: forall<a> (head : a, tail : list<a>) -> list<a>(xx: $5271,xxxx: list<$5271>) -> if predicatepredicate: ($5271) -> $5272 bool(xx: $5271) then Truestd/core/types/True: bool else xxxx: list<$5271>.anystd/core/list/any: (xs : list<$5271>, predicate : ($5271) -> $5272 bool) -> $5272 bool(predicatepredicate: ($5271) -> $5272 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) -> $2003 char : charstd/core/types/char: V -> ee: E charstd/core/types/char: V )result: -> 2051 string : ee: E stringstd/core/types/string: V ss: string.liststd/core/string/list: (s : string) -> $2003 list<char>.mapstd/core/list/map: (xs : list<char>, f : (char) -> $2003 char) -> $2003 list<char>(ff: (char) -> $2003 char).stringstd/core/string/listchar/string: (cs : list<char>) -> $2003 string // todo: optimize