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

Re: list comprehension

Thread Previous | Thread Next
From:
Lucas Buchala
Date:
February 22, 2019 17:42
Subject:
Re: list comprehension
Message ID:
CALPGu0iZ_RJfNgXL42G7P5JjESBiquDOSa3sUx+jW7E9EBwJPQ@mail.gmail.com
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