Chefs Kiss
- This article is not detailed enough and needs to be expanded. Please help us by adding some more information.
Basically just +-= but with emojis, and ASCII
Emoji | The other column |
---|---|
π | Add the Accumulator |
π | Decrease the Accumulator |
π | Print ASCII |
Also thought during class
Examples
Hello, World!
This program prints the message βHello, World!β to the standard output:
ππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππππ
Implementation
The following furnishes an implementation of the Chefs Kiss programming language in Common Lisp. Please note that the concrete character set deployed constitutes a dependency on the Common Lisp implementation; in corollary, Unicode support may or may not be a feature incorporated in the personal environment. The interpreter at hand has been developed and tested with Steel Bank Common Lisp (SBCL) version 1.1.4 as part of the Lisp Cabinet 0.3.5 bundle.
(defun interpret-Chefs-Kiss (code) "Interprets the piece of Chefs Kiss source CODE and returns no value." (declare (type string code)) (let ((accumulator 0)) (declare (type integer accumulator)) (loop for current-token of-type character across code do (case current-token (#\π (incf accumulator)) (#\π (decf accumulator)) (#\π (format T "~c" (code-char (mod accumulator 256)))) (otherwise (format T "~&Error!"))))) (values))
A parergal warklume shall be extended below, capacitating the construction of Chefs Kiss programs which print a certain message to the standard output:
(deftype destination () "Defines a sink for output operations." '(or null (eql T) stream string)) (defun print-several-times (character-to-print number-of-repetitions destination) "Prints the CHARACTER-TO-PRINT the NUMBER-OF-REPETITIONS times to the DESTINATION and returns no value." (declare (type character character-to-print)) (declare (type (integer 0 *) number-of-repetitions)) (declare (type destination destination)) (format destination "~v@{~a~:*~}" number-of-repetitions character-to-print) (values)) (defun generate-text-program (text &key (destination NIL)) "Generates a Chefs Kiss program that replicates the TEXT on the DESTINATION, returning for a non-NIL DESTINATION the NIL value, otherwise producing a fresh string with the resulting code." (declare (type string text)) (declare (type destination destination)) (the (or null string) (if destination (let ((accumulator 0)) (declare (type integer accumulator)) (loop for text-character of-type character across text do (let ((new-accumulator (char-code text-character))) (declare (type fixnum new-accumulator)) (cond ((< accumulator new-accumulator) (print-several-times #\π (- new-accumulator accumulator) destination)) ((= accumulator new-accumulator) NIL) ((> accumulator new-accumulator) (print-several-times #\π (- accumulator new-accumulator) destination)) (T (error "Unexpected relationship betwixt the current ~ accumulator state ~d and the intended ~d." accumulator new-accumulator))) (format destination "π") (setf accumulator new-accumulator)))) (with-output-to-string (chefs-kiss-code) (declare (type string-stream chefs-kiss-code)) (generate-text-program text :destination chefs-kiss-code)))))