Created
July 31, 2017 13:24
-
-
Save mdallastella/59965ba34ded779852e79d2a9358e887 to your computer and use it in GitHub Desktop.
This file contains 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 sessions) | |
(defn create-sessions | |
"Initialize the session atom." | |
[] | |
(atom [])) | |
(defn put-session! | |
"Insert a session into the sessions atom." | |
[sessions session] | |
(swap! sessions conj session)) | |
(defn has-session? | |
"Check if there are at least one session." | |
[sessions] | |
(not (empty? @sessions))) | |
(defn read-session | |
"Read ALWAYS the first element of sessions. TO BE IMPROVED!" | |
[sessions] | |
(first @sessions)) | |
(defn reset-session! | |
"Reset the session atom." | |
[sessions] | |
(swap! sessions empty)) |
This file contains 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 sessions) | |
(defonce sessions (atom [])) | |
(defn put-session! | |
"Insert a session into the sessions atom." | |
[session] | |
(swap! sessions conj session)) | |
(defn has-session? | |
"Check if there are at least one session." | |
[] | |
(not (empty? @sessions))) | |
(defn read-session | |
"Read ALWAYS the first element of sessions. TO BE IMPROVED!" | |
[] | |
(first @sessions)) | |
(defn reset-session! | |
"Reset the session atom." | |
[] | |
(swap! sessions empty)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment