<- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#lists|Lists]] ===== CopyList ===== ^Arguments^Result^Notation^ | a list | a different list | '' L1 -- L2 '' | === Description === Creates a new list with the same contents as the old list. Changes to the new list will not change the old list. However, unlike [[crpl:docs:deepcopylist|DeepCopyList]], lists inside this list will not be copied, so the same lists will be inside both lists. Changing one of these inner lists will affect the same inner lists in the other list. === Examples === ShowTraceLog ClearTraceLog CreateList ->a CreateList ->b CreateList ->c #Stuff lists b and c and a number into a. <-a <-b AppendToList <-a <-c AppendToList <-a 4 AppendToList #Give b and c some contents. <-b 9 AppendToList <-c "hello" AppendToList #Make copies. How many lists do we have? hint:7 <-a CopyList ->a2 <-a DeepCopyList ->a3 #Show that a is not the same as either a2 or a3. <-a "weird" AppendToList #Show that b inside a2 is the same as b inside a. <-a2 0 GetListElement "goo" AppendToList #Show that c inside a3 is not the same as c inside a. <-a3 1 GetListElement "creeper" AppendToList <-a Trace #[[9,"goo"],["hello"],4,"weird"] <-a2 Trace #[[9,"goo"],["hello"],4] <-a3 Trace #[[9],["hello","creeper"],4]