Hi everyone,
I am new here, and I have a couple of questions related to the code that
follows this message.
1. I want to learn functional programming. When it comes to solving the
problem of making a simple chatbot such as this, is there an approach that
is more consistent with functional programming?
2. I would prefer to not have to use multiple spaces every time I want to
indent. Does Dr. Racket have anything comparable to the tab functionality
of other programs?
Thank you for letting me join your community!
Karona
;example.rkt
#lang racket
(require racket/match)
(define (say str)
(printf "Chatbot: ~a\n" str))
(define (handle-input str)
(cond
[(regexp-match #px"(?i:Hello,* world!)" str)
(say "I would not know about the rest of the world, but I can
hear \
you just fine.")]
[(regexp-match #px"(?i:I( am|'m) learning how to program in
Racket,* world!)" str)
(say "Racket is a great language, and it is lovely that you are
\
learning it, but does literally everyone need to know?")]
[(regexp-match #px".*,+\\s*world!" str)
(say "Did the whole world really need to hear that?")]
[else (say "Did you really just say something without addressing
the \
world? I am so proud of you! :,)")]))
(let loop ()
(display "Input: ")
(define str (read-line (current-input-port) 'any))
(handle-input str)
(loop))
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/2f107ab5-2efd-4c33-83f6-eb5751664cb6n%40googlegroups.com.