Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-03-16
19:38 • Closed ticket [1905809fff]: lreplace man page description for negative index con... artifact: 2a949cbcbe user: dkf
2008-03-02
19:10 • New ticket [1905809fff]. artifact: 136f2a1769 user: v_f

lreplace man page description for negative index confusing

Closed / Fixed1905809fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-03-02 19:10:32
lreplace man page states:

"If last is less than zero but greater than first, then any specified elements will be prepended  to  the  list."

What happens if last is less than zero and equal to first? My use case is to search the list for an element and then delete it if it exists. Otherwise the list should be unmodified:

% set L {a b c}
a b c
% set i [lsearch $L x]
-1
% lreplace $L $i $i
a b c

This obviously works, but is it guaranteed?
dkf Closed ticket [1905809fff]. [History diff]2008-03-16 19:38:26
Log in (anonymous is fine) to add a comment.