Skip to content

Instantly share code, notes, and snippets.

@krishnabhargav
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krishnabhargav/2a92da3f5f161c7da197 to your computer and use it in GitHub Desktop.
Save krishnabhargav/2a92da3f5f161c7da197 to your computer and use it in GitHub Desktop.
some clojure code to get some experts review it ..
(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