Created
August 19, 2022 10:53
-
-
Save lambduli/292df213d6b34f6b21eaf4308d6c279d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
#| | |
Data: 06/07/202 | |
Author: Lambduli | |
github: @lambduli | |
This script is intended for teachers and students. | |
If you are a teacher and frequently ask your students to write some Racket code in front of the class, you can thank them / give them compliment with this script when they are done. | |
It produces simple asciiart robo-head saying encouraging words - like this one: | |
;__________ | |
;| _ _ | ______________ | |
;|(^) (^) | / | | |
;| o | / Nicely done! | | |
;| \___/ | \_______________| | |
;+---------+ | |
License: MIT/Apache 2 | |
|# | |
(require quickscript) | |
(define (robot-say message) | |
(string-append | |
";__________" | |
"\n;| _ _ | _" (build-string (+ 1 (string-length message)) (lambda (i) #\_)) | |
"\n;|(^) (^) | / " (build-string (+ 1 (string-length message)) (lambda (i) #\ )) "|" | |
"\n;| o | / " message " |" | |
"\n;| \\___/ | \\__" (build-string (+ 1 (string-length message)) (lambda (i) #\_)) "|" | |
"\n;+---------+" | |
) | |
) | |
; you are free to add more compliments | |
(define (compliments) | |
`( | |
"Good job!" | |
"Nice one!" | |
"Outstanding move!" | |
"Amazing form!" | |
"Perfection!" | |
"Nicely done!" | |
"Just perfect!" | |
) | |
) | |
(define (give-compliment n) | |
( | |
letrec ( | |
[ lst (compliments)] | |
[ index (modulo n (length lst)) ] | |
) | |
(list-ref lst index) | |
) | |
) | |
(define-script robopat | |
#:label "robopat" | |
(λ (selection) | |
(string-append (robot-say (give-compliment (string-length selection))) "\n" selection) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment