From c0f3006a7fcb75d29c4ae17ddaf5ac33111ebf23 Mon Sep 17 00:00:00 2001 From: Mike Small Date: Mon, 5 Oct 2020 08:08:16 -0400 Subject: [PATCH] add ask fn and change representation Using lists of symbols instead of strings may help when recognizing answers that are right but not textually identical. --- citizenship.l | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/citizenship.l b/citizenship.l index f07ec16..8dfd343 100644 --- a/citizenship.l +++ b/citizenship.l @@ -1,11 +1,19 @@ #!/usr/local/bin/picolisp /usr/local/lib/picolisp/lib.l (setq *Questions - (("How old do citizens have to be to vote for President?" - "18" ) - ("What happened at the Constitutional Convention?" - "The Constitution was written" ) - ("Where is the Statue of Liberty?" - "New York Harbor") -)) + '(((How old do citizens have to be to vote for President?) + (18) ) + ((What happened at the Constitutional Convention?) + (The Constitution was written) ) + ((Where is the Statue of Liberty?) + (New York Harbor) ) + ) ) + +(de ask (Question) + (prinl (str (car Question))) + (let (Answer (str (line T)) + Actual (cadr Question)) + (cond + ((= Answer Actual) '(T "Exactly right")) + (T '(NIL "Wrong or unrecognized")) ) ) )