Clojure lists can be created in one of two ways. The
list function can create a list, or you can
quote a literal list.
Lists are special because Clojure will treat them as calls. It expects the call to start with an operator, which is usually a function. The remaining items of the list are considered operands, meaning they become the function's arguments.
Clojure's special treatment of lists is why we cannot create a list literal directly. Quoting a list using
quote or its shorthand
' indicates that the list should not be evaluated.
Unlike some modern languages, Clojure lists are heterogeneous, meaning they can contain multiple types of items internally e.g.,
'(2 "a" "b" 3).
Unlike other Lisps, an empty list in Clojure is truthy and is not equivalent to
In this exercise you'll be writing code to process a list of programming languages you are planning to practice from Exercism platform.
You have six tasks.
Before you can add languages, you'll need to start by creating a new list. Define a function that returns an empty list.
(new-list) ;; => ()
As you explore Exercism and find languages you want to learn, you'll need to be able to add them to your list. Define a function to add a new language the beginning of your list.
You'll want to quickly check which language you just added. Define a function that returns the first language from your list.
(first-language '("Haskell" "Python")) ;; => "Haskell"
Sometimes you'll change your mind about a language you just added. Define a function to remove the first language from your list.
(remove-language '("Common Lisp" "Racket" "Scheme")) ;; => '("Racket" "Scheme")
Counting the languages one-by-one is inconvenient. Define function to count the number of languages on your list.
(count-languages '("C#" "Racket" "Rust" "Ruby")) ;; => 4
learning-list function, within which you will use the some of the functions you've defined above.
Create an empty list
Add 2 new programming languages to the list.
Remove "Lisp" from the list, as you might not have enough time for the year, and it's quite similar to Clojure.
Add 2 more programming languages to the list.
Return the total number of languages. Hint: it should be 3.
(learning-list) ;; => 3