ATSLIB/libats/sllist

This package contains a variety of common functions for creating/freeing and manipulating singly-linked linear lists.

The type for a singly-linked linear list containing N elements of type T is denoted by sllist(T, N), where T can be linear and N indicates that there are N elements in the list. Note that the type constructor sllist is co-variant in its first argument, that is, sllist(T1, N) is a subtype of sllist(T2, N) if T1 is a subtype of T2. The low-level representation for sllist is the same as that for a standard singly-linked list in C, and it is fairly straightforward to implement functions in C that can directly manipulate singly-linked linear lists in ATS and vice versa.


  • sllist
  • sllist_vtype
  • lemma_sllist_param
  • sllist_nil
  • sllist_free_nil
  • sllist_sing
  • sllist_cons
  • sllist_uncons
  • sllist_snoc
  • sllist_unsnoc
  • sllist_is_nil
  • sllist_is_cons
  • sllist_length
  • sllist_get_elt
  • sllist_set_elt
  • sllist_getref_elt
  • sllist_getref_next
  • sllist_get_elt_at
  • sllist_set_elt_at
  • sllist_getref_elt_at
  • sllist_insert_at
  • sllist_takeout_at
  • sllist_append
  • sllist_reverse
  • sllist_free
  • sllist_freelin$clear
  • sllist_freelin
  • sllist_map
  • sllist_map$fopr
  • sllist_foreach
  • sllist_foreach_env
  • sllist_foreach$cont
  • sllist_foreach$fwork
  • mytkind
  • g2node0
  • g2node1
  • sllist_cons_ngc
  • sllist_uncons_ngc
  • sllist_snoc_ngc
  • sllist_unsnoc_ngc
  • Overloaded Symbols
  • iseqz
  • isneqz
  • []
  • fprint

  • sllist

    Synopsis

    stadef sllist = sllist_vtype // HX: shorthand

    sllist_vtype

    Synopsis

    absvtype
    sllist_vtype (a:viewt@ype+, n:int) = ptr

    lemma_sllist_param

    Synopsis

    praxi
    lemma_sllist_param {a:vt0p}
      {n:int} (xs: !sllist (INV(a), n)): [n >= 0] void

    sllist_nil

    Synopsis

    fun{}
    sllist_nil {a:vt0p} ():<> sllist (a, 0)

    sllist_free_nil

    Synopsis

    praxi
    sllist_free_nil
      {a:vt0p} (xs: sllist (INV(a), 0)): void

    sllist_sing

    Synopsis

    fun{a:vt0p}
    sllist_sing (x: a):<!wrt> sllist (a, 1)

    sllist_cons

    Synopsis

    fun{a:vt0p}
    sllist_cons{n:int}
      (x: a, xs: sllist (INV(a), n)):<!wrt> sllist (a, n+1)

    sllist_uncons

    Synopsis

    fun{a:vt0p}
    sllist_uncons{n:int | n > 0}
      (xs: &sllist (INV(a), n) >> sllist (a, n-1)):<!wrt> (a)

    sllist_snoc

    Synopsis

    fun{a:vt0p}
    sllist_snoc{n:int}
      (xs: sllist (INV(a), n), x: a):<!wrt> sllist (a, n+1)

    sllist_unsnoc

    Synopsis

    fun{a:vt0p}
    sllist_unsnoc{n:int | n > 0}
      (xs: &sllist (INV(a), n) >> sllist (a, n-1)):<!wrt> (a)

    sllist_is_nil

    Synopsis

    fun{
    } sllist_is_nil
      {a:vt0p}{n:int} (xs: !sllist (INV(a), n)):<> bool (n==0)

    sllist_is_cons

    Synopsis

    fun{
    } sllist_is_cons
      {a:vt0p}{n:int} (xs: !sllist (INV(a), n)):<> bool (n > 0)

    sllist_length

    Synopsis

    fun{a:vt0p}
    sllist_length
      {n:int} (xs: !sllist (INV(a), n)):<> int (n)

    sllist_get_elt

    Synopsis

    fun{a:t0p}
    sllist_get_elt (xs: !Sllist1 (INV(a))): (a)

    sllist_set_elt

    Synopsis

    fun{a:t0p}
    sllist_set_elt (xs: !Sllist1 (INV(a)), x0: a): void

    sllist_getref_elt

    Synopsis

    fun{a:vt0p}
    sllist_getref_elt (xs: !Sllist1 (INV(a))):<> cPtr1 (a)

    sllist_getref_next

    Synopsis

    fun{a:vt0p}
    sllist_getref_next (xs: !Sllist1 (INV(a))):<> Ptr1

    sllist_get_elt_at

    Synopsis

    fun{a:t0p}
    sllist_get_elt_at {n:int}
      (xs: !sllist (INV(a), n), i: natLt(n)):<> (a)

    sllist_set_elt_at

    Synopsis

    fun{a:t0p}
    sllist_set_elt_at {n:int}
      (xs: !sllist (INV(a), n), i: natLt(n), x0: a):<!wrt> void

    sllist_getref_elt_at

    Synopsis

    fun{a:vt0p}
    sllist_getref_elt_at {n:int}
      (xs: !sllist (INV(a), n), i: natLt(n)):<> cPtr1 (a)

    sllist_insert_at

    Synopsis

    fun{a:vt0p}
    sllist_insert_at {n:int}
      (xs: sllist (INV(a), n), i: natLte(n), x0: a):<!wrt> sllist (a, n+1)

    sllist_takeout_at

    Synopsis

    fun{a:vt0p}
    sllist_takeout_at {n:int}
      (xs: &sllist (INV(a), n) >> sllist (a, n-1), i: natLt(n)):<!wrt> (a)

    sllist_append

    Synopsis

    fun{a:vt0p}
    sllist_append
      {n1,n2:int} (
      xs1: sllist (INV(a), n1), xs2: sllist (a, n2)
    ) :<!wrt> sllist (a, n1+n2) // end of [sllist_append]

    sllist_reverse

    Synopsis

    fun{a:vt0p}
    sllist_reverse
      {n:int} (xs: sllist (INV(a), n)):<!wrt> sllist (a, n)

    sllist_free

    Synopsis

    fun{a:t0p}
    sllist_free (xs: Sllist (INV(a))):<!wrt> void

    sllist_freelin$clear

    Synopsis

    fun{a:vt0p}
    sllist_freelin$clear (x: &a >> a?):<!wrt> void

    sllist_freelin

    Synopsis

    fun{a:vt0p}
    sllist_freelin (xs: Sllist (INV(a))):<!wrt> void

    sllist_map

    Synopsis

    fun{
    a:vt0p}{b:vt0p
    } sllist_map {n:int} (xs: !sllist (a, n)): sllist (b, n)

    sllist_map$fopr

    Synopsis

    fun{
    a:vt0p}{b:vt0p
    } sllist_map$fopr (x: &a): b

    sllist_foreach

    Synopsis

    fun{a:vt0p}
    sllist_foreach (xs: !Sllist (INV(a))): void

    sllist_foreach_env

    Synopsis

    fun{
    a:vt0p}{env:vt0p
    } sllist_foreach_env
      (xs: !Sllist (INV(a)), env: &env >> _): void

    sllist_foreach$cont

    Synopsis

    fun{
    a:vt0p}{env:vt0p
    } sllist_foreach$cont (x: &a, env: &env): bool

    sllist_foreach$fwork

    Synopsis

    fun{
    a:vt0p}{env:vt0p
    } sllist_foreach$fwork (x: &a, env: &env >> _): void

    mytkind

    Synopsis

    stadef mytkind = $extkind"libats_sllist"

    g2node0

    Synopsis

    typedef g2node0 (a:vt0p) = gnode0 (mytkind, a)

    g2node1

    Synopsis

    typedef g2node1 (a:vt0p) = gnode1 (mytkind, a)

    sllist_cons_ngc

    Synopsis

    fun{a:vt0p}
    sllist_cons_ngc{n:int}
      (nx: g2node1(a), xs: sllist(INV(a), n)):<!wrt> sllist (a, n+1)

    sllist_uncons_ngc

    Synopsis

    fun{a:vt0p}
    sllist_uncons_ngc{n:pos}
      (xs: &sllist (INV(a), n) >> sllist (a, n-1)):<!wrt> g2node1 (a)

    sllist_snoc_ngc

    Synopsis

    fun{a:vt0p}
    sllist_snoc_ngc{n:int}
      (xs: sllist(INV(a), n), nx: g2node1(a)):<!wrt> sllist (a, n+1)

    sllist_unsnoc_ngc

    Synopsis

    fun{a:vt0p}
    sllist_unsnoc_ngc{n:pos}
      (xs: &sllist (INV(a), n) >> sllist (a, n-1)):<!wrt> g2node1 (a)

    Overloaded Symbols


    iseqz

    Synopsis

    overload iseqz with sllist_is_nil

    isneqz

    Synopsis

    overload isneqz with sllist_is_cons

    []

    Synopsis

    overload [] with sllist_get_elt_at
    overload [] with sllist_set_elt_at

    fprint

    Synopsis

    overload fprint with fprint_sllist

    This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. SourceForge.net Logo