Parsing expressions
09-15-2015, 06:11 AM
Post: #1
 xset Junior Member Posts: 46 Joined: Sep 2015
Parsing expressions
Hello

I wanted to explode expression like X^2 + 5 to the list of {operation,firstOP,secondOP}, i found i can do it in CAS window with "at" special syntax like 'X^2+5'[1 +-].

It rewrites it as at('X^2+5',0) and gives answer _x -> _x (looks like lambda).
'X^2+5'[2 +-] gives x^2
'X^2+5'[3 +-] gives 5

There is no really 'at' function and this code does not work in program.

So, question is: how to parse expressions ? If there some command like OBJ-> from 50g ?

Many many thanks anyway!
XSet
09-15-2015, 07:20 AM
Post: #2
 Didier Lachieze Senior Member Posts: 1,233 Joined: Dec 2013
RE: Parsing expressions
In CAS mode you can use part():

The following CAS program could be a starting point for what you want:

Code:
#cas
OBJ(f):=
BEGIN
LOCAL k,l;
l:={};
FOR k FROM 0 TO part(f) DO
l:=CONCAT(l,part(f,k));
END;
return l;
END;
#end

09-15-2015, 07:27 AM (This post was last modified: 09-15-2015 07:42 AM by xset.)
Post: #3
 xset Junior Member Posts: 46 Joined: Sep 2015
RE: Parsing expressions
(09-15-2015 07:20 AM)Didier Lachieze Wrote:  In CAS mode you can use part():

OMG! What a beautiful syntax, kinda functional!
Thank you! You are Wizard !
09-26-2015, 05:44 PM
Post: #4
 ji3m Member Posts: 149 Joined: Sep 2015
RE: Parsing expressions
Cmd line works but obj just returns 0.

on android prime emulator.

I work with android Prime only for now on my
Galaxy Tab Pro/Note 2
09-26-2015, 06:55 PM
Post: #5
 Tim Wessman Senior Member Posts: 2,239 Joined: Dec 2013
RE: Parsing expressions
(09-26-2015 05:44 PM)ji3m Wrote:  Cmd line works but obj just returns 0.

on android prime emulator.

The android emu is basically equivalent at this moment to the version from dec 2014. The "part" command was added in 2015 I believe.

TW

Although I work for the HP calculator group, the views and opinions I post here are my own.
09-27-2015, 07:42 AM
Post: #6
 xset Junior Member Posts: 46 Joined: Sep 2015
RE: Parsing expressions
Thanks GOD i did not buy Android version
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)