Skip to content

Instantly share code, notes, and snippets.

@luxbock luxbock/handrange.clj Secret
Created Aug 13, 2015

Embed
What would you like to do?
(deftype HandRange [^IPersistentMap hrange]
s/IHandRange
(add-hand [this hand] (add-hand* this hand))
(remove-hand [this hand] (HandRange. (dissoc hrange hand)))
(set-freq [this hand fq] (HandRange. (assoc hrange hand fq)))
(hands [this] (keys hrange))
(freqs [this] (vals hrange))
(get-hand [this hand] (get hrange hand 0.0))
clojure.lang.IPersistentMap
(assoc [this k v] (s/set-freq this k v))
(assocEx [this k v] (throw (Exception.)))
(without [this k] (HandRange. (.without hrange k)))
clojure.lang.Associative
(containsKey [this k] (.containsKey hrange k))
(entryAt [this k] (.entryAt hrange k))
clojure.lang.IPersistentCollection
(count [this] (.count (filter (comp pos? val) hrange)))
(cons [this hand] (s/add-hand this hand))
(empty [this] (HandRange. {}))
(equiv [this o]
(and (isa? (class o) HandRange)
(.equiv hrange (.hrange o))))
clojure.lang.Seqable
(seq [this] (.seq hrange))
clojure.lang.Counted
(count [this] (count (filter (comp pos? val) hrange)))
clojure.lang.ISeq
(first [this] (first hrange))
(next [this] (next hrange))
(more [this] (rest hrange))
java.lang.Iterable
(iterator [this] (.iterator hrange))
clojure.lang.ILookup
(valAt [this hand] (s/get-hand this hand))
(valAt [this hand not-found] (throw (Exception. "Not supported.")))
clojure.lang.IFn
(invoke [this hand] (s/get-hand this hand)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1. Unhandled java.lang.AbstractMethodError
(No message)
RT.java: 748 clojure.lang.RT/get
ranges2.clj: 26 hermes.game.ranges2.HandRange/get_hand
REPL: 1 hermes.game.ranges2/eval42720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.