Downey_HUff
Downey_HUff

Reputation: 191

lappending a range of list to another list

set mac_list ""
set new_mac_list "1111.1111.1111 2222.2222.2222 3333.3333.3333 4444.4444.4444"
lappend mac_list [lrange new_mac_list $i end]

i value is always 3 at this point in my script the concept is i always want mac_address of new_mac_list list from lindex 3 in my mac_list

it works fine when i have 4 mac address as above in new_mac_list but when new_mac_list has less than 4 mac address i get {} value to my mac_list and when new_mac_list has more than 4 mac address i get whole remaining list elements as a single element in mac_list..

Upvotes: 1

Views: 2350

Answers (1)

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

That's how you append multiple elements (tcl8.5+):

lappend mac_list {*}[lrange $new_mac_list $i end]

Older TCL would require

set mac_list [concat $mac_list [lrange $new_mac_list $i end]]

Upvotes: 4

Related Questions