Re: Hyper-concat
Hi, Thomas Klausner wrote: my $string=a b c ~ 1 2 3; say $string; # prints a1 b2 c3 But where do the spaces in the second example come from? the spaces come from the stringification of lists/arrays: my @array = a b c d; say [EMAIL PROTECTED];# a b c d You can use say [~] @array; # abcd or say @array.join();# abcd or say join , @array;# abcd if you want to supress the spaces. And you could override this by doing something like: class MyArray is Array { method *prefix:~ (@self: ) { [~] @self } } my @array is MyArray = a b c d; say [EMAIL PROTECTED];# abcd --Ingo -- Linux, the choice of a GNU | The computer revolution is over. The generation on a dual AMD | computers won. -- Eduard Bloch [EMAIL PROTECTED] Athlon!|
Re: Hyper-concat
On Tue, Jun 14, 2005 at 10:31:58PM +0200, Ingo Blechschmidt wrote: : You can use : say [~] @array; # abcd or : say @array.join();# abcd or : say join , @array;# abcd : if you want to supress the spaces. I think a bare @array.join should also work. Larry
Re: Hyper-concat
Larry Wall skribis 2005-06-14 14:15 (-0700): On Tue, Jun 14, 2005 at 10:31:58PM +0200, Ingo Blechschmidt wrote: : You can use : say [~] @array; # abcd or : say @array.join();# abcd or : say join , @array;# abcd : if you want to supress the spaces. I think a bare @array.join should also work. I think it should not. split splits on whitespace, stringification joins on whitespace, reverse in scalar context joins on whitespace. It would be fair if join defaulted to ' ' as well. You suggested cat as a join assuming '' in an old thread. I still like that idea. [ 'a' .. 'e' ].join # a b c d e [ 'a' .. 'e' ].cat# abcde Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Hyper-concat
On Tue, Jun 14, 2005 at 11:33:21PM +0200, Juerd wrote: : You suggested cat as a join assuming '' in an old thread. I still like : that idea. : : [ 'a' .. 'e' ].join # a b c d e : [ 'a' .. 'e' ].cat# abcde I had forgotten that. Yes, there is a little something to be said for preserving the (mostly false) symmetry of split and join. I think I argued for .cat on the basis that it also gives us cat as a list operator. But these days that's just [~], so at the moment I'm inclined to stick with argumentless .join doing concatenation, especially since I'd like to undo the split(' ') special case anyway and use a different notation for word splitting. Larry
Re: Hyper-concat
Larry Wall skribis 2005-06-14 14:54 (-0700): : [ 'a' .. 'e' ].join # a b c d e : [ 'a' .. 'e' ].cat# abcde I had forgotten that. Yes, there is a little something to be said for preserving the (mostly false) symmetry of split and join. I think I argued for .cat on the basis that it also gives us cat as a list operator. But these days that's just [~], so at the moment I'm inclined to stick with argumentless .join doing concatenation, especially since I'd like to undo the split(' ') special case anyway and use a different notation for word splitting. Still, argumentless split probably defaults to something. And ' ' is a good thing to default to, IMO. It doesn't have to be a special case. In fact, it not being a special case makes the symmetry less false, and would --if ' ' is the default-- make the case even stronger for join to default to ' ' too. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Hyper-concat
At 12:01 AM +0200 6/15/05, Juerd wrote: Larry Wall skribis 2005-06-14 14:54 (-0700): : [ 'a' .. 'e' ].join # a b c d e : [ 'a' .. 'e' ].cat# abcde I had forgotten that. Yes, there is a little something to be said for preserving the (mostly false) symmetry of split and join. I think I argued for .cat on the basis that it also gives us cat as a list operator. But these days that's just [~], so at the moment I'm inclined to stick with argumentless .join doing concatenation, especially since I'd like to undo the split(' ') special case anyway and use a different notation for word splitting. Still, argumentless split probably defaults to something. And ' ' is a good thing to default to, IMO. It doesn't have to be a special case. In fact, it not being a special case makes the symmetry less false, and would --if ' ' is the default-- make the case even stronger for join to default to ' ' too. I think that '' is the best default case for both split and join in Perl 6. They would be symmetrical because they are both ''. And the space character is really a rather arbitrary looking value for a default and is equally valid with, say, the line break, so how can one say it is better? -- Darren Duncan
Re: Hyper-concat
Darren Duncan skribis 2005-06-14 15:12 (-0700): And the space character is really a rather arbitrary looking value for a default and is equally valid with, say, the line break, so how can one say it is better? Array stringification uses it too, by default. The lesser the number of defaults, the more predictible the language is. Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html http://convolution.nl/gajigu_juerd_n.html
Re: Hyper-concat
Juerd wrote: Still, argumentless split probably defaults to something. And ' ' is a good thing to default to, IMO. I like /\s+/ as a default for split better. -- Rod Adams
Re: Hyper concat ^_ ?
On Fri, Oct 05, 2001 at 09:50:53AM +0100, Richard Nuttall wrote: my @images = qw( pic1 pic2 pic3) ^_ ('.jpg'); my @images = map { $_ _ '.jpg' } qw(pic1 pic2 pic3); Hmmm, that's visually unappealing. Just thinking out loud. -- Michael G. Schwern [EMAIL PROTECTED]http://www.pobox.com/~schwern/ Perl6 Quality Assurance [EMAIL PROTECTED] Kwalitee Is Job One GOD made us funky!
Re: Hyper concat ^_ ?
my @images = qw( pic1 pic2 pic3) ^_ ('.jpg'); Doesn't that clash with the default currying argument? No. The DCA is: $^_ Damian