I´m a beginner of c. Lisp and actually i´ve got some problems with my first code. The topic was a "dicegame" with random numbers. If you get two 1 you win or if you get two 6 you also win.
First i´ve worte this code:
(defun dice ()
(+(random 6)1))
(defun dicegame(dice dice)
(and
(and
(or
(equal (print(dice)) 1)
(equal (print(dice)) 6)
)
(or
(equal (print(dice)) 1)
(equal (print (dice))6)
)
)
(or(equal (print(dice))(print(dice))))
)
)
(dicegame (dice) (dice))
it isn´t working. I get results with 6 numbers which are nil and i get results with for ex. 3 5 4 5 3 4 which are true. I don´t get that.
Than I wrote a new one which is working:
(defun dicegame-s(dice dice)
(or
(and
(equalp (print(dice)) 1)
(equalp (print(dice)) 1)
)
(and
(equalp (print(dice)) 6)
(equalp (print(dice)) 6)
)
))
My question is: why is the first one not working and the second one is working.
Thanks!
Aucun commentaire:
Enregistrer un commentaire