ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: Hyper-concat
by Ingo Blechschmidt other posts by this author
Jun 14 2005 1:34PM messages near this date
Hyper-concat | 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 ~@array;            # "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 ~@array;            # "abcd"


--Ingo

-- 
Linux, the choice of a GNU | The computer revolution is over. The
generation on a dual AMD   | computers won. -- Eduard Bloch <edi@[...].de> 
Athlon!                    | 
Thread:
Thomas Klausner
Ingo Blechschmidt
Larry Wall
Juerd
Larry Wall
Juerd
Rod Adams
Darren Duncan
Juerd

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved