This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: PHYS 5900 Class 19 (10/07/2009) Zi-Wei Lin Naming Patterns Names of patterns must be symbols , i.e., Head[patternName] must return Symbol . 2-dimensional forms can not be pattern names. In:= ? Symbol Symbol @ " name " D refers to a symbol with the specified name. In:= Head 8 x5, a, abcde, Sin @ x D , x y < Out= 8 Symbol, Symbol, Symbol, Sin, Power < In:= Head : x y , x y , x z y , x y , x † , x + , x * , x ‘ , x > Out= 8 Power, Subscript, Power, Underscript , SuperDagger , SuperPlus, SuperStar, OverHat, OverBar < x_ stands for any single expression to be named x on the right-hand-side of a definition or transformation rule; full form is Pattern[ x ,Blank] In:= Pattern @ x, Blank @DD Out= x_ In:= H h @ a D + h @ b, c D + h @ a, a DL * h @ d, e, f D . h @ x_, y_ D-> x ^ y Out= H a a + b c + h @ a DL h @ d, e, f D In:= H h @ a D + h @ b, c D + h @ a, a DL * h @ d, e, f D . h @ x_, x_ D-> x ^ x Out= H a a + h @ a D + h @ b, c DL h @ d, e, f D In:= myfunc @ x_ ^ n_ D : = 8 x, n < In:= Map @ myfunc, 8 3, x, a ^ 4, Sqrt @ 1 + x D<D Out= : myfunc @ 3 D , myfunc @ x D , 8 a, 4 < , : 1 + x, 1 2 >> In:= 8 3, x, a ^ 4, Sqrt @ 1 + x D< . I x_ ^ n_ fi 8 x, n <M Out= : 3, x, 8 a, 4 < , : 1 + x, 1 2 >> In:= Clear @ myfunc D x:pattern stands for any expression matching pattern , and this expression is named...
View Full Document
This note was uploaded on 04/25/2010 for the course PHYS 5900 taught by Professor Lin during the Fall '09 term at East Carolina University .
- Fall '09