Last active
August 29, 2015 14:06
-
-
Save krishnabhargav/2a92da3f5f161c7da197 to your computer and use it in GitHub Desktop.
some clojure code to get some experts review it ..
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
(ns trip.core | |
(:require [[clj-time.core :as t] | |
[clojure.set :as set]])) | |
(defn default-trip | |
"returns a default trip with current date as start date & end date as 5 days from now" | |
[] | |
{ :name "New Trip" | |
:description "Enter your trip description here" | |
:start-date (t/today) | |
:end-date (-> 5 t/days t/from-now) | |
:people #{}}) | |
(defn +people | |
"Adds a person to the trip" | |
[trip & persons] | |
(update-in trip [:people] | |
into persons)) | |
(defn -people | |
"Removes a person from the trip" | |
[trip & persons] | |
(update-in trip [:people] | |
set/difference persons)) | |
(comment | |
(-> (default-trip) | |
(assoc :name "NYC Trip" | |
:description "Fall trip to NYC" | |
:start-date (-> 2 t/days t/from-now) | |
:end-date (-> 9 t/days t/from-now)) | |
(+people "John" "Jason" "Krishna" "Raju")) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment