RosettaCodeData/Task/Deepcopy/Aime/deepcopy.aime

33 lines
804 B
Plaintext

list L1, L2;
# Lists are heterogeneous:
l_append(L1, 3);
l_append(L1, "deep");
# and may contain self references.
# A self references in the last position:
l_link(L1, -1, L1);
# List may also contain mutual references.
# Create a new list in the last position:
l_n_list(L1, -1);
# Add a reference to the top level list to the nested list:
l_link(l_q_list(L1, -1), -1, L1);
# There are no limitations to the deep copy method:
l_copy(L2, L1);
# Modify the string in the original list,
# via the self reference in the 3rd position
l_r_text(l_q_list(L1, 2), 1, "copy");
# Show the string in the two lists:
o_text(l_query(L2, 1));
o_text(l_query(L1, 1));
o_byte('\n');
# And again, via the included self references:
o_text(l_query(l_query(L2, 2), 1));
o_text(l_query(l_query(L1, 2), 1));
o_byte('\n');