Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-11-27
22:48 • Closed ticket [7e9d561a08]: It may be error. plus 7 other changes artifact: 72c88b24f4 user: jan.nijtmans
16:55 • New ticket [7e9d561a08]. artifact: c62bbcafdb user: anonymous

It may be error.

Closed / Invalid7e9d561a08d14855a310d9df3bd364e2ac18d668Created 4 years agoUpdated 4 years ago
Descriptionplain2022-11-27 16:55:33
########################################################
# It may be error.
########################################################
puts "$::tcl_patchLevel\n$::tcl_platform(os); $::tcl_platform(machine);\
 $::tcl_platform(platform); $::tcl_platform(osVersion); $::tcl_platform(wordSize);"
set li { 1 2 3 4 5 }
puts "[expr { [string map [list end [llength $li] ] end+8] } ]"
########################################################
#Output:
8.6.2
Windows NT; intel; windows; 10.0; 4;
5+8
########################################################
# Why not 13?!
########################################################
jan.nijtmanswiki2022-11-27 22:48:01

Well, 8.6.2, that's an old Tcl version!!!!!

I get:

% set li { 1 2 3 4 5 }
 1 2 3 4 5 
% expr { [string map [list end [llength $li] ] end+8] }
5+8

The reason for this is that your 'expr' has only a single argument (everything between the outer '[' and ']'. Therefore the '+' is not seen as an operation.

Works as expected

Log in (anonymous is fine) to add a comment.