[Date Index] [Thread Index] [Author Index]
pattern bugs and comment on intuitive syntax for the New Year
Guess the results. x+3 /. x+c___ -> aha[c] x /. x+c___ -> aha[c] x /. x+c___:0 -> aha[c] compare to x+y+3 /. x+y+c___ -> aha[c] x+y /. x+y+c___ -> aha[c] x+y /. x+y+c___:0 -> aha[c] x+y+a+b /. x+y+c___ :> aha[c] x+y+a+b /. x+y+c___ :> aha[Plus[c]] x+y /. x+y+c___ :> aha[Plus[c]] I think the requirement for the :0 represents a bug. Maybe the need for the Plus, too. The treatment of NullSequences within a Flat operator could be different, leaving an operator around. ............ Another item. really, syntax. define GreaterThan[q_]:= #>q& gt2=GreaterThan (* a function of one argument. is that argument > 2? *) mm[2, 10] /. mm[q_, s_?GreaterThan[q]] :> aha[q, s] doesn't give aha.. mm[2, 10] /. mm[q_, s_?gt2] :> aha[q, s] does give aha this works, though. mm[2, 10] /. mm[q_, s_?(GreaterThan[q])] :> aha[q, s] I love that intuitive syntax. None of that excess parentheses and stuff. (sarcasm) This error would have been much more apparent in Lisp. happy new year.