Go Fish/PicoLisp: Difference between revisions

Feature: Sort user cards when shown; Flush output for Picolisps that do not fush their "prin"s in Windows console (Ersatz)
mNo edit summary
(Feature: Sort user cards when shown; Flush output for Picolisps that do not fush their "prin"s in Windows console (Ersatz))
Line 3:
<lang PicoLisp>(de *Ranks
Ace 2 3 4 5 6 7 8 9 10 Jack Queen King )
 
(de goFish ()
(let
Line 18:
(loop
(prin "Your Books: ")
(flush)
(println YourBooks)
(prin "My Books: ")
(flush)
(println MyBooks)
(T (nor Your Mine Ocean)
Line 29 ⟶ 31:
(T "I won!") ) ) ) )
(prin "You have ")
(println Yourflush)
(println (sort Your))
(prinl "I have " (length Mine) " cards")
(loop
Line 36 ⟶ 39:
"Ask for a rank, lay down a book, or 'draw' a card: "
"Ask for a rank or lay down a book: " ) )
(flush)
(T (member (setq Reply (read)) *Ranks)
(ifn (filter = Mine (circ Reply))
Line 42 ⟶ 46:
(push 'YouHave Reply) )
(prin " I give you ")
(flush)
(println @)
(setq
Line 54 ⟶ 59:
((atom Reply)
(prin " The rank must be one of ")
(flush)
(println *Ranks) )
((and (cdddr Reply) (member (car Reply) *Ranks) (not (cdr (uniq Reply))) (= (length Your) (length (append (diff Your Reply) Reply))))
(prin " You lay down the book ")
(flush)
(println (push 'YourBooks Reply))
(setq
Line 76 ⟶ 83:
(loop
(prin "Please give me all your " Request "s (or NIL): ")
(flush)
(NIL (setq Reply (read))
(push 'YouDont Request)
Line 95 ⟶ 103:
(let B (need 4 @)
(prin " I lay down the book ")
(flush)
(println (push 'MyBooks B))
(setq Mine (diff Mine B)) ) )