My implementation is CLisp, by the way. I've only just started programming not long ago and I've only written so many little toy programs in my life.
Here's some code I have tried, it's incredibly messy and sort of just butchered from what it originally was as I tried to duct tape more mthods on to it to make it work.
- Code: Select all
(defun splitspace (str) ;I didn't write this, I found it somewhere. Sorry I couldn't give credit.
(loop for i = 0 then (1+ j)
as j = (position #\Space str :start i)
collect (subseq str i j)
while j))
(defun ffind (var)
(eval `(find ,var ',(splitspace (read)))))
(defun inp (what) ;(find) isn't working
(let ((in-list (splitspace (read))))
(find what in-list)))
(defun imp (str rstr) ;nothing's working
(eval `(map 'list #'string-equal ,str ',(splitspace rstr))))
I'm quite frankly exhausted and reached the end or my rope, I'm completely stuck. I'm just trying to write a chatbot, ultimately what I'd like for the input is a system that allows the user to simply type in a reply without putting quotes around it, then have it parse the input for specific words, and return those words as strings if it find them, maybe in a list. I've been trying to figure this out for days, I quickly gave up on the quote thing.
Also, I don't know how common this is, but I'm using a small custom REPL and (read-line) simply returns a blank string (like "") instead of prompting for input like it does when invoked in CLISP's REPL. So that hasn't been an option for me. And of course (read) freaks out when given more than one argument so I have to put quotes around the input.
I'm sorry if this is somewhat stupid or simple, as I've said, I've been trying this and searching for days. All I wanted was a simple chatbot! Any help at all will be nice.