Array concatenation: Difference between revisions
Content added Content deleted
Line 1,926: | Line 1,926: | ||
=={{header|LIL}}== |
=={{header|LIL}}== |
||
LIL uses lists instead of arrays. The builtin '''append''' command could be used as '''append a $b''' |
LIL uses lists instead of arrays. The builtin '''append''' command could be used as '''append a $b'''. That would add the entire list in variable '''b''' as one item to list '''a'''. Below '''quote''' is used to flatten the lists into a single new list of all items. |
||
<lang tcl>## |
<lang tcl>## |
||
Array concatenation in LIL |
Array concatenation in LIL |
||
Line 1,932: | Line 1,933: | ||
set a [list 1 2 3] |
set a [list 1 2 3] |
||
set b [list 4 5 6] |
set b [list 4 5 6] |
||
set c [quote $a $b] |
|||
foreach i $b {append a $i} |
|||
print $a |
|||
print |
print $c |
||
print "[index $c 0] [index $c 3]"</lang> |
|||
{{out}} |
|||
<pre>prompt$ lil arrayConcatenation.lil |
|||
1 2 3 4 5 6 |
|||
1 4</pre> |
|||
=={{header|Limbo}}== |
=={{header|Limbo}}== |