May 2018
Beginner to intermediate
290 pages
6h 43m
English
As you might expect, it’s easy to find very familiar-looking examples of if, when, cond, and case. Here, for instance, are a few lines pulled from Leiningen:
| | (when (real-directory? f) |
| | (doseq [child (.listFiles f)] |
| | (delete-file-recursively child silently))) |
We may not follow the details, but the general idea of this code is not hard to work out: when f is a real directory—that is, not a file or a symbolic link—then delete it and all of its contents.
Here’s another snippet, also from Leiningen:
| | (if (.isDirectory entry) |
| | (.mkdirs f) |
| | (do (.mkdirs (.getParentFile f)) |
| | (io/copy (.getInputStream jar entry) f))) |
If entry is a directory, then do this; otherwise do something else.
Dot What? | |
|---|---|
|
The reason for the funny un-Clojurelike ... | |
Read now
Unlock full access