lassign_array — Assign a list of values to array variables


::rivet::lassign_array ?value_list? ?array_name? ?array_variables?


lassign_array is an utility command inspired by the same Tclx command and with a close resemblance with Tcl's lassign for assigning list elements to variables. lassign_array first argument is a list of values to be assigned to an array that must be given as second argument. The remaining arguments are the array's variable names which will store as values the elements of the list. Variables names don't matching values in the list are given an empty string. Unassigned list elements are returned as a list.

::rivet::lassign_array {1 2 3 4} assigned_array a b c d
parray assigned_array
assigned_array(a) = 1
assigned_array(b) = 2
assigned_array(c) = 3
assigned_array(d) = 4

set rem [::rivet::lassign_array {1 2 3 4 5 6 7} assigned_array a b c d]
puts $rem
5 6 7