Jack Brennen on Tue, 08 Jul 2014 01:23:15 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: concat([])


Or should it be "" ?

"ab" <- concat(["a","b"])
"a"  <- concat(["a"])
""   <- concat([])

I guess it's ambiguous, so it is rejected?

Note that concat() has some serious weirdnesses
when you mix strings with other types...
This is version 2.5.5 behavior:

? concat(["",1,x,y])
%1 = "1xy"
? concat([1,x,y,""])
%2 = "[1, x, y]"
? concat([[],x,y,""])
%3 = "[x, y]"
? concat([[],x,y,[]])
%4 = [x, y]
? concat(["",x,y,[]])
%5 = "xy[]"

It seems as if it progresses using non-string-based concatenation
until it finds a string, at which point it converts the result
so far to a string and then continues?




On 7/7/2014 3:34 PM, Max Alekseyev wrote:
? concat([])
   ***   at top-level: concat([])
   ***                 ^----------
   *** concat: domain error in concat: vector = []
   ***   Break loop: type 'break' to go back to GP prompt


Should it simply return [] ?

Regards,
Max