uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

fizzbuzz.tal (647B)


      1 ( Print the first 30 numbers using the following rules:
      2 	| If n is divisible by 3, print "fizz"
      3 	| If n is divisible by 5, print "buzz"
      4 	| If n is divisible by both, print "fizzbuzz"
      5 	| Else, print the number )
      6 
      7 @fizzbuzz ( -> )
      8 	#1e00
      9 	&>loop ( length i -- )
     10 		DUP fizz OVR buzz ORA ?{ DUP <dec> }
     11 		#0a18 DEO
     12 		INC GTHk ?&>loop
     13 	POP2 BRK
     14 
     15 @fizz ( n -- ) #03 DIVk MUL SUB ?{ #01 ;Dict/fizz !<str> } #00 JMP2r
     16 @buzz ( n -- ) #05 DIVk MUL SUB ?{ #01 ;Dict/buzz !<str> } #00 JMP2r
     17 @<dec> ( n -- ) DUP #0a DIV /d #0a DIVk MUL SUB &d #30 ADD #18 DEO JMP2r
     18 @<str> ( s* -- ) LDAk #18 DEO INC2 LDAk ?<str> POP2 JMP2r
     19 @Dict &fizz "Fizz $1 &buzz "Buzz $1
     20