Bug with CONCAT
01-02-2014, 04:23 PM
Post: #1
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
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?
01-02-2014, 04:34 PM
Post: #2
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
RE: Bug with CONCAT
The above problem occurs in CAS view, and with a CAS program, I should add.
Post: #3
 Michael de Estrada Senior Member Posts: 337 Joined: Dec 2013
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.
01-02-2014, 05:58 PM
Post: #4
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
RE: Bug with CONCAT
Yes, that is interesting. Same with my workaround with an empty list at the beginning. Works for two arguments.
01-02-2014, 06:10 PM
Post: #5
 Michael de Estrada Senior Member Posts: 337 Joined: Dec 2013
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.
01-02-2014, 06:39 PM
Post: #6
 Alberto Candel Member Posts: 169 Joined: Dec 2013
RE: Bug with CONCAT
And with strings:

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

and

CONCAT("5",6) -> "56"
01-02-2014, 07:51 PM
Post: #7
 Mark Hardman Senior Member Posts: 484 Joined: Dec 2013
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.
Post: #8
 Michael de Estrada Senior Member Posts: 337 Joined: Dec 2013
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]
01-02-2014, 11:07 PM
Post: #9
 Terje Vallestad Member Posts: 143 Joined: Dec 2013
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
01-02-2014, 11:16 PM
Post: #10
 Michael de Estrada Senior Member Posts: 337 Joined: Dec 2013
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}.
01-02-2014, 11:21 PM
Post: #11
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
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

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?
01-02-2014, 11:40 PM
Post: #12
 Terje Vallestad Member Posts: 143 Joined: Dec 2013
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
01-02-2014, 11:58 PM
Post: #13
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
RE: Bug with CONCAT
No, unfortunately, that is not what I'm looking for. But thanks for your response!
Post: #14
 Michael de Estrada Senior Member Posts: 337 Joined: Dec 2013
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;
01-03-2014, 01:19 AM
Post: #15
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
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).
01-03-2014, 01:49 AM
Post: #16
 Michael de Estrada Senior Member Posts: 337 Joined: Dec 2013
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.
01-03-2014, 02:03 AM
Post: #17
 Helge Gabert Senior Member Posts: 460 Joined: Dec 2013
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 . . .
 « Next Oldest | Next Newest »

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