Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Getting rid of temporaries...



    Hi Bart :)

 * Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> dixit:
> }     Now the question: how can I do this without using the temporary
> } parameter 'array' and, if possible, without 'uniq'.
> If you have the array, it's easy to do without uniq.

    Yes, with typeset -U, I just learned it a minute ago O:))

> The 'e' globbing flag gets you most of the way:

    I tried, but didn't get any result.
 
>     print -l *.??.jpg(e['REPLY=${REPLY%.??.jpg}'])

    I didn't write anything so elaborated O:). Thanks for the line :)
But this doesn't do the 'uniqueness', so I still depend on the array
(typesetted with -U) or 'uniq'. No problem about that.
 
> Of course, that uses the magic temporary $REPLY variable, so it hasn't
> really eliminated temporaries.

    No problem, because I want to get rid of the array so I could put
this in an alias instead of a function. Just for learning.
 
> }     array=( /directory/*/* )
> This suggestion is on the right track, but it's not equivalent to Raul's
> original one, because your first assignment may match names that do not
> match *.<00-99>.jpg, which won't be modified by the second assignment.

    Mine did, too. I'm sure that all filenames are of the form
name.digitdigit.jpg, so I carelessly matched all filenames.

> } though it might be a nice candidate for yet another parameter expansion
> } flag.  :)
> You mean like ${(u)...}, which is in 4.1.1-dev-* ...

    Oh, yes, I knew that I read it somewhere in this list. But I have
4.0.6 and that doesn't work, of course. Thanks for pointing :)

>     typeset -U array
>     array=( *.<00-99>.jpg(e['REPLY=${REPLY%.??.jpg}']) )
>     print -l $array

    Well, this is pretty compact, too :)) Thanks a lot :) I've
learned to use the (e) flag!

    Raúl Núñez de Arenas Coronado

-- 
Linux Registered User 88736
http://www.pleyades.net & http://raul.pleyades.net/



Messages sorted by: Reverse Date, Date, Thread, Author