Today I will look at Maps, one of the most important collection types in Clojure. Maps are collections of key-value pairs. Keys can be of any type in Clojure including functions, lists, other maps etc. The are 3 types of maps in Clojure: Hash Maps, Sorted Maps and Array Maps. Sorted maps keep the key value pairs in a certain order which implies that a lookup time may not be constant and it also allows you to traverse the values in the order of the keys. Sorted maps have a constraint in that the keys have to be comparable.
Tuesday, September 08, 2020
#100DaysOfClojure (Day [9] Maps)
Monday, September 07, 2020
#100DaysOfClojure (Day [8] Vectors)
Vector is another collection data structure that allow random access and add new elements to the end of the collection.
Sunday, September 06, 2020
#100DaysOfClojure (Day [7] (lists))
The Clojure programming language is designed around data processing which includes the code as data. Today I get into the very foundations of programs in Clojure, the collection data structures. Remember that data in Clojure is immutable so in order for Collections to be efficient they need to be persistent, which means that all the copies have to share the common data. The are 4 collection types, Lists, Vectors, Maps and Sets. And these collections share a set of core functions :
- conj - returns a new list with the new add item added
- seq - returns sequence to of the collection
- count - return the number of items in a collection
- empty - returns an empty collection of the same type
- = - determine the value equality of one or more collections
Saturday, September 05, 2020
#100DaysOfClojure (Day [6] Functions Continued)
Today I am continuing with 3 more useful function concepts: How to define functions, anonymous functions and using apply with functions
Friday, September 04, 2020
#100DaysOfClojure (Day [5] Functions)
The excitement is building up, today I played with functions. A Clojure function has the following structure
Thursday, September 03, 2020
#100DaysOfClojure (Day [4] Basics)
Today I can dip my toes into the language itself. I will be looking at the some of the syntax and forms, Clojure refers to valid code as forms. Clojure has literals which consist of primitive data types, symbols and collections.
Wednesday, September 02, 2020
#100DaysOfClojure (Day [3] IntelliJ + Cursive)
With the wide variety of editors/ides available, it was a difficult decision to make. So how did I make this decision you ask? I made the decision based on the quality of the documentation and my familiarity with the editor. Hence I chose IntelliJ and the Cursive plugin. Cursive provide 3 licenses, personal, commercial and non-commercial. Since I am only using it to learn Clojure, I chose the non-commercial licence which is a free 6 month renewable licence.
Tuesday, September 01, 2020
#100DaysOfClojure : (+ Day [2] Tools)
Today was a busy and tiring day, so I decided to keep it light and explore the tools available for Clojure. The first tool of importance is Leiningen. It is a build automation and dependency management tool for the Clojure programming language written in Clojure itself. It integrates well with Maven repositories and the Clojars repository for Clojure libraries. On an Apple Mac you can install Leiningen very easily using homebrew.
- The ability to create projects
- Compile and package projects
- Run projects
- Run tests
- And more….
- Emacs with Cider plugin
- Atom with nrepl
- Cursive plugin for IntelliJ
- Nightcode
- Counterclockwise a plugin for Eclipse
- Vim with plugins
- Light table
- SublimeText with SublimeREPL
- Netbeans Clojure
- VS Code with Calva plugin