Tracks on Tracks on Tracks
Tracks on Tracks on Tracks

Tracks on Tracks on Tracks

Learning Exercise


In Clojure, Lists are collections, just as like lists in other languages. Similar to other languages in the Lisp family, Clojure uses parentheses to express lists.

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 nil or false.


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.

1. Create a new list

Before you can add languages, you'll need to start by creating a new list. Define a function that returns an empty list.

;; => ()

2. Add a new language to the 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.

(add-language '("Clojurescript") "JavaScript")
;; => '("JavaScript" "Clojurescript")

3. Check the language last added

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"

4. Remove the first language from the list

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")

5. Count the languages in the list

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

6. Put it all together

Define a 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.

    • "Clojure"
    • "Lisp"
  • 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.

    • "Java"
    • "JavaScript"
  • Return the total number of languages. Hint: it should be 3.

;; => 3
Edit via GitHub The link opens in a new window or tab
Clojure Exercism

Ready to start Tracks on Tracks on Tracks?

Sign up to Exercism to learn and master Clojure with 12 concepts, 88 exercises, and real human mentoring, all for free.