Re: Readline using foreach and while



"s" == szr <szrRE@xxxxxxxxxxxxxxx> writes:

>> Absolutely not. my %h = map { $_ => 1 } qw/a b c/; is quite a common
>> idiom.

s> Well, you're still getting that many *sets* which is probably what I
s> should of said, or have been clearer. In that example, you get 3 set of
s> hash pairs resulting from the 3 element list. The point is you get
s> count_of_passed_list amount of something from the map, in some form or
s> another. How exactly it's returned is determined by the template inside
s> the map.

you are still missing the picture. map can return ANY number of elements
(not sets). it executes its expression/block once for each input element
but that can generate 0-?? elements which are appended to the return
list. there are no boundaries in those elements so there are no true
sets. if you return a reference which holds stuff you can force your own
boundaries and make sets. that is also a known map idiom. map generates
a new list from input from another list. the transformation can be
anything and isn't tied to how many input elements there are.

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
.



Relevant Pages

  • Re: Readline using foreach and while
    ... (Please use proper capitalization and such, ... each>> input element but that can generate 0-?? ... of map, s> it's done that many times are there are elements in the ... assigning the list to a hash. ...
    (comp.lang.perl.misc)
  • Re: how to map mutiple data of child field attribute to single file
    ... Use the concatenate functiod under 'String functoids' category. ... input element in sequence the map the output to a single field in the ... destination.. ... I am using map but what functoid to i need to you or i need to write ...
    (microsoft.public.biztalk.general)
  • Re: Readline using foreach and while
    ... it executes its expression/block once for each ... >> input element but that can generate 0-?? ... s> I understand, but still, whatever is being generated to the LHS of map, ... the CODE in the expression/block is executed ONCE for each ...
    (comp.lang.perl.misc)
  • Re: Readline using foreach and while
    ... common>> idiom. ... it's returned is determined by the template inside s> the map. ... the RHS is always a single element list. ... saying is fair in that sense, but the map operation can change the ...
    (comp.lang.perl.misc)
  • my map vs. collect bone
    ... Anytime I create a method like #collect_with_counter I ... Besides its a waste of useful semanitic space. ... To me 'map' indicates 'hash' and its a strech to think of the resulting ... I suppose 'map' indicates that an input element ...
    (comp.lang.ruby)