class19 - PHYS 5900 Class 19 (10/07/2009) Zi-Wei Lin Naming...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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[1]:= ? Symbol Symbol @ " name " D refers to a symbol with the specified name. In[2]:= Head 8 x5, a, abcde, Sin @ x D , x y < Out[2]= 8 Symbol, Symbol, Symbol, Sin, Power < In[3]:= Head : x y , x y , x z y , x y , x † , x + , x * , x ‘ , x > Out[3]= 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[4]:= Pattern @ x, Blank @DD Out[4]= x_ In[5]:= H h @ a D + h @ b, c D + h @ a, a DL * h @ d, e, f D . h @ x_, y_ D-> x ^ y Out[5]= H a a + b c + h @ a DL h @ d, e, f D In[6]:= H h @ a D + h @ b, c D + h @ a, a DL * h @ d, e, f D . h @ x_, x_ D-> x ^ x Out[6]= H a a + h @ a D + h @ b, c DL h @ d, e, f D In[7]:= myfunc @ x_ ^ n_ D : = 8 x, n < In[8]:= Map @ myfunc, 8 3, x, a ^ 4, Sqrt @ 1 + x D<D Out[8]= : myfunc @ 3 D , myfunc @ x D , 8 a, 4 < , : 1 + x, 1 2 >> In[9]:= 8 3, x, a ^ 4, Sqrt @ 1 + x D< . I x_ ^ n_ fi 8 x, n <M Out[9]= : 3, x, 8 a, 4 < , : 1 + x, 1 2 >> In[10]:= 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 .

Page1 / 6

class19 - PHYS 5900 Class 19 (10/07/2009) Zi-Wei Lin Naming...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online