Post Reply 
Bug with CONCAT
01-02-2014, 04:23 PM
Post: #1
Bug with CONCAT
I've come across a problem with CONCAT and two arguments (firmware 5447).

Try CONCAT(5,6) returns 0. ???

CONCAT(5,6,7) returns [ 5 6 7 ], as it should.

In a program, for now, one can get around this problem with defining a list first, e.g.,

l:= {}

l:=CONCAT(l,5);

l:=CONCAT(l,6);

RETURN (l); returns the list {5, 6}.

I thought I should mention this because I got unexpected results in my program, and was finally able to trace it - - I called RETURN(CONCAT(v1,v2)) and obtained 0.

Also CAS programs really should be debuggable (just like PPL programs) - - why is the DEBUG soft key missing for CAS programs in the editor?
Find all posts by this user
Quote this message in a reply
01-02-2014, 04:34 PM
Post: #2
RE: Bug with CONCAT
The above problem occurs in CAS view, and with a CAS program, I should add.
Find all posts by this user
Quote this message in a reply
01-02-2014, 05:52 PM (This post was last modified: 01-02-2014 06:00 PM by Michael de Estrada.)
Post: #3
RE: Bug with CONCAT
I find it interesting that if the first entry is a list, then it works, i.e. CONCAT({5},6) --> {5,6}. However, you can only have one item after the list, e.g. CONCAT({5},6,7) --> [{5} 6 7], but CONCAT({5},{6,7}) --> {5,6,7}. Also, CONCAT(5,{6,7}) --> {5,6,7} works as well.
Find all posts by this user
Quote this message in a reply
01-02-2014, 05:58 PM
Post: #4
RE: Bug with CONCAT
Yes, that is interesting. Same with my workaround with an empty list at the beginning. Works for two arguments.
Find all posts by this user
Quote this message in a reply
01-02-2014, 06:10 PM
Post: #5
RE: Bug with CONCAT
I also found that as long as one of the arguments is a list, then it works ok, i.e. CONCAT(5,{6}) --> {5,6} also works.
Find all posts by this user
Quote this message in a reply
01-02-2014, 06:39 PM
Post: #6
RE: Bug with CONCAT
And with strings:

CONCAT("5","6") -> "56"

and

CONCAT("5",6) -> "56"
Find all posts by this user
Quote this message in a reply
01-02-2014, 07:51 PM
Post: #7
RE: Bug with CONCAT
I wonder if this is a case of xcas attempting to parse the argument (5,6) as an imaginary number.

There was a thread in the old forums with a similar issue. I've searched and could not find a link.

Mark Hardman

Ceci n'est pas une signature.
Find all posts by this user
Quote this message in a reply
01-02-2014, 09:47 PM (This post was last modified: 01-02-2014 09:49 PM by Michael de Estrada.)
Post: #8
RE: Bug with CONCAT
(01-02-2014 07:51 PM)Mark Hardman Wrote:  I wonder if this is a case of xcas attempting to parse the argument (5,6) as an imaginary number.

There was a thread in the old forums with a similar issue. I've searched and could not find a link.

Mark Hardman

I don't think so, since it would not recognize it as such w/o a second set of parentheses. Also, I think you meant to say complex number. For example:

CONCAT(1,2) --> 0

but,

CONCAT((1,2)) --> CONCAT((1,2))
CONCAT(1+2*i) --> CONCAT(1+2*i)

because it can't further combine a complex number into itself

however,

CONCAT((1,2),(3,4)) --> 0
CONCAT(1+2*i,3+4*i) --> 0

but,

CONCAT((1,2),(3,4),(5,6)) --> [(1,2),(3,4),(5,6)]
CONCAT(1+2*i,3+4*i,5+6*i) --> [1+2*i,3+4*i,5+6*i]
Find all posts by this user
Quote this message in a reply
01-02-2014, 11:07 PM
Post: #9
RE: Bug with CONCAT
(01-02-2014 04:23 PM)Helge Gabert Wrote:  I've come across a problem with CONCAT and two arguments (firmware 5447).

Try CONCAT(5,6) returns 0. ???

CONCAT(5,6,7) returns [ 5 6 7 ], as it should.

In a program, for now, one can get around this problem with defining a list first, e.g.,

l:= {}

l:=CONCAT(l,5);

l:=CONCAT(l,6);

RETURN (l); returns the list {5, 6}.

I thought I should mention this because I got unexpected results in my program, and was finally able to trace it - - I called RETURN(CONCAT(v1,v2)) and obtained 0.

Also CAS programs really should be debuggable (just like PPL programs) - - why is the DEBUG soft key missing for CAS programs in the editor?

I think if you try the function \( cat \) you will get the response you are looking for?

The user manual only states CONCAT to be used with lists so you may be confusing the parser?

Cheers, Terje
Find all posts by this user
Quote this message in a reply
01-02-2014, 11:16 PM
Post: #10
RE: Bug with CONCAT
(01-02-2014 11:07 PM)Terje Vallestad Wrote:  I think if you try the function \( cat \) you will get the response you are looking for?

The user manual only states CONCAT to be used with lists so you may be confusing the parser?

Cheers, Terje

The problem is that the Prime Help for CONCAT does not say this, and simply states that it joins items (values) into a list. One of the examples is CONCAT(1,2,3,4) which returns {1,2,3,4}.
Find all posts by this user
Quote this message in a reply
01-02-2014, 11:21 PM
Post: #11
RE: Bug with CONCAT
(01-02-2014 11:07 PM)Terje Vallestad Wrote:  
(01-02-2014 04:23 PM)Helge Gabert Wrote:  I've come across a problem with CONCAT and two arguments (firmware 5447).

Try CONCAT(5,6) returns 0. ???

CONCAT(5,6,7) returns [ 5 6 7 ], as it should.

In a program, for now, one can get around this problem with defining a list first, e.g.,

l:= {}

l:=CONCAT(l,5);

l:=CONCAT(l,6);

RETURN (l); returns the list {5, 6}.

I thought I should mention this because I got unexpected results in my program, and was finally able to trace it - - I called RETURN(CONCAT(v1,v2)) and obtained 0.

Also CAS programs really should be debuggable (just like PPL programs) - - why is the DEBUG soft key missing for CAS programs in the editor?

I think if you try the function \( cat \) you will get the response you are looking for?

The user manual only states CONCAT to be used with lists so you may be confusing the parser?

Cheers, Terje

I'm not sure I understand you at all.

I'm trying to join two elements into a list (in CAS view, or in a CAS program). CONCAT is the correct command, and it doesn't work, because it returns zero.

Does it work for you?
Find all posts by this user
Quote this message in a reply
01-02-2014, 11:40 PM
Post: #12
RE: Bug with CONCAT
(01-02-2014 11:21 PM)Helge Gabert Wrote:  
(01-02-2014 11:07 PM)Terje Vallestad Wrote:  I think if you try the function \( cat \) you will get the response you are looking for?

The user manual only states CONCAT to be used with lists so you may be confusing the parser?

Cheers, Terje

I'm not sure I understand you at all.

I'm trying to join two elements into a list (in CAS view, or in a CAS program). CONCAT is the correct command, and it doesn't work, because it returns zero.

Does it work for you?

Yes. On the calculator. For instance cat(5,6) gives "56", but maybe that was not what you were looking for?

Cheers, Terje
Find all posts by this user
Quote this message in a reply
01-02-2014, 11:58 PM
Post: #13
RE: Bug with CONCAT
No, unfortunately, that is not what I'm looking for. But thanks for your response!
Find all posts by this user
Quote this message in a reply
01-03-2014, 12:11 AM (This post was last modified: 01-03-2014 12:19 AM by Michael de Estrada.)
Post: #14
RE: Bug with CONCAT
I just discovered something. CONCAT is not a CAS command, so if you run it in Home view it works correctly, i.e. CONCAT(5,6) --> {5,6}. So, if you run it in a program, it should work if you don't CAS it.

I just wrote this short program and it worked:

EXPORT Ctest(v1,v2)
BEGIN
RETURN CONCAT(v1,v2);
END;
Find all posts by this user
Quote this message in a reply
01-03-2014, 01:19 AM
Post: #15
RE: Bug with CONCAT
Yes it works correctly in Home View; I know that.

Unfortunately, my program is a CAS program, and there is where I run into trouble. Is there an equivalent CAS function for CONCAT? To your knowledge?

(Actually, this is all kind of silly - - CONCAT should work in both modes (CAS and Home), and it does work correctly in CAS for arguments of three or more. It makes absolutely no sense why it should not work in the CAS environment for two arguments only).
Find all posts by this user
Quote this message in a reply
01-03-2014, 01:49 AM
Post: #16
RE: Bug with CONCAT
(01-03-2014 01:19 AM)Helge Gabert Wrote:  Yes it works correctly in Home View; I know that.

Unfortunately, my program is a CAS program, and there is where I run into trouble. Is there an equivalent CAS function for CONCAT? To your knowledge?

(Actually, this is all kind of silly - - CONCAT should work in both modes (CAS and Home), and it does work correctly in CAS for arguments of three or more. It makes absolutely no sense why it should not work in the CAS environment for two arguments only).

I'm not aware of a CAS-specific function for Concatenation, but the CAS problem goes beyond what you've identified. For example CONCAT({5},{6},7) returns {5,6,7} in Home view, but it returns [{5} {6} 7] in CAS view. IOW, in Home view it properly combines the three items into a single list, but in CAS view it simply creates a size 3 vector containing those items.
Find all posts by this user
Quote this message in a reply
01-03-2014, 02:03 AM
Post: #17
RE: Bug with CONCAT
Yes, good observation!

It appears, generally speaking, that vectors and lists are somewhat interchangeable in CAS (a concept that I don't like myself, but there it is).

For example, you can save the aforementioned vector of yours to a list, e.g.,

store [ 5 6 7 ] in L1. It works! Then, recall L1. Voila! Now it morphed into a list.

{5 6 7 }.

Funny . . .
Find all posts by this user
Quote this message in a reply
Post Reply 




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