Skip to content

Instantly share code, notes, and snippets.

@greghelton
Created December 27, 2011 00: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 greghelton/1522322 to your computer and use it in GitHub Desktop.
Save greghelton/1522322 to your computer and use it in GitHub Desktop.
Clojure: add several rows or records or structs then print singly then in loop
(def account-info (hash-set
{:username "zak"
:balance 13.59
:member-since "2009-02-01"}
{:username "mak"
:balance 12.59
:member-since "2011-02-02"}
{:username "jak"
:balance 11.59
:member-since "2009-12-02"}))
(prn (first account-info))
(prn (first (rest account-info)))
(prn (first (next (rest account-info))))
(prn (type (first (next (rest account-info)))))
(defn loop-thru [n]
(if-not (empty? n)
(do (prn (first n))
(recur (rest n)))))
(loop-thru account-info)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment