On Tuesday 23 September 2008 07:36:37 am W F wrote:
Thanks for the comments, I am sure they will help. I'll put
them in some kind of TODO list.
> 1*2+3*4 is the same as 1 2 + 3 4 (the space is the same as multiplcation)
I spent some time trying to get the parser to understand that, but I gave up
and moved on. Maybe moving to a different parser would help, or just more
experience.
> Much code is written in this shorthand method.
I was guessing that is the case. Since, I am most concerned at
first with translating common code correctly, this needs
to be fixed.
> For example (example 1):
>
> v = {1, 2, 0, 3, 4, 0}
> {1, 2, 0, 3, 4, 0}
>
> v1 = MapAt[0 &, v, Position[v, 0] - 1]
> {1, 0, 0, 3, 0, 0}
>
> v2 = Select[v1, # != 0 &]
> {1, 3}
>
I'm not sure, but I think those two examples are not too
difficult given what I have already implemented. MapAt
should be pretty easy. For Select or Postion, I might have
to learn to control evaluation with Maxima, which I have
tried quite a bit, but have not been able to do. But, maybe
thats not necessary.
> Example 2: (same as example 1 - but different code)
> v = {1, 2, 0, 3, 4, 0}
> {1, 2, 0, 3, 4, 0}
>
> v //. {{a___, _, 0, b___} -> {a, b}, {0, b___} -> {b}}
> {1, 3}
I can get infix notation, eg //. and -> to work for other
things like Map and Apply, but it slows the parser that I
am using so much that it can't be used. Maybe moving
parser rules around would help, but that would ruin precedence and
would have to be post-processed. I don't know yet how
difficult the patterns and so forth are.
Thanks for the references as well.
John