Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@swannodette
Created August 12, 2011 01:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save swannodette/1141252 to your computer and use it in GitHub Desktop.
Save swannodette/1141252 to your computer and use it in GitHub Desktop.
patjava.clj
(ns match.java
(:refer-clojure :exclude [compile])
(:use [match.core]))
(extend-type java.util.Date
IPLookup
(p-val-at [this key]
(case key
:year (.getYear this)
:month (.getMonth this)
:date (.getDate this)
:hours (.getHours this)
:minutes (.getMinutes this)
nil)))
(comment
(let [x (java.util.Date. 2010 10 1 12 30)]
(match [x]
[{2009 :year month :month date :date}] [:a0 month date]
[{2010 :year month :month date :date}] [:a1 month date]))
;; [:a1 10 1]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment