develooper Front page | perl.perl6.language | Postings from June 2004

Re: Semantics of vector operations (Damian)

Thread Previous | Thread Next
From:
Mark J. Reed
Date:
June 14, 2004 15:05
Subject:
Re: Semantics of vector operations (Damian)
Message ID:
20040614220509.GC15962@charm.turner.com

On 2004-06-14 at 22:58:58, Matthew Walton wrote:
> 'it would be better to explicitly just say
> 
> (@list.grep value) = undef
> 
> although I think that might be supposed to be
> 
> (@list.grep value) »= undef;

Those do different things according to my understanding.  The first
removes all matching items from the list; the second replaces the 
matching items with undef.

e.g. (please forgive any Perl6 syntax errors):

	[1,2,3,4,5].grep { $_ % 2 } = undef

results in the list

	[2,4]

while

	[1,2,3,4,5].grep { $_ % 2 } »= undef

results in the list

	[undef, 2, undef, 4, undef]

-Mark

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