!!
Jump to navigation
Jump to search
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
!! is a joke esolang that modifies everything written about it to be in uppercase.
Commands
Command | Description |
---|---|
HW
|
Prints Hello, world! |
99
|
Prints 99 bottles of beer |
CT
|
Cat program |
FB
|
FizzBuzz |
??
|
Acronym |
Implementation
This attempt at an implementation has been realized in the programming language common lisp. please heed that the ??
(“Acronym”) command has been construed as to query the user for a string and print its acronym form.
(DEFTYPE DESTINATION () "THE DESTINATION TYPE DEFINES A SINK FOR OUTPUT OPERATIONS, ENCOMPASSING, AMONG OTHERS, THE FUNCTIONS FORMAT AND WRITE-CHAR." '(OR NULL (EQL T) STREAM STRING)) (DEFUN PRINT-HELLO-WORLD () "PRINTS THE MESSAGE \"HELLO WORLD\" TO THE STANDARD OUTPUT AND RETURNS NO VALUE." (FORMAT T "~&HELLO WORLD") (VALUES)) (DEFUN PRINT-99-BOTTLES-OF-BEER () "PRINTS THE LYRICS OF THE SONG \"99 BOTTLES OF BEER\" TO THE STANDARD OUTPUT AND RETURNS NO VALUE." (LOOP FOR NUMBER-OF-BOTTLES OF-TYPE (INTEGER 0 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.~)" NUMBER-OF-BOTTLES NUMBER-OF-BOTTLES (1- NUMBER-OF-BOTTLES))) (FORMAT T "~2%") (VALUES)) (DEFUN EXECUTE-CAT-PROGRAM () "EXECUTES A ONE-TIME LINE-BASED CAT PROGRAM, THE SAME REVERBERATES ITS OUTPUT IN A MAJUSCULAR FORM, AND RETURNS NO VALUE." (FORMAT T "~&CAT PROGRAM: ") (FINISH-OUTPUT) (FORMAT T "&~:@(~A~)" (READ-LINE)) (CLEAR-INPUT) (VALUES)) (DEFUN FIZZBUZZ (DESTINATION OBJECT-TO-FORMAT COLON-MODIFIER-SUPPLIED-P AT-SIGN-MODIFIER-SUPPLIED-P &REST PREFIX-PARAMETERS) "DEPENDING UPON THE OBJECT-TO-FORMAT'S VALUE, EITHER PRINTS \"FIZZ\", \"BUZZ\", OR \"FIZZBUZZ\" TO THE DESTINATION, IGNORING THE PARAMETERS COLON-MODIFIER-SUPPLIED-P, AT-SIGN-MODIFIER-SUPPLIED-P, AND THE PREFIX-PARAMETERS, AND RETURNS NIL FOR A NON-NIL DESTINATION, OTHERWISE RESPONDING WITH A FRESH STRING COMPREHENDING THE OUTPUT. --- THIS FUNCTION'S SIGNATURE RENDERS IT ELIGIBLE FOR THE EMPLOYMENT AS A CUSTOM DIRECTIVE IN THE FORMAT FUNCTION." (DECLARE (TYPE DESTINATION DESTINATION)) (DECLARE (TYPE (INTEGER 1 100) OBJECT-TO-FORMAT)) (DECLARE (TYPE T COLON-MODIFIER-SUPPLIED-P)) (DECLARE (IGNORE COLON-MODIFIER-SUPPLIED-P)) (DECLARE (TYPE T AT-SIGN-MODIFIER-SUPPLIED-P)) (DECLARE (IGNORE AT-SIGN-MODIFIER-SUPPLIED-P)) (DECLARE (TYPE LIST PREFIX-PARAMETERS)) (DECLARE (IGNORE PREFIX-PARAMETERS)) (FORMAT DESTINATION "~&~:@(~A~)" (COND ((ZEROP (MOD OBJECT-TO-FORMAT 15)) "FIZZBUZZ") ((ZEROP (MOD OBJECT-TO-FORMAT 3)) "FIZZ") ((ZEROP (MOD OBJECT-TO-FORMAT 5)) "BUZZ") (T OBJECT-TO-FORMAT))) (VALUES)) (DEFUN EXECUTE-FIZZBUZZ () "EXECUTES A FIZZBUZZ PROGRAM WITH A COUNTER ASCENDING FROM INCLUSIVE ZERO (0) TO ONE HUNDRED (100) AND RETURNS NO VALUE." (LOOP FOR COUNTER OF-TYPE (INTEGER 1 101) FROM 1 TO 100 DO (FORMAT T "~/FIZZBUZZ/" COUNTER)) (VALUES)) (DEFUN PRINT-ACRONYM (TEXT) "GENERATES FOR THE TEXT THE CORRESPONDING ACRONYM, PRINTS IT TO THE STANDARD OUTPUT, AND RETURNS NO VALUE." (DECLARE (TYPE STRING TEXT)) (LET ((POSITION 0)) (DECLARE (TYPE FIXNUM POSITION)) (FLET ((SEPARATOR-P (CANDIDATE) "DETERMINES WHETHER THE CANDIDATE REPRESENTS A WORD SEPIMENT, RETURNING ON CONFIRMATION A BOOLEAN VALUE OF T, OTHERWISE NIL." (DECLARE (TYPE CHARACTER CANDIDATE)) (THE BOOLEAN (NOT (NULL (MEMBER CANDIDATE '(#\SPACE #\TAB #\-) :TEST #'CHAR=)))))) (TAGBODY CHOOSE-NEXT-ACTION (COND ((>= POSITION (LENGTH TEXT)) (GO END)) ((SEPARATOR-P (CHAR TEXT POSITION)) (GO SKIP-SEPARATOR)) (T (GO COLLECT-INITIAL))) SKIP-SEPARATOR (SETF POSITION (OR (POSITION-IF-NOT #'SEPARATOR-P TEXT :START POSITION) (LENGTH TEXT))) (GO CHOOSE-NEXT-ACTION) COLLECT-INITIAL (FORMAT T "~:@(~C~)" (CHAR TEXT POSITION)) (SETF POSITION (OR (POSITION-IF #'SEPARATOR-P TEXT :START POSITION) (LENGTH TEXT))) (GO CHOOSE-NEXT-ACTION) END))) (VALUES)) (DEFUN EXECUTE-ACRONYM-PROGRAM () "QUERIES THE USER FOR A LINE OF INPUT, GENERATES AND PRINTS THE CORRESPONDING ACRONYM, AND RETURNS NO VALUE." (FORMAT T "~&LET US GENERATE AN ACRONYM: ") (FINISH-OUTPUT) (PRINT-ACRONYM (READ-LINE)) (CLEAR-INPUT) (VALUES)) (DEFUN EXECUTE-ACTION (TOKEN) "EXECUTES THE FUNCTION ASSOCIATED WITH THE COMMAND TOKEN, OR SIGNALS AN ERROR OF AN UNSPECIFIED TYPE UPON ITS DISRESPONDENCY." (DECLARE (TYPE STRING TOKEN)) (COND ((STRING= TOKEN "HW") (PRINT-HELLO-WORLD)) ((STRING= TOKEN "99") (PRINT-99-BOTTLES-OF-BEER)) ((STRING= TOKEN "CT") (EXECUTE-CAT-PROGRAM)) ((STRING= TOKEN "FB") (EXECUTE-FIZZBUZZ)) ((STRING= TOKEN "??") (EXECUTE-ACRONYM-PROGRAM)) (T (ERROR "INVALID COMMAND TOKEN: ~S." TOKEN))) (VALUES)) (DEFUN WHITESPACE-CHARACTER-P (CANDIDATE) "DETERMINES WHETHER THE CANDIDATE REPRESENTS A WHITESPACE, RETURNING ON CONFIRMATION A BOOLEAN VALUE OF T, OTHERWISE NIL." (DECLARE (TYPE CHARACTER CANDIDATE)) (THE BOOLEAN (NOT (NULL (MEMBER CANDIDATE '(#\NEWLINE #\SPACE #\TAB) :TEST #'CHAR=))))) (DEFUN SKIP-WHITESPACES (SOURCE START) "PROCEEDING FROM THE START POSITION INTO THE SOURCE, SKIPS A SEQUENCE OF ZERO OR MORE ACCOLENT WHITESPACES, AND RETURNS THE LOCATION IN THE SOURCE OF THE FIRST NON-WHITESPACE CHARACTER." (DECLARE (TYPE STRING SOURCE)) (DECLARE (TYPE FIXNUM START)) (THE FIXNUM (LOOP FOR POSITION OF-TYPE FIXNUM FROM START BELOW (LENGTH SOURCE) WHILE (WHITESPACE-CHARACTER-P (CHAR SOURCE POSITION)) FINALLY (RETURN POSITION)))) (DEFUN INTERPRET-!! (CODE) "INTERPRETS THE PIECE OF !! SOURCE CODE AND RETURNS NO VALUE." (DECLARE (TYPE STRING CODE)) (LET ((POSITION 0)) (DECLARE (TYPE FIXNUM POSITION)) (LOOP INITIALLY (SETF POSITION (SKIP-WHITESPACES CODE POSITION)) WHILE (< POSITION (LENGTH CODE)) FOR TOKEN-END-POSITION OF-TYPE FIXNUM = (MIN (+ POSITION 2) (LENGTH CODE)) DO (EXECUTE-ACTION (SUBSEQ CODE POSITION TOKEN-END-POSITION)) (SETF POSITION (SKIP-WHITESPACES CODE TOKEN-END-POSITION)))) (VALUES))