Hi,
Presumably you are using 'head' to get the first element of a list.
However, there is no function 'head' for lists.
see: https://docs.racket-lang.org/reference/pairs.html
Try using 'first' and 'rest' instead of 'head' and 'tail'.
George
On 2/24/2021 3:55 PM, IF Karona wrote:
Hi everyone,
After trying to implement some changes Sage suggested (all errors are
my own), I am now encountering the following message (courtesy of
DrRacket):
"head: unbound identifier in: head"
Could someone help me find a fix?
As before, I welcome suggestions on how to better do this the
functional programming way.
Karona
;example.rkt
#lang racket
(require racket/match)
(struct message (str sender recipient))
(define (say chat-history m)
(cons m
chat-history))
(define (log chat-history m)
(cons m
chat-history))
(let loop ()
(display "Input: ")
(define input (message (read-line (current-input-port) 'any)
"participant" "me"))
(define str (message-str input))
(log chat-history input)
(cond
[(regexp-match #px"(?i:Hello,* world!)" str)
(say chat-history (message "I would not know about the rest of
the world, but I can hear \
you just fine." "me" "participant" "me" "participant"))]
[(regexp-match #px"(?i:I( am|'m) learning how to program in
Racket,* world!)" str)
(say chat-history (message "Racket is a great language, and it is
lovely that you are \
learning it, but does literally everyone need to know?" "me"
"participant"))]
[(regexp-match #px".*,+\\s*world!" str)
(say chat-history (message "Did the whole world really need to
hear that?" "me" "participant"))]
[else (say chat-history (message "Did you really just say
something without addressing the \
world? I am so proud of you! :,)" "me" "participant"))])
(define hd (head chat-history))
(define s (message-str hd))
(printf "Chatbot: ~a\n" s)
(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 racket-users+unsubscr...@googlegroups.com
<mailto:racket-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/ae6488a3-3b70-4de7-8a1f-8f5526e63580n%40googlegroups.com
<https://groups.google.com/d/msgid/racket-users/ae6488a3-3b70-4de7-8a1f-8f5526e63580n%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-users/1323324c-372f-ff37-efdb-d888d2c223dc%40comcast.net.