40 lines
985 B
Plaintext
Executable File
40 lines
985 B
Plaintext
Executable File
#!/usr/local/bin/picolisp /usr/local/lib/picolisp/lib.l
|
|
|
|
(setq *Testlen 2)
|
|
|
|
(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) )
|
|
) )
|
|
|
|
(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")) ) ) )
|
|
|
|
(seed (time))
|
|
(setq *Test (make (do *Testlen (NIL *Questions)
|
|
(let (N (rand 1 (length *Questions)))
|
|
(link (get *Questions N))
|
|
(setq *Questions (remove N *Questions)) ) ) ) )
|
|
|
|
(setq *Right 0)
|
|
|
|
(mapc '((Q)
|
|
(in NIL
|
|
(let (A (ask Q))
|
|
(when (car A)
|
|
(inc '*Right) )
|
|
(prinl (cadr A)) ) ) )
|
|
*Test)
|
|
|
|
(msg 'Score: " " *Right '/ *Testlen)
|
|
(bye)
|