develooper Front page | perl.perl6.users | Postings from February 2019

Re: list comprehension

Thread Previous | Thread Next
From:
Brian Duggan
Date:
February 24, 2019 15:06
Subject:
Re: list comprehension
Message ID:
20190224150643.GA16843@localhost
Yes, +1 and we have this documented on the py-to-perl6 nutshell page:

https://docs.perl6.org/language/py-nutshell#List_comprehensions

On Friday, February 22, Lucas Buchala wrote: 
> Hello folks. Did I understand correctly that this thread is about list
> comprehension syntax in Perl 6? :-)
> I don't if it was mentioned, but I think this syntax just simply works
> already. See an example:
> 
>   > say ($_~$_ if $_ %% 2 for ^10).Set
>   set(00 22 44 66 88)
> 
>   > say ($_.item if $_[0] eq 'a' or $_[1] == 2 for <a b c> X ^3).Set
>   set((a 0) (a 1) (a 2) (b 2) (c 2))
> 
> (Just drop the .Set from the end if it's not needed)

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About