Skip to content

Instantly share code, notes, and snippets.

@g-k
Created December 26, 2012 18:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save g-k/4381991 to your computer and use it in GitHub Desktop.
Save g-k/4381991 to your computer and use it in GitHub Desktop.
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