+TheBF Posted September 29, 2017 Share Posted September 29, 2017 I found out late in the day that yesterday was national beer drink day. https://www.daysoftheyear.com/days/drink-beer-day/ Thankfully I had just enough time to enjoy a very dark ale from Ireland while watching TV. In honour of this auspicious day, I thought I would take the opportunity to show how you can create your own language in Forth. (Of course I had to tie that in) Here is a program written in my new language called BREWER : BEERS ( n -- ) \ Usage: 99 BEERS POPONE DRINK HOWMANY BOTTLES OF BEER ON THE WALL , HOWMANY BOTTLES OF BEER , TAKE ONE DOWN PASS IT AROUND , ONELESS BOTTLES OF BEER ON THE WALL . ANOTHER HANGOVER ; And on the off chance that anyone cares... here is the source code for the language. :-) \ 99 bottles of beer. Create a beer language and write the program DECIMAL : CASE ( -- 0 ) 0 ; IMMEDIATE : OF ( -- ) POSTPONE OVER POSTPONE = POSTPONE IF POSTPONE DROP ; IMMEDIATE : ENDOF ( -- ) POSTPONE ELSE ; IMMEDIATE : ENDCASE ( -- ) POSTPONE DROP BEGIN ?DUP WHILE POSTPONE THEN REPEAT ; IMMEDIATE : BOTTLES ( n -- ) DUP CASE 1 OF ." One more bottle " DROP ENDOF 0 OF ." NO MORE bottles " DROP ENDOF . ." bottles " \ DEFAULT CASE ENDCASE ; : , [CHAR] , EMIT SPACE 100 MS CR ; : . [CHAR] . EMIT 300 MS CR CR CR ; : HANGOVER ." :-(" CR QUIT ; : OF ." of " ; : BEER ." beer " ; : ON ." on " ; : THE ." the " ; : WALL ." wall" ; : TAKE ." take " ; : ONE ." one " ; : DOWN ." down, " ; : PASS ." pass " ; : IT ." it " ; : AROUND ." around" ; : POPONE 1 SWAP CR ; : DRINK POSTPONE DO ; IMMEDIATE : ANOTHER POSTPONE -1 POSTPONE +LOOP ; IMMEDIATE : HOWMANY S" I " EVALUATE ; IMMEDIATE : ONELESS S" I 1- " EVALUATE ; IMMEDIATE Please drink responsibly 2 Quote Link to comment Share on other sites More sharing options...
+TheBF Posted September 29, 2017 Author Share Posted September 29, 2017 LOL! And for the real computer scientist we added the word BINARY so you can do this: 99 BINARY BEERS 2 Quote Link to comment Share on other sites More sharing options...
atrax27407 Posted September 29, 2017 Share Posted September 29, 2017 Only in FORTH!! Quote Link to comment Share on other sites More sharing options...
+InsaneMultitasker Posted September 29, 2017 Share Posted September 29, 2017 hahaha that's great Quote Link to comment Share on other sites More sharing options...
+Ksarul Posted September 29, 2017 Share Posted September 29, 2017 I like it! Beer is good! Forth is good! Forth beer is better. . . Quote Link to comment Share on other sites More sharing options...
Sinphaltimus Posted September 30, 2017 Share Posted September 30, 2017 I like it! Beer is good! Forth is good! Forth beer is better. . . Because that's when the buzz kicks in. 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted September 30, 2017 Share Posted September 30, 2017 Nice! Quote Link to comment Share on other sites More sharing options...
BillyHW Posted September 30, 2017 Share Posted September 30, 2017 You can't miss National Drink Beer day if you drink beer every day. Just sayin'... Quote Link to comment Share on other sites More sharing options...
notwhoyouthink Posted October 5, 2017 Share Posted October 5, 2017 Using your method, there is still a way to miss it: drink so much the night before in anticipation that you sleep away all of the following day. Quote Link to comment Share on other sites More sharing options...
+TheBF Posted October 6, 2017 Author Share Posted October 6, 2017 Using your method, there is still a way to miss it: drink so much the night before in anticipation that you sleep away all of the following day. LOL! Now THAT is a solid analysis. . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.