Created
December 26, 2012 18:18
-
-
Save g-k/4381991 to your computer and use it in GitHub Desktop.
fizzbuzz in GNU make
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include gmsl-1.1.2/gmsl | |
# ^ Thank you Mr. Make | |
three := $(call int_encode,3) | |
five := $(call int_encode,5) | |
start := $(call int_encode,1) | |
stop := $(call int_encode,100) | |
int_remainder = $(__gmsl_tr2)$(strip $(if $2, \ | |
$(if $(call int_gte,$1,$2), \ | |
$(call int_remainder,$(call int_subtract,$1,$2),$2),$1), \ | |
$(call __gmsl_error,Division by zero))) | |
fizz = $(if $(call int_eq,$(call int_remainder,$1,$(three))),Fizz,) | |
buzz = $(if $(call int_eq,$(call int_remainder,$1,$(five))),Buzz,) | |
fizzbuzz = $(if $(call fizz,$1)$(call buzz,$1), \ | |
$(call fizz,$1)$(call buzz,$1), \ | |
$(call int_decode,$1)) | |
main = $(info $(call fizzbuzz,$1)) \ | |
$(if $(call int_gte,$1,$2), \ | |
, \ | |
$(call main,$(call int_inc,$1),$2)) | |
.PHONY: all | |
all: ; @echo $(call main,$(start),$(stop)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.cmcrossroads.com/article/learning-gnu-make-functions-arithmetic