Post Reply 
CAS questions: IF...THEN and length() function
12-01-2015, 09:36 PM
Post: #1
CAS questions: IF...THEN and length() function
I've been writing some simple CAS programs in CAS mode and I've encountered a few issues. The first is to do with return:
IF (x<0) THEN return -1; END;
return 1;
I'd expect this to return -1 if x<0 and 1 otherwise, but it always returns 1. It isn't hard to work around this (using ELSE), but is there something that I'm missing here?

The second issue (rather obscure) is to do with the length() function. length("abc") returns 3, which is fine. length(x+2=y) (note: expressions in XCAS seem to be stored as lists) returns 2, although it has three elements.

More generally: does anyone know where I can find lots of CAS programs written for the Prime? I like to learn a programming language by looking at programs that other people have already written!

Nigel (UK)
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
CAS questions: IF...THEN and length() function - Nigel (UK) - 12-01-2015 09:36 PM

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