Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- equals = $(if $(filter $1,$2),$1)
- slice = $(wordlist 2,$(words $1),$1)
- map = $(if $(call equals,$(words $2),0),$(strip $3),$(call map,$1,$(call slice,$2),$3 $(call $1,$(firstword $2),$(words $3))))
- replicate = $(if $(call equals,$(words $3),$1),$(strip $3),$(call replicate,$1,$2,$3 $2))
- range = $(if $(call equals,$(words $2),$1),$(strip $2),$(call range,$1,$2 $(words $2)))
- repeat = $(if $(call equals,$(words $4),$1),$3,$(call repeat,$1,$2,$(call $2,$3),$4 $1))
- rotate = $(call slice,$1) $(firstword $1)
- cycle = $(firstword $(call repeat,$1,rotate,$2))
- select = $(if $1,$1,$2)
- concat = $(if $(call equals,$1,_),,$1)$(if $(call equals,$2,_),,$2)
- add = $(words $(call replicate,$1,_) $(call replicate,$2,_))
- incr = $(call add,1,$1)
- numbers := $(call map,incr,$(call range,100))
- fizz := $(call replicate,2,_) fizz
- buzz := $(call replicate,4,_) buzz
- fizzbuzz = $(call select,$(call concat,$(call cycle,$2,$(fizz)),$(call cycle,$2,$(buzz))),$1)
- result := $(call map,fizzbuzz,$(numbers))
- print = $(info $1)
- .PHONY: all
- all: ; $(call map,print,$(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement