{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" 0 21 "" 0 1 0 0 0 1 0 0 0 0 2 0 0 0 0 1 }{CSTYLE "Help Head ing" -1 26 "" 1 14 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Error" -1 8 1 {CSTYLE "" -1 -1 "Courier " 1 10 255 0 255 1 2 2 2 2 2 1 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 } {PSTYLE "Maple Output" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Outpu t" -1 12 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 } 1 3 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {SECT 0 {PARA 0 "" 0 "" {TEXT 26 6 "Error:" }{TEXT -1 45 " as signing to a long list, please use arrays" }}{PARA 0 "" 0 "" {TEXT -1 86 "Maple allows you to change a list by assigning a new value to one \+ of its components. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "L:= \+ [a,b,c,d,e]: L[2]:= B; L;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>&%\"LG6# \"\"#%\"BG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#7'%\"aG%\"BG%\"cG%\"dG% \"eG" }}}{PARA 0 "" 0 "" {TEXT -1 113 "However, it only works for list s of length 100 or less. Trying it for a longer list produces this er ror message." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "L:= [seq(i,i =1..101)]:\nL[2]:= 3;" }}{PARA 8 "" 1 "" {TEXT -1 51 "Error, assigning to a long list, please use arrays\n" }}}{PARA 0 "" 0 "" {TEXT -1 78 " Nevertheless, the same effect can be obtained for a list of any length , using " }{MPLTEXT 0 21 6 "subsop" }{TEXT -1 1 ":" }}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 17 "L:=subsop(2=3,L);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%\"LG7aq\"\"\"\"\"$F'\"\"%\"\"&\"\"'\"\"(\"\")\"\"*\"# 5\"#6\"#7\"#8\"#9\"#:\"#;\"#<\"#=\"#>\"#?\"#@\"#A\"#B\"#C\"#D\"#E\"#F \"#G\"#H\"#I\"#J\"#K\"#L\"#M\"#N\"#O\"#P\"#Q\"#R\"#S\"#T\"#U\"#V\"#W\" #X\"#Y\"#Z\"#[\"#\\\"#]\"#^\"#_\"#`\"#a\"#b\"#c\"#d\"#e\"#f\"#g\"#h\"# i\"#j\"#k\"#l\"#m\"#n\"#o\"#p\"#q\"#r\"#s\"#t\"#u\"#v\"#w\"#x\"#y\"#z \"#!)\"#\")\"##)\"#$)\"#%)\"#&)\"#')\"#()\"#))\"#*)\"#!*\"#\"*\"##*\"# $*\"#%*\"#&*\"#'*\"#(*\"#)*\"#**\"$+\"\"$,\"" }}}{PARA 0 "" 0 "" {TEXT -1 331 "This is rather inefficient if the list is long, because \+ it requires copying the whole list structure. If you used an array or Array it would be very quick. Nevertheless, if only a few of these o perations are to be done, it may still be preferable to use lists rath er than arrays, because lists can be produced very quickly using " } {MPLTEXT 0 21 3 "seq" }{TEXT -1 115 ". Here is an example, where we c reate a list of 1000000 integers and then replace 100 of them. Timing s were done " }}{PARA 0 "" 0 "" {TEXT -1 56 "under Windows 95 on a 266 -mhz Pentium II with 128Mb RAM." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 169 "restart; t:= time(): L:= [seq(1000000-i,i=1..1000000)]: \npri nt(\"Setup time\",time()-t);\nfor i from 1 to 100 do \n L:= subsop(i^ 2 = 0, L)\nod:\nprint(\"Total time\",time()-t);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$Q+Setup~time6\"$\"%*p#!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$Q+Total~time6\"$\"&\"R(*!\"$" }}}{PARA 0 "" 0 "" {TEXT -1 215 "And here is the equivalent calculation using an array. Changi ng 100 elements of the array is practically instantaneous, but setting up the array in the first place is very time-consuming (an Array woul d be faster)." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 193 "restart; t := time(): L:= array(1..1000000):\nfor i from 1 to 1000000 do L[i]:= 1 000000-i od:\nprint(\"Setup time\",time()-t);\nfor i from 1 to 100 do \+ \n L[i^2] := 0\nod:\nprint(\"Total time\",time()-t);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$Q+Setup~time6\"$\"'D66!\"$" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$Q+Total~time6\"$\"'H66!\"$" }}}}{SECT 0 {PARA 0 "" 0 " " {TEXT 26 9 "See also:" }{TEXT -1 1 " " }{HYPERLNK 17 "array" 2 "arra y" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Array" 2 "Array" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "list" 2 "list" "" }{TEXT -1 2 ", " }{HYPERLNK 17 " seq" 2 "seq" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "subsop" 2 "subsop" "" }}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 22 "Maple Advisor Database" } {TEXT -1 18 " R. Israel, 2000" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {MARK "1 0 10" 0 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }