Created
July 27, 2014 19:05
-
-
Save xenophobia/254e0b0cce84cdfbf9b0 to your computer and use it in GitHub Desktop.
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
;; 従来のcard matcherをregular-card matcherにリネーム | |
(define $regular-card | |
(algebraic-data-matcher | |
{<card suit (mod 13)>})) | |
;; Joker入りcard matcher | |
;; (,<Joker>みたいなvalue typeは考えてない | |
;; 欲しけりゃプリミティブパターン節を一個追加すればいいと思うけど未検証) | |
(define $card | |
(matcher | |
{[<card $ $> [suit (mod 13)] | |
{[<Card $x $y> {[x y]}] | |
[<Joker> (concat (map (lambda [$x] (map (lambda [$y] [y x]) {<Spade> <Heart> <Club> <Diamond>})) (between 1 13)))]}] | |
;; Jokerは52種どんなカードとしてもマッチする。 | |
[$ [regular-card] {[$tgt {tgt}]}]})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment