Getting started

Download cs340-lab16.zip. It is an Eclipse project, so you can import it into Eclipse using File→Import…→General→Existing projects into workspace→Archive file. You should see a project called clojure-review in your Eclipse workspace.

Your task

This is a Clojure review lab. It is intended to prepare you for Exam 2.

Complete the make-pair, double-apply, double-applicator, my-flatten, and conj-all functions in src/clojure_review/core.clj. Each function is described by a detailed comment with example inputs and expected results.

You can test your functions by running the command lein test in a terminal window from the root of the project.

You can also start a Clojure REPL (in Eclipse) by right-clicking in core.clj and choosing Clojure→Load file in REPL. This is very useful for testing your functions interactively.

Important: make sure you follow the requirements for each function. For example, my-flatten must be recursive, and conj-all must be tail recursive. Trivial solutions (e.g., (defn my-flatten [a-seq] (flatten a-seq)) are not acceptable.

Resources you may use

You may use your textbook, the course website, the Clojure MOOC website, the clojure.org website, and the clojuredocs.org website.

Solutions

Here are my solutions: lab16.clj. Do not look at these until you have completed all of the functions on your own.