{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 "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Couri er" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 0 1 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }1 0 0 0 6 6 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 "" 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 1 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Error" 7 8 1 {CSTYLE "" -1 -1 "" 0 1 255 0 255 1 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 "M aple 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 8 "Advice: " }{TEXT -1 33 "Declaring the type of an argument" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 227 "The use \+ of types in Maple is quite different from what you may find in typical computer languages. In Maple, any value, regardless of type, can alw ays be assigned to any variable. You don't have to declare, for examp le, that " }{MPLTEXT 0 21 1 "x" }{TEXT -1 76 " is an array of a certai n size - you just create the array and assign it to " }{MPLTEXT 0 21 1 "x" }{TEXT -1 477 ". Of course, a function that is designed to oper ate on an array will not work very well if it operates on something th at is not an array. Therefore many functions (whether part of Maple i tself or written by users) check the types of their arguments. If the argument is not of the correct type or types, an error message is pro duced. The simplest way to do this is to declare the allowed types wh en naming the formal parameters: after the name of a formal parameter, insert " }{MPLTEXT 0 21 2 "::" }{TEXT -1 29 " and the type specificat ion. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 37 " Note the difference between this and " }{MPLTEXT 0 21 6 "assume" } {TEXT -1 7 ". The " }{MPLTEXT 0 21 6 "assume" }{TEXT -1 311 " command is used with symbolic variables that are not assigned values, and sim ply tells Maple that it can apply rules that would be appropriate when the variable has certain properties (e.g. is an integer). But it doe s not prevent values that do not have these properties from being assi gned to the variable. " }}}{SECT 0 {PARA 3 "" 0 "" {TEXT 26 9 "Exampl es:" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 97 "f:= proc(x::integer, \+ y::\{list(integer), set(integer)\})\n local t;\n x+add(t,t = \+ y)\n end:" }}}{PARA 0 "" 0 "" {TEXT -1 13 "In this case " }{MPLTEXT 0 21 1 "x" }{TEXT -1 35 " is required to be an integer, and " } {MPLTEXT 0 21 1 "y" }{TEXT -1 56 " must be either a list of integers o r a set of integers." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "f(u, [3,4]);" }}{PARA 8 "" 1 "" {TEXT -1 75 "Error, f expects its 1st argum ent, x, to be of type integer, but received u" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "f(3,5);" }}{PARA 8 "" 1 "" {TEXT -1 97 "Error, f \+ expects its 2nd argument, y, to be of type \{list(integer), set(intege r)\}, but received 5" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "f(3 ,\{4,5\});" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"#7" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "g:= (f::procedure, r::(name = realcons .. r ealcons)) -> evalf(Int(f(op(1,r)),r)):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "g(sin,x=0..Pi);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#$ \"\"#\"\"!" }}}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 10 "See also: " } {HYPERLNK 17 "assume" 2 "assume" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "As sume doesn't affect solve" 2 "Assume_doesn't_affect_solve" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "Error: ... expects its ... argument, ..., to \+ be of type ..., but received ..." 2 "Error:..._expects_its_..._argumen t,_...,_to_be_of_type_...,_but_received_..." "" }{TEXT -1 2 ", " } {HYPERLNK 17 "parameter passing" 2 "parameter" "" }{TEXT -1 2 ", " } {HYPERLNK 17 "procedures" 2 "procedure" "" }{TEXT -1 2 ", " } {HYPERLNK 17 "type" 2 "type" "" }{TEXT -1 2 ", " }{HYPERLNK 17 "typema tch" 2 "typematch" "" }{TEXT -1 1 " " }}}{SECT 0 {PARA 0 "" 0 "" {TEXT 26 22 "Maple Advisor Database" }{TEXT -1 18 " R. Israel, 1997 " }}}}{MARK "3 0 3" 10 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }