Skip to content

Instantly share code, notes, and snippets.

@g-k
Created Dec 26, 2012
Embed
What would you like to do?
fizzbuzz in GNU make
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))
@g-k
Copy link
Author

g-k commented Apr 30, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment