A Clojure Story - Collections (Lists)
Being fairly new to clojure ecosystem. I thought it would be better to be dedicating a post to each of the data structures in Clojure.
Clojure has the following data structures
These are concrete data types, which are implementation of abstract data types.
This post will try to scratch the surface of - LISTS
LISTS⌗
As the name goes, are a collection of group of values.
Funny thing, by mistake I typed this in the repl.
Turns out ` is for denoting ‘Cons’ which is another list-like structure in LISP. The term ‘cons’ is derived from “constructing a pair”, where these pairs could then be chained together to build a list. Will dig in deep for more about it
Operations on LISTS⌗
Lists are comparable
We can modify lists by conjoing on it, this operation adds the element to the front of the list Because lists function as a singly linked list in clojure, insertion of an element occurs at the front of the list.
Lists are suitable for small collections and can be slow in getting elements.
For faster access to every element we would look at VECTORS
(or Arrays as we know) in the next post.