[CRIU] [PATCH 1/2] build/nmk: define map and newline

Dmitry Safonov dsafonov at virtuozzo.com
Fri Feb 19 07:31:44 PST 2016


On 02/19/2016 05:25 PM, Cyrill Gorcunov wrote:
> On Fri, Feb 19, 2016 at 05:17:25PM +0300, Dmitry Safonov wrote:
>>> map = $(foreach x,$2,$(call $1,$x)$(newline))
>>>
>>> (I really tempting to call it well known mapcar,
>>>   but this won't work :)
>> Hehe, I may change this also if you want to :)
> Nope, it won't work in a way the original function does anyway ;-)
>
> ps: for curious people
> http://www.lispworks.com/documentation/HyperSpec/Body/f_mapc_.htm
Hehe, here is it:

# map funciton:
# $1 - func to call
# $2 - list over which map the $1 func
# result is divided with newlines
map = $(foreach x,$2,$(call $1,$x)$(newline))

define __mapcap_f
$(eval $2 := $(call map,$1,$($2)))
endef
# mapcap funciton:
# $1 - func to call
# $2 - lists over which map the $1 func
mapcap = $(foreach x,$2,$(call __mapcap_f,$1,$x))

first_list:=a b
second_list:=n m
lists_list:=first_list second_list

define add_c
$(1)c
endef

define print_function
$(warning $(1))$(1)
endef

$(call mapcap,add_c,$(lists_list))
$(call mapcap,print_function,$(lists_list))

### --->8---
$ make
Makefile:28: ac
Makefile:28: bc
Makefile:28: nc
Makefile:28: mc

-- 
Regards,
Dmitry Safonov



More information about the CRIU mailing list