Post Reply 
to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
03-12-2018, 07:47 PM
Post: #1
to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
Hello,
Does somebody know how to change list to a set. I am trying to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4], but the program when it comes to EXPR("%{1,2,3,3,4%}") gives me "Error: Syntax Error". When I do not use EXPR I get "%{1,2,3,3,4%}" and outside the prgm. when I use EXPR("%{1,2,3,3,4%}") I get the set [1,2,3,4]. The problem is; how to get the program to return the set [1,2,3,4] instead giving me "Error: Syntax Error" when using EXPR.

Thank you,
John P
Find all posts by this user
Quote this message in a reply
03-12-2018, 09:44 PM
Post: #2
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
EXPR is a Home command
To interpret CAS functions use CAS (...)

CAS("%{1,2,3,3,4%}") → [1,2,3,4]

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-12-2018, 10:01 PM (This post was last modified: 03-12-2018 10:43 PM by compsystems.)
Post: #3
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
expr (lowercase) is a CAS command for CAS environment #cas ... #end

expr("%{1,2,3,3,4%}") returns
[1,2,3,4] (History) =(.
returns set[1,2,3,4] =) (entryline or textbook flag: off)

expr("%{ a, a, b, c, c, d, ee, ee, ee,f %}") returns
[a,b,c,d,ee,f] (History) =(
returns
set[a,b,c,d,ee,f] =) (entryline or textbook flag: off)

For [hp-prime team]
I think that the history should be conversed the prefix SET[], to differentiate it from arrays, lists, vectors , tables, etc

expr("%{ a, a, b, c, c, d, ee, ee, ee,f %}") → set[a,b,c,d,ee,f]
Find all posts by this user
Quote this message in a reply
03-12-2018, 10:20 PM
Post: #4
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
(03-12-2018 09:44 PM)Carlos295pz Wrote:  EXPR is a Home command
To interpret CAS functions use CAS (...)

CAS("%{1,2,3,3,4%}") → [1,2,3,4]


Thanks Carlos295pz.
It works now but I had to use, in the prgm. body, CAS(CAS(l(1))) where l(1)="%{1,2,3,3,4%}". Why CAS inside the CAS?

Cheers,
Find all posts by this user
Quote this message in a reply
03-12-2018, 10:26 PM
Post: #5
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
(03-12-2018 10:01 PM)compsystems Wrote:  expr is a CAS command =)

expr("%{1,2,3,3,4%}") returns
[1,2,3,4] (History) =(.
returns set[1,2,3,4] =) (entryline or textbook flag: off)

expr("%{ a, a, b, c, c, d, ee, ee, ee,f %}") returns
[a,b,c,d,ee,f] (History) =(
returns
set[a,b,c,d,ee,f] =) (entryline or textbook flag: off)

For [hp-prime team]
I think that the history should be conversed the prefix SET[], to differentiate it from arrays, lists, vectors , tables, etc

expr("%{ a, a, b, c, c, d, ee, ee, ee,f %}") → set[a,b,c,d,ee,f]

Thanks compsystems,
If I understand your post correctly you did the EXPR i the history of CAS. I need it to work inside the body of a program. It works for now, see the response to Carlos295pz above.

Cheers
Find all posts by this user
Quote this message in a reply
03-12-2018, 10:41 PM (This post was last modified: 03-12-2018 10:43 PM by compsystems.)
Post: #6
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
PHP Code:
EXPORT exprprg1()
BEGIN
return expr("%{ a, a, b, c, c, d, ee, ee, ee,f %}");
END

exprprg1() returns "Error: Syntax Error" =(

another solution is to work on the CAS environment, you avoid being added CAS( )

PHP Code:
#cas
exprprg2():=
BEGIN
  
return expr("%{ a, a, b, c, c, d, ee, ee, ee,f %}");
END;
#end 

exprprg2() returns set[a,b,c,d,ee,f]
Find all posts by this user
Quote this message in a reply
03-12-2018, 10:45 PM
Post: #7
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
(03-12-2018 10:20 PM)John P Wrote:  Thanks Carlos295pz.
It works now but I had to use, in the prgm. body, CAS(CAS(l(1))) where l(1)="%{1,2,3,3,4%}". Why CAS inside the CAS?

Cheers,

There is a topic of Home/CAS interaction.

Only with data

CAS("%{1,2,3,3,4%}") → [1,2,3,4] //OK
CAS("%{1,2,3,"+"3,4%}") → "%{1,2,3,3,4%}" //You need to send the pure chain, not an operation that loses the first evaluation to the chain

CAS(EVAL("%{1,2,3,"+"3,4%}")) → [1,2,3,4] //OK, string was created before being sent as a parameter


With variables

LOCAL lr="%{1,2,3,3,4%}",ls={"%{1,2,3,3,4%}"};
CAS(lr) → "%{1,2,3,3,4%}"
CAS(ls(1)) → "%{1,2,3,3,4%}"
CAS(EVAL(lr)) → [1,2,3,4] //OK, string extracted from lr before the parameter pass
CAS(EVAL(ls(1))) → [1,2,3,4] //OK, string extracted from ls(1) before the parameter pass

I have written about Home/CAS Interaction, but I can only create it in Spanish.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-12-2018, 10:49 PM
Post: #8
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
CAS(CAS(...)) may look like CAS(EVAL(...)), but I think I have seen some differences that could be considered as unexpected behaviors, so I advise using CAS(EVAL()), since the implementation was designed so that EVAL controls the passage of parameters to CAS, or that is what I understand.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-15-2018, 12:37 PM
Post: #9
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
Buenos dias Carlos,

No hablo español, pero con google traduzco tus textos.
Su trabajo es importante para todos nosotros, ya que HP no lo ha estado haciendo desde 2013.
Tengo 83 años, pero el cerebro todavía está allí (¡no de salud, qué mal!).
Gracias amigo. (un ejemplo de lo que hago).


Attached File(s) Thumbnail(s)
   

Gérard.
Find all posts by this user
Quote this message in a reply
03-15-2018, 01:11 PM (This post was last modified: 03-15-2018 01:11 PM by Carlos295pz.)
Post: #10
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
Si google no existiera tampoco estaría aquí xD, es un gusto saber que incluso los que no hablan mi idioma puedan aprovechar lo que publico, sinceramente son pocos los que lo leen pero veo que esos pocos son personas realmente interesadas y esa es mi principal meta.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
03-15-2018, 09:40 PM
Post: #11
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
The CAS() command is intended to provide users with access to the CAS environment as well as the CAS commands. It is, however, a "Home" command which means the "Home" environment rules are applied. Generally speaking, this means that all referenced variables were passed as resolved values. For example, if x:=2 and we subsequently called a routine using: MYPROG(x), then 2 is passed in place of x. This method, however, caused problems for symbolic computations in which it is sometimes necessary to pass arguments unevaluated.

In much older firmwares, the CAS() command would always resolve all variables first before passing control over to the CAS environment. In the newer firmwares, all variables passed to CAS() are left as-is (to be resolved from the CAS environment). In order to pass resolved values, we use EVAL().

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
03-16-2018, 08:30 PM (This post was last modified: 03-16-2018 08:33 PM by ggauny@live.fr.)
Post: #12
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
Hola Carlos !

A tranlate I try to do, surely not very good but it is good for me enough.
It take me about 3 hours with google.

Be sure your work is in my french friends to study.

Thanks.


Attached File(s)
.pdf  Nouveau document RTF2.pdf (Size: 291.03 KB / Downloads: 31)

Gérard.
Find all posts by this user
Quote this message in a reply
03-18-2018, 11:29 AM
Post: #13
RE: to get a program to return EXPR("%{1,2,3,3,4%}") as the set [1,2,3,4]
There is a CAS document here that is very good. It's not completely up to date, but has most of it described.
https://www-fourier.ujf-grenoble.fr/~par...me_cas.pdf

There are also some references to CAS vs HOME here in the main PRIME page, under Programming...
http://wiki4hp.com/doku.php?id=prime:start
Find all posts by this user
Quote this message in a reply
Post Reply 




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