Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clojure example of lightweight data modelling
(ns cljtests.data)
(defn main []
(let [some-items [1 2 3 4]
some-mapping {:ST "started", :IP "in progress", :DN "done"}]
(doseq [item some-items]
(println item))
(doseq [[key val] some-mapping]
(println (str key " => " val)))))
(defn -main
[& args]
(main))
@amontalenti

This comment has been minimized.

Copy link
Owner Author

commented Dec 24, 2013

The starting point for this discussion was:

https://gist.github.com/amontalenti/8114359

Then, @jpfuentes2 shared this example, which is similar but doesn't quite capture the same thing as the Java & Python examples, IMO:

https://gist.github.com/jpfuentes2/8117271

This is a rewrite of that example to be closer.

Here's the full set:

Python: https://gist.github.com/amontalenti/8114383
Java: https://gist.github.com/amontalenti/8114359
Clojure: https://gist.github.com/amontalenti/8117294
Scala: https://gist.github.com/csoma/8115672
C++11: https://gist.github.com/csoma/8115693

@jpfuentes2

This comment has been minimized.

Copy link

commented Dec 24, 2013

Nice, that example is certainly more symmetrical. Minor suggestion:

Place all trailing parentheses on a single line instead of distinct lines.

From https://github.com/bbatsov/clojure-style-guide

@amontalenti

This comment has been minimized.

Copy link
Owner Author

commented Dec 25, 2013

Thanks! Updated to reflect that style consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.