A more flexible facility than <> is the use of ^^
which allows the
contents of one list to be spliced into another at any location, whereas
<> allows only joining lists "end on". For example:
vars list1 = [a b c], list2 = [d e f]; [1 2 ^^list1 3 4 ^^list2 ] => ** [1 2 a b c 3 4 d e f]The same list can be spliced in at several different points:
[ ^^list1 x y z ^^list1] => ** [a b c x y z a b c]It is possible to use an arbitrary Pop-11 expression that evaluates to a list after
^^
provided that it is enclosed in parentheses.
[a set of numbers ^^( [% 1 + 2, 3 + 4, 5 + 6%])] => ** [a set of numbers 3 7 11]Compare the use of
^
without the embedded list brackets and % symbols:
[a set of numbers ^( 1 + 2, 3 + 4, 5 + 6)] => ** [a set of numbers 3 7 11]So inside a list, the form
^^( [% <Pop-11 instructions> %] )is exactly equivalent to
^( <Pop-11 instructions> )except that the former wastefully creates a temporary list and then discards it after its contents have been spliced into the final list. so it is worth using
^^
only when a list already exists, although it may
be necessary to use a complex expression to access it, e.g.
vars list = [a [b c d] e f]; [another list with : ^^(list(2)) ] => ** [another list with : b c d]Here list(2) was used to get at the second element of list.
If the above had used ^
instead of ^^
, the result would have been:
[another list with: ^(list(2)) ] => ** [another list with : [b c d]]In other words
^^
removes a layer of list brackets that ^
will leave.
The prefix "^^
" can be thought of as meaning "remove the list brackets".
If the value is not a list, an error will result.
vars x = 99; [a b c ^^x] => ;;; MISHAP - LIST NEEDED ;;; INVOLVING: 99