Last active
December 19, 2015 07:09
-
-
Save azolotko/5916639 to your computer and use it in GitHub Desktop.
Write the rules of the rock-paper-scissors game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns rock-paper-scissors.core | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defrel beats hand1 hand2) | |
(facts beats [[:rock :scissor] [:paper :rock] [:scissor :paper]]) | |
(defn play [hand1 hand2] | |
(run* [result] | |
(conde | |
((beats hand1 hand2) (== result :victory)) | |
((beats hand2 hand1) (== result :loss)) | |
((== hand1 hand2) (== result :tie))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment