2.14 table
On this page:
2.14.1 Tables
make-table
get
put!
add-to-list!
adjoin-to-list!
2.14.2 AList tables
lookup
2.14.3 PList tables
default-lookup
table-of

2.14 table🔗

 (require sicm/general/table) package: rktsicm

2.14.1 Tables🔗

procedure

(make-table name assoc)  table

  name : any/c
  assoc : (-> any/c (listof (pair? any/c any/c)) (or/c #f (pair? any/c any/c)))
Create an empty (multidimensional) table. A table is defined as an object-like function.

procedure

(get table keys ...)  any/c

  table : table
  keys : any/c

procedure

(put! table val keys ...)  void

  table : table
  val : any/c
  keys : any/c

procedure

(add-to-list! obj table keys ...)  any/c

  obj : any/c
  table : table
  keys : any/c

procedure

(adjoin-to-list! obj table keys ...)  any/c

  obj : any/c
  table : table
  keys : any/c
Retrieve and put objects in the table.

2.14.2 AList tables🔗

procedure

(lookup key table)  any/c

  key : any/c
  table : (listof (list any/c any/c))
Traverse the association-list table returning the val from the (list key val) item that has eq? key

2.14.3 PList tables🔗

procedure

(default-lookup key default table)  any/c

  key : any/c
  default : any/c
  table : (listof any/c)
Traverse the the property-list table, which is a list where the even-numbered items are keys, and odd-numbered items are the values. For the first item that is eq? to the key, return the next item in the list. If no corresponding item is found, the default argument is returned.

procedure

(table-of same? keys vals)  (-> any/c any/c)

  same? : (-> any/c any/c any/c)
  keys : (listof any/c)
  vals : (listof any/c)
From a list of keys and a list of vals generate a procedure that takes a key and gives the corresponding val. The vals list should be at least as long as the keys list. The first item in the keys list that is the same according to same? will give the corresponding item from the vals list.