Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Operators
- eq = $(filter $1,$2)
- slice = $(wordlist 2,$(words $1),$1)
- repl = $(if $(call eq,$(words $4),$1),$3,$(call repl,$1,$2,$3 $2,$(words $4) $4))
- map = $(if $2,$(call map,$1,$(call slice,$2),$3,$4 $(call $1,$(firstword $2),$3,$4)),$4)
- rotate = $(call slice,$1) $(firstword $1)
- zip3 = $(if $2,$(call zip3,$1,$(call slice,$2),$(call rotate,$3),$(call rotate,$4),$5 $(call $1,$(firstword $2),$(firstword $3),$(firstword $4))),$5)
- inc = $(words $(call repl,$1,_) _)
- ### Program body
- count = $(words $3)
- cycle = $(call slice,$(call repl,$1,_)) $2
- fizz := $(call cycle,3,fizz)
- buzz := $(call cycle,5,buzz)
- numbers := $(call map,inc,$(call map,count,$(call repl,100,_)))
- select = $(if $1,$1,$2)
- fizzbuzz = $(call select,$(if $(call eq,$2,_),,$2)$(if $(call eq,$3,_),,$3),$1)
- result := $(call zip3,fizzbuzz,$(numbers),$(fizz),$(buzz))
- println = $(info $1)
- ### Targets
- .PHONY: all
- all: ; $(call map,println,$(result))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement