in reply to Re^3: using shift and $_ in loop
in thread using shift and $_ in loop

Both of your examples use the return value of is_name($_) only for truth testing, but it should (after applying uc) be assembled in the result array, at least that's what the OP's example does (don't know if it makes sense)

Perl 6 - links to (nearly) everything that is Perl 6.

Replies are listed 'Best First'.
Re^5: using shift and $_ in loop
by keszler (Priest) on Oct 21, 2009 at 17:57 UTC
    Very good point, sir. I was assuming that is_name() returned the parameter given, or a false value. But you are correct: it could be altering/enhancing the parameter or returning anything else. Thus:
    @A = map { uc(is_name($_)) } grep { is_name($_) } @a;
      It does return the parameter given. If what was desired were simply to filter out elements and return selections, some grep procedure would be perfect for this, as you show in your examples.

      What I am wanting to do is something that's probably wrong to even try and do.

      I want to grab @_, iterate with shift- some elements will be discarded, elements not discarded will be changed into something completely different- and returned.

      I was fantasizing of even using the @_ list to return as well.