Jump to navigation Jump to search
Bgt is a joke esoteric programming language speedran by Cinnamony. Let's see how long it takes to write this one.
||prints the character in front of it|
||prints the input|
||prints the 99 bottles of beer on the wall program|
||print the FizzBuzz program|
An implementation in Common Lisp shall be provided:
(defun interpret-Bgt (code) "Interprets the piece of Bgt source CODE and returns NIL." (declare (type string code)) (let ((position 0)) (declare (type fixnum position)) (symbol-macrolet ((current-token (the character (char code position))) (eof-p (the boolean (not (array-in-bounds-p code position))))) (loop until eof-p do (case current-token (#\P (incf position) (when eof-p (error "Expected at character to print, encountered EOF.")) (format T "~c" current-token) (incf position)) (#\K (format T "~&>> ") (format T "~a" (read-line)) (clear-input) (incf position)) (#\L (loop for number-of-bottles of-type (integer -1 99) from 99 downto 1 do (format T "~&~d ~:*bottle~p of beer on the wall,~%~ ~:*~d ~:*bottle~p of beer.~%~ Take one down, pass it around,~%~ ~[No~:;~d~] ~:*bottle~p of beer on the wall.~2%" number-of-bottles (decf number-of-bottles) number-of-bottles)) (incf position)) (#\J (loop for counter of-type (integer 1 101) from 1 to 100 do (format T "~&~a" (cond ((zerop (mod counter 15)) "FizzBuzz") ((zerop (mod counter 3)) "Fizz") ((zerop (mod counter 5)) "Buzz") (T counter)))) (incf position)) (#\Z (format T "~&>> ") (let ((input (parse-integer (read-line)))) (declare (type integer input)) (clear-input) (if (zerop input) (format T "~&0") (loop initially (fresh-line) do (format T "1")))) (incf position)) (otherwise (error "Invalid character at position ~d: ~s." position current-token)))))))