Version 0 of lprepend

Updated 2009-03-02 22:27:26 by LEG

lprepend - insert elements in front of a list

lprepend listVar e ?e ..?

This is not a command included in Tcl. It is useful for implementing queues and stacks. lunshift implements the same functionality, but only for one element.

See also: lpop, lshift and Chart of existing list functionality.


Implementation

proc lprepend {listVar args} {
    upvar 1 $listVar l

    lappend l; # bring l to live.
    set l [K* [concat $args $l] [set l {}]]
}