ATSLIB/libats/funralist_nested

This package implements random-access lists based on an interesting structure due to Chris Okasaki. Unlike Okasaki's original formulation, which involves a nested datatype, the formulation of the structure in ATS makes only use of regular datatypes. This package is largely for educational purpose, demonstrating a convincing case of employing dependent types in practical programming.
  • ralist
  • ralist_type
  • Ralist
  • lemma_ralist_param
  • funralist_nil
  • funralist_cons
  • funralist_uncons
  • funralist_is_nil
  • funralist_is_cons
  • funralist_length
  • funralist_head
  • funralist_tail
  • funralist_get_at
  • funralist_lookup
  • funralist_set_at
  • funralist_update
  • funralist_foreach$cont
  • funralist_foreach$fwork
  • funralist_foreach
  • funralist_foreach_env
  • funralist_listize

  • ralist

    Synopsis

    stadef ralist = ralist_type
    typedef ralist (a:t0p) = [n:int] ralist (a, n)

    ralist_type

    Synopsis

    abstype
    ralist_type (a:t@ype+, n:int) = ptr

    Ralist

    Synopsis

    typedef Ralist (a:t0p) = [n:int] ralist (a, n)

    lemma_ralist_param

    Synopsis

    prfun lemma_ralist_param
      {a:t0p}{n:int} (xs: ralist (INV(a), n)): [n >= 0] void

    funralist_nil

    Synopsis

    fun{}
    funralist_nil{a:t0p}():<> ralist (a, 0)

    Description

    This function forms an empty list.

    funralist_cons

    Synopsis

    fun{a:t0p}
    funralist_cons{n:int}
      (x: a, xs: ralist (INV(a), n)):<> ralist (a, n+1)

    Description

    Given x and xs, this function forms a list whose head and tail are x ans xs, respectively.

    funralist_uncons

    Synopsis

    fun{a:t0p}
    funralist_uncons{n:pos}
      (xs: &ralist (INV(a), n) >> ralist (a, n-1)):<!wrt> a

    Description

    Given a non-empty list, this function returns the head of the list while storing the tail of the list into its (call-by-reference) argument.

    funralist_is_nil

    Synopsis

    fun{
    } funralist_is_nil
      {a:t0p}{n:int} (xs: ralist (INV(a), n)):<> bool(n==0)

    Description

    This function tests whether a given list is empty.

    funralist_is_cons

    Synopsis

    fun{
    } funralist_is_cons
      {a:t0p}{n:int} (xs: ralist (INV(a), n)):<> bool(n > 0)

    Description

    This function tests whether a given list is non-empty.

    funralist_length

    Synopsis

    fun{
    } funralist_length
      {a:t0p}{n:nat} (xs: ralist (INV(a), n)):<> int (n)

    Description

    This function returns the length of a given list. Its time-complexity is O(log(n)).

    funralist_head

    Synopsis

    fun{a:t0p}
    funralist_head
      {n:pos} (xs: ralist (INV(a), n)):<> a

    Description

    This function returns the head of a given non-empty list.

    funralist_tail

    Synopsis

    fun{a:t0p}
    funralist_tail
      {n:pos} (xs: ralist (INV(a), n)):<> ralist (a, n-1)

    Description

    This function returns the tail of a given non-empty list.

    funralist_get_at

    Synopsis

    fun{a:t0p}
    funralist_get_at{n:int}
      (xs: ralist (INV(a), n), i: natLt n):<> a

    Description

    Given a list xs of length n and a natural number i less than n, this function returns xs[i], that is, element i in the list xs. The time-complexity of the function is O(log(i)).

    funralist_lookup

    Synopsis

    fun{a:t0p}
    funralist_lookup{n:int}
      (xs: ralist (INV(a), n), i: natLt n):<> a

    Description

    This function is an alias of funralist_get_at.

    funralist_set_at

    Synopsis

    fun{a:t0p}
    funralist_set_at{n:int}
    (
      xs: ralist (INV(a), n), i: natLt n, x0: a
    ) :<> ralist (a, n) // endfun

    Description

    Given a list xs of length n, a natural number i less than n and an element x0, this function returns a list obtained from replacing element i in xs with x0. The time-complexity of the function is O(log(i)).

    funralist_update

    Synopsis

    fun{a:t0p}
    funralist_update{n:int}
    (
      xs: ralist (INV(a), n), i: natLt n, x0: a
    ) :<> ralist (a, n) // endfun

    Description

    This function is an alias of funralist_set_at.

    funralist_foreach$cont

    Synopsis

    Synopsis for [funralist_foreach$cont] is unavailable.

    funralist_foreach$fwork

    Synopsis

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

    funralist_foreach

    Synopsis

    fun{a:t0p}
    funralist_foreach (xs: Ralist (INV(a))): void

    funralist_foreach_env

    Synopsis

    fun{a:t0p}{env:vt0p}
    funralist_foreach_env (xs: Ralist (INV(a)), env: &(env)>>env): void

    funralist_listize

    Synopsis

    fun{a:t0p}
    funralist_listize
      {n:int} (xs: ralist (INV(a), n)):<!wrt> list_vt (a, n)

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