tech-toolchain 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



On Thu, Sep 03, 2015 at 12:17:06PM +0200, Edgar Fu? wrote:
 > Sorry, just posted to the wrong list.
 > 
 > Is there a sane way of, in a Makefile, selecting every other (i.e. either 
 > even or odd, I don't care) member from a list?
 > I'm aware of bmake's nice feature of iterating on tuples, but I need to 
 > select a unique subset of those list members. I.e., given
 > 	l= foo 1 bar 2 foo 3
 > or
 > 	l= 1 foo 2 bar 3 foo
 > if that's more convenient, I want foo bar (or bar foo), so I'd need 
 > something like ${l:[!odd!]:O:u}

Worst case you can do

l2:=
.for _i _j in $(l)
l2+=$(_i)
.endfor

and then apply :O:u to $(l2).

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index