tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: (b)make: selecting every other element from a list



>> Is there some reason for not doing that using iteration?
> 1. This can be greatly simplified by iterating over pairs.

True.  While I rarely do it in make, in sh I comparatively often do
this by gluing the elements of pairs together, as in

for x in 1.foo 2.bar 3.blee
do
	...${x%%.*}...${x#*.}...
done

Depending on where your lists come from, something of the sort may be
of some use to you (adapted, of course, to make syntax).

> 2. My memory mis-told me that appending the loop variable to a list
> didn't work.

I think it might not if you use = instead of :=, or some such.

> 3. I was hoping for a nicer solution (as in "oh, I forgot to document
> the :[%odd%] modifier").

Heh.  Fair enough.

/~\ The ASCII				  Mouse
\ / Ribbon Campaign
 X  Against HTML		mouse%rodents-montreal.org@localhost
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index