Last active
May 12, 2019 19:52
-
-
Save aamedina/0ac69540b092c06d96cfe42d76591295 to your computer and use it in GitHub Desktop.
This describes an enumerated set of valid months in the calendar. I love how easy in Clojure it is to read, write, and reason about the "shape" of the data that flows through your code. An elegant, and rapidly evolving language.
This file contains hidden or 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
| (clojure.spec-alpha2/def ::חודש | |
| #{:חודש/ניסן | |
| :חודש/אייר | |
| :חודש/סיון | |
| :חודש/תמוז | |
| :חודש/אב | |
| :חודש/אלול | |
| :חודש/תשרי | |
| :חודש/חשון | |
| :חודש/מרחשון | |
| :חודש/כסלו | |
| :חודש/טבת | |
| :חודש/שבט | |
| :חודש/אדר | |
| :חודש/אדר-ראשון | |
| :חודש/אדר-שני}) | |
| (spec/defop days | |
| [n] | |
| `(spec/int-in ~n (inc ~n))) | |
| (spec/def :חודש/ניסן | |
| (days 30)) | |
| (spec/def :חודש/אייר | |
| (days 29)) | |
| (spec/def :חודש/סיון | |
| (days 30)) | |
| (spec/def :חודש/תמוז | |
| (days 29)) | |
| (spec/def :חודש/אב | |
| (days 30)) | |
| (spec/def :חודש/אלול | |
| (days 29)) | |
| (spec/def :חודש/תשרי | |
| (days 30)) | |
| (spec/def :חודש/חשון | |
| (spec/or :min (days 29) :max (days 30))) | |
| (spec/def :חודש/מרחשון | |
| (spec/or :min (days 29) :max (days 30))) | |
| (spec/def :חודש/כסלו | |
| (spec/or :min (days 29) :max (days 30))) | |
| (spec/def :חודש/טבת | |
| (days 29)) | |
| (spec/def :חודש/שבט | |
| (days 30)) | |
| (spec/def :חודש/אדר | |
| (spec/or :min (days 29) :max (days 30))) | |
| (spec/def :חודש/אדר-ראשון | |
| (days 30)) | |
| (spec/def :חודש/אדר-שני | |
| (days 29)) | |
| ;; dev> (spec/describe :חודש/ניסן) | |
| ;; => | |
| ;; (days 30) | |
| ;; dev> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment