> < ^ Date: Sat, 07 Jan 1995 21:10:00 -0800
> < ^ From: Jacob Hirbawi <hirbawi@commquest.com >
> ^ Subject: strange problem with string concatenation

I ran into this strange behavior of string concatenation :

f:=x->Concatenation(List(x,String));
a:=UnorderedTuples([1..3],2);
b:=List(a,f);

# I want b to equal ["11","12",...,"33"]; instead I get :
gap> b;
[ [ '1', '1' ], [ '1', '2' ], [ '1', '3' ], [ '2', '2' ], [ '2', '3' ],
  [ '3', '3' ] ]

# but single elements look right!
gap> b[1];
"11"

# looking at an element seems to "fix" it :
gap> b;
[ "11", [ '1', '2' ], [ '1', '3' ], [ '2', '2' ], [ '2', '3' ], [ '3', '3' ] ]

# so this "fixes" the fourth element
gap> b[4];
"22"

gap> b;
[ "11", [ '1', '2' ], [ '1', '3' ], "22", [ '2', '3' ], [ '3', '3' ] ]

it's easy to find a way around this; for example this works :

ff:=function(lst) local str,i;
str:="";
for i in lst do
str:=ConcatenationString(str,String(i));
od;
return str;end;

gap> bb:=List(a,ff);
[ "11", "12", "13", "22", "23", "33" ]

but it would be nicer if the built-in function behaves predictably.

Jacob Hirbawi <JcbHrb@CERF.net>

PS. I'm running with version 3.4


> < [top]