I've found a different behavior of the function "contents" in HOME and CAS, in the following situation:
L1:={"A","B"}
In CAS
contains(L1,"A") -> 1
contains(L1,"B") -> 2
In HOME
contains(L1,"A") -> 0 !!!
contains(L1,"B") -> 0 !!!
its name is in lowercase, so I think it should be only a CAS command (not Home)...
(01-02-2018 03:18 PM)salvomic Wrote: [ -> ]its name is in lowercase, so I think it should be only a CAS command (not Home)...
Agreed, but when L1 is filled with numbers instead of strings, it works correctly both in CAS and HOME.
The lower case [CAS] command can work the same way in [Home] if you provide a CAS wrapper:
[CAS]
contains(L1,"A"); ==> 1
[Home]
CAS(contains(L1,"A")); ==> 1
Ok, I realize that the safe way to execute a CAS function in HOME is to use the structure CAS(CAS_function).
What still bothers me is that you can use the CAS function directly in HOME and, depending on the arguments, get correct or incorrect results. As I said before, when L1 contains numbers instead of strings "contains" works correctly both in HOME and CAS.
(01-02-2018 03:29 PM)DrD Wrote: [ -> ]The lower case [CAS] command can work the same way in [Home] if you provide a CAS wrapper:
[CAS]
contains(L1,"A"); ==> 1
[Home]
CAS(contains(L1,"A")); ==> 1
How does it work in RPN mode?
Hello,
home contains(L1, "A") will cause A to be parsed as a CAS command line before the switch to CAS mode and the execution of contains. Assuming that the var A contains 0, what you execute is: contains(L1,0).
CAS(contains(L1,"A")) will not cause a parse of the string.
Subtelties of HOME/CAS interraction :-)
Cyrille
(01-02-2018 06:32 PM)Voldemar Wrote: [ -> ] (01-02-2018 03:29 PM)DrD Wrote: [ -> ][Home]
CAS(contains(L1,"A")); ==> 1
How does it work in RPN mode?
'contains(L1,"A")' Enter
CAS(1) Enter
It is as indicated by Cyrille, it is due to the topic of Home/CAS interaction, since strings are interpreted by using CAS commands such as contains, head,
solve, etc. (similar post
http://www.hpmuseum.org/forum/thread-8149.html)
It can be said that all CAS functions (~ lowercase commands) will present this interpretation of a string data. This article
Home/CAS-Spanish may be useful.
Correct use under this consideration:
CAS(contains(L1,"A"))
contains(L1,("A"))
contains(L1,'"A"')
contains(L1,"A"+"")
LOCAL Strg="A"
contains(L1,Strg)