Post Reply 
head-ache
04-11-2017, 11:07 PM
Post: #2
RE: head-ache
(04-11-2017 10:08 PM)BruceH Wrote:  The 'head' and 'tail' commands don't seem to work consistently on strings in the Home and Cas environments.

[Image: hp_prime_headache.png?psid=1]

Workaround in Home view: use double parentheses.

head("test") --> test (unexpected)
head(("test")) --> "t" (as expected)

tail("test") --> [[]] (unexpected)
tail(("test")) --> "est" (as expected)

The reason that head("test") in Home view yields test instead of "t" is because head is a CAS command, and calling CAS commands from Home with string arguments extracts the contents from the string and passes THAT to CAS as the argument. Therefore head("test") in Home is identical to head(test) in CAS (notice the lack of quotes). Using double parentheses in Home forces the string itself to be passed to CAS as the argument.

Here's a fun example of the difference:
CAS: head("VERSION") --> "V" (as expected)
Home: head("VERSION") --> "H" (do you see why?)

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
head-ache - BruceH - 04-11-2017, 10:08 PM
RE: head-ache - Joe Horn - 04-11-2017 11:07 PM
RE: head-ache - toml_12953 - 04-12-2017, 01:38 AM
RE: head-ache - BruceH - 04-12-2017, 09:44 AM
RE: head-ache - Carlos295pz - 04-12-2017, 01:53 AM
RE: head-ache - cyrille de brébisson - 04-12-2017, 05:17 AM
RE: head-ache - JMB - 04-16-2017, 08:14 PM



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