|
[Date Index]
[Thread Index]
[Author Index]
Re: pattern bugs and comment on intuitive syntax for the
- To: mathgroup at smc.vnet.net
- Subject: [mg115157] Re: pattern bugs and comment on intuitive syntax for the
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Mon, 3 Jan 2011 03:54:49 -0500 (EST)
This bothers me:
x /. x + c___ : 0 -> aha[c]
x + y /. x + y + c___ : 0 -> aha[c]
aha[0]
aha[]
I'm accustomed to guessing what works or just trying random things until
something does... but it gets tiring.
Bobby
On Sun, 02 Jan 2011 03:56:08 -0600, Richard Fateman
<fateman at cs.berkeley.edu> wrote:
>
>
> 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[2] (* 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.
>
>
>
>
--
DrMajorBob at yahoo.com
Prev by Date:
Re: How to change the directory for the docs?
Next by Date:
Re: pattern bugs and comment on intuitive syntax for the
Previous by thread:
Re: NDSolve, three 2-d order ODE, 6 initial conditions
Next by thread:
Re: pattern bugs and comment on intuitive syntax for the
|