Post Reply 
Recursive programs in XCAS.
02-12-2017, 04:06 AM (This post was last modified: 02-12-2017 04:07 AM by Han.)
Post: #6
RE: Recursive programs in XCAS.
Just for fun, create the program below. Then in the CAS view, type:

purge(x);
f:=x^2-3*x+4;
CRPN(f);

Recursive Program Example:

Code:
#pragma mode( separator(.,;) integer(h32) )
#cas
CRPN(f):=
begin
  local rpn, op, par, n, j, g;

  rpn:="";
  op:="";
  par:="";
  if (type(f) <> DOM_SYMBOLIC) then
    rpn:=string(f);
    return(rpn);
  end;

  op:=string(f[1]);
  n:=size(op);
  op:=MID(op,2,n-2);
  n:=dim(f) + 1;

  for j from 2 to n do
    g:=f[j];
    if (type(g) <> DOM_SYMBOLIC) then
      par:=string(g);
    else
      par:=CRPN(g);
    end;
    if (j > 2) then rpn:=rpn + " "; end;
    rpn:=rpn + par;
    if ((j > 2) or (n == 2)) then
      rpn:=rpn + " " + op;
    end;
  end;

  return(rpn);
end;
#end

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Recursive programs in XCAS. - John P - 02-12-2017, 12:22 AM
RE: Recursive programs in XCAS. - Han - 02-12-2017, 01:41 AM
RE: Recursive programs in XCAS. - John P - 02-12-2017, 02:08 AM
RE: Recursive programs in XCAS. - John P - 02-12-2017, 02:32 AM
RE: Recursive programs in XCAS. - Han - 02-12-2017, 02:52 AM
RE: Recursive programs in XCAS. - Han - 02-12-2017 04:06 AM
RE: Recursive programs in XCAS. - Han - 03-01-2017, 04:46 AM
RE: Recursive programs in XCAS. - Han - 03-01-2017, 04:49 AM



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