Skip to content
Tcl Source Code View Ticket
Login

View Ticket

More list ops

Open1227494fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-06-25 20:17:50
Only one list operation is provided, lappend.
Could add these ones:

dict lindex
dict llength
dict lset
dict lreplace -- but inline like lset
dict lrange

And maybe:
dict lsort -- maybe add an -inline option to sort in place
dkfplain2005-06-26 05:52:18
Logged In: YES 
user_id=79902

the lindex, llength and lrange operations are trivially
composed out of [dict get] and the appropriate list operation.

The other two operations are actually constructable through
the use of the [dict update] command, rather like this:
  proc dict_lset {var key index value} {
     upvar 1 $var d
     dict update d $key theList {
        dict set d $key {}  ;# Performance hack!
        lset theList $index $value
     }
  }

Because of this, this is a low-priority FRQ at best.
Log in (anonymous is fine) to add a comment.