The command signatures for lappend, linsert, and lreplace are presented in Lesson 15 of the tutorial ("Adding & Deleting members of a list") as follows.
lappend listName ?arg1 arg2 ... argn?
linsert listName index arg1 ?arg2 ... argn?
lreplace listName first last ?arg1 ... argn?
The latter should read like this instead.
linsert list index arg1 ?arg2 ... argn?
lreplace list first last ?arg1 ... argn?
According to the tutorial, the following interactive session should set `otherlist` to `{{one} {oneandahalf} {two} {three} {four}}`, return `two` from the corresponding `lindex` command, set `replacementlist` to {{one} {two} {tres} {cuatro}}`, and return `cuatro` from the corresponding `lindex` command.
% set mylist [list one two three]
one two three
% lappend mylist four
one two three four
% lindex $mylist 3
four
% set otherlist [linsert mylist 1 oneandahalf]
mylist oneandahalf
% lindex $otherlist 2
% set replacementlist [lreplace mylist 2 3 tres cuatro]
mylist tres cuatro
% lindex $replacementlist 3
%
|