{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 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 7 "Advice:" }{TEXT -1 21 " Last name evaluation" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 204 "Normally, when you enter an expression it is evaluated completely. If your expression contain s a variable that has a value, the variable is replaced by that value; if it contains a function call such as " }{MPLTEXT 0 21 4 "f(x)" } {TEXT -1 8 ", where " }{MPLTEXT 0 21 1 "f" }{TEXT -1 76 " is a procedu re or function, then this is replaced by the value returned by " } {MPLTEXT 0 21 1 "f" }{TEXT -1 15 " with argument " }{MPLTEXT 0 21 1 "x " }{TEXT -1 586 ". And if those values in turn contain variables or f unction calls, they are also evaluated. Eventually (we hope) Maple ob tains a form that does not require any further evaluation, and this is what it returns to us. However, certain types of object have special evaluation rules. In particular, tables, arrays (including vectors a nd matrices, but not Vectors or Matrices) and procedures use last name evaluation. This means that if the result of one level of evaluation of a name would be a table, array or procedure, then the chain of eva luation stops with that name. For example:" }}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 19 "T:= array([a,b,c]);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"TG-%'vectorG6#7%%\"aG%\"bG%\"cG" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 6 "S:= T;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"SG%\"T G" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 2 "S;" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%\"TG" }}}{PARA 0 "" 0 "" {TEXT -1 24 "In the first sta tement, " }{MPLTEXT 0 21 1 "T" }{TEXT -1 46 " is assigned a value whic h is an array. Then " }{MPLTEXT 0 21 1 "S" }{TEXT -1 23 " is assigned the value " }{MPLTEXT 0 21 1 "T" }{TEXT -1 17 ". Evaluation of " } {MPLTEXT 0 21 1 "T" }{TEXT -1 63 " stops at the name, rather than goin g all the way to the array " }{MPLTEXT 0 21 7 "[1,2,3]" }{TEXT -1 7 ". For " }{MPLTEXT 0 21 1 "S" }{TEXT -1 44 " there is one level of eval uation, yielding " }{MPLTEXT 0 21 1 "T" }{TEXT -1 121 ", but again eva luation stops there. If you want the next level of evaluation, the ta ble or array structure, you can use " }{MPLTEXT 0 21 4 "eval" }{TEXT -1 1 ":" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "eval(S);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'vectorG6#7%%\"aG%\"bG%\"cG" }}}{PARA 0 " " 0 "" {TEXT -1 118 "However, even this is not full evaluation, as the entries of this array were not evaluated. For that you need to map \+ " }{MPLTEXT 0 21 4 "eval" }{TEXT -1 6 " into " }{MPLTEXT 0 21 1 "S" } {TEXT -1 1 ":" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "b:= a: a:= \+ sin(x): x:= Pi:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "eval(S); " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'vectorG6#7%%\"aG%\"bG%\"cG" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "map(eval,S);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'vectorG6#7%\"\"!F'%\"cG" }}}{PARA 0 "" 0 "" {TEXT -1 244 "Last-name evaluation is usually not a problem, and can h ave significant benefits in efficiency by avoiding the copying of larg e tables or arrays. However, there are some points to watch out for. \+ One is that at first glance it may appear that " }{MPLTEXT 0 21 1 "T " }{TEXT -1 42 " has not been assigned a value. Even the " }{MPLTEXT 0 21 8 "whattype" }{TEXT -1 29 " function does not help here:" }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "whattype(T);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%'symbolG" }}}{PARA 0 "" 0 "" {TEXT -1 21 "Instead , you can use " }{MPLTEXT 0 21 8 "assigned" }{TEXT -1 31 ". Of course \+ you could also use " }{MPLTEXT 0 21 7 "eval(T)" }{TEXT -1 1 "." }} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "assigned(T);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%%trueG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "whattype(eval(T));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%&arrayG" }} }{PARA 0 "" 0 "" {TEXT -1 31 "Another common problem is that " } {MPLTEXT 0 21 4 "subs" }{TEXT -1 108 " will not see the table, array o r procedure structure, but only the name. Again, you can fix this by \+ using " }{MPLTEXT 0 21 4 "eval" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "subs(c=4, S);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #%\"TG" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "subs(c=4, eval(S) );" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#-%'vectorG6#7%%\"aG%\"bG\"\"%" } }}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 9 "See also:" }{TEXT -1 1 " " } {HYPERLNK 17 "array" 2 "array" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "assi gned" 2 "assigned" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "eval" 2 "eval" " " }{TEXT -1 2 ", " }{HYPERLNK 17 "procedure" 2 "procedure" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "table" 2 "table" "" }}}{SECT 0 {PARA 0 "" 0 " " {TEXT 26 24 "Maple Advisor Database, " }{TEXT -1 15 " R. Israel 1997 " }}}}{MARK "1 12 0" 211 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }