Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a lisp function ask-and-tell that processes simple sentences. It should al

ID: 3773020 • Letter: W

Question

Write a lisp function ask-and-tell that processes simple sentences. It should allow you to enter lists that represent assertions, such as (Mary likes hiking) or (Steve hates pretzels), as well as questions such as (Does Mary like hiking) or (Does Steve like pretzels). The assertions should all have a proper name (e.g., Mary) in the first position, the word likes or hates in the second position, and either an activity (e.g., hiking) or and object (e.g., pretzels) in the last position. The questions should be similar, except that they begin with the word Does. The function should remember the assertions you give it, and answer your questions appropriately. If you repeat an assertion, it should let you know that; if you enter a contradictory assertion, it should alert you to that, and confirm that you’re sure before making the change. E.g., > (ask-and-tell ‘(mary likes hiking) )

“OK”

>(ask-and-tell ‘(steve hates pretzels) )

“OK”

>(ask-and-tell ‘(does mary like hiking) )

“YES”

>(ask-and-tell ‘(does mary like pretzels) )

“I DON’T KNOW”

>(ask-and-tell ‘(mary likes hiking) )

“I KNOW THAT ALREADY”

>(ask-and-tell ‘(does steve like pretzels) )

“NO”

>(ask-and-tell ‘(mary hates hiking) )

“YOU’VE CHANGED YOUR MIND …

ARE YOU SURE?”

no “OK”

>(ask-and-tell ‘(does mary like hiking) )

“YES”

>(ask-and-tell ‘(mary hates hiking) )

“YOU’VE CHANGED YOUR MIND …

ARE YOU SURE?”

yes “OK”

>(ask-and-tell ‘(does mary like hiking) )

“NO”

Explanation / Answer

>(ask-and-tell ’(does mary like pretzels))
"I DON’T KNOW"
>(ask-and-tell ’(mary likes hiking))
"I KNOW THAT ALREADY"
>(ask-and-tell ’(does steve like pretzels))
"NO"
>(ask-and-tell ’(mary hates hiking))
"YOU’VE CHANGED YOUR MIND. ARE YOU SURE?" no "OK"
>(ask-and-tell ’(does mary like hiking))
"YES"
>(ask-and-tell ’(mary hates hiking))
"YOU’VE CHANGED YOUR MIND. ARE YOU SURE?" yes "OK"
>(ask-and-tell ’(does mary like hiking))
"NO"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote