ChipL (2) [Avatar] Offline
#1
I am slowly going through the book and find it is what I seek in to learn Clojure. I am making a point by point attempt of listing mistakes and potential corrections and list what I have so far following with hope of updating this as I go along.

Thank you for the great work in progress and here's wishing you much success.
ChipL (2) [Avatar] Offline
#2
Re: Proof reading
1.1 What is Clojure?

This unfamiliarity with Lisp syntax often causes people to get turned off the language, hence it is important to understand the reasoning behind its choice.

Correction: This unfamiliarity with Lisp syntax often causes people to get turned off to the language, hence it is important to understand the reasoning behind its choice.


1.1.3 How this book teaches Clojure

Programming in Clojure requires a new way of thinking, one that's probably very different from what you might be used to, depending your programming background. We will address this by focusing on the basics of
Lisp, on functional programming, and on understanding the new facilities provided by Clojure.

Correction: Programming in Clojure requires a new way of thinking, one that's probably very different from what you might be used to, depending on your programming background. We will address this by focusing on the basics of
Lisp, functional programming, and understanding the new facilities provided by Clojure.


1.2.2 Lists, vectors, and hashes

In order to make it easier to read and write Clojure code, it uses two other types of brackets - square brackets and braces, in addition to the parenthesis.

Correction: In order to make it easier to read and write Clojure code, it uses two other types of brackets - square brackets and braces, in addition to the parentheses.


1.3.1 Clojure as a Lisp

THE MACRO SYSTEM
It is easy to imagine writing code that transformed this data-structure into something else.

Correction: It is easy to imagine writing code that transforms this data-structure into something else.

THE REPL

In fact, in chapter 8, we’ll walk illustrate this by using the REPL along with creating unit-tests for a few functions, in a step-by-step manner.

Correction: In fact, in chapter 8, we’ll illustrate this by using the REPL along with creating unit-tests for a few functions in a step-by-step manner.


1.3.2 Clojure as a functional language

LAZY EVALUATION AND INFINITE SEQUENCES

Further, this implies that a chain of such functions calls return a value that is also lazy!

Correction: Further, this implies that a chain of such function calls returns a value that is also lazy!

Writing Clojure-like code in an other languages

Correction: Writing Clojure-like code in other languages


1.3.3 Clojure as a JVM-based language

CALLING JAVA FROM CLOJURE
It's trivial to use Java libraries from Clojure. For instance, here’s an example of using the a method on the string class to do some simple text manipulation:

Correction: For instance, here’s an example of using a method on the string class to do some simple text manipulation:


1.4 Clojure - beyond object orientation

Systems built this way are more flexible, and are more resilient to changing requirements.

Correction: Systems built this way are more flexible and resilient to changing requirements.


1.5 Summary

Further, the macro system can be used for good or bad. You explored some of its power in this chapter, and there’s more throughout book.

Correction: Further, the macro system can be used for good or bad. You explored some of its power in this chapter, and there’s more throughout this book.

However, it's important to realize that macros aren’t functions, specific they don’t compose very well.

Correction: However, it's important to realize that macros aren’t functions. They don’t compose well.


2.1.5 A few more points on Clojure syntax

PREFIX NOTATION
Clojure code uses prefix notation (also called polish notation) to represent function calls. For those that are new to Lisp, this definitely takes a little getting used to, especially when it comes to using math functions such + / * etc.

Correction: For those who are new to Lisp, this definitely takes a little getting used to, especially when it comes to using math functions such as + / * etc.


2.2.3 side-effects with do

Of course, the real world is full of state and side effects are a necessity.

Correction: Of course, the real world is full of state alterations and side effects are a necessity.


2.3.4 Functional iteration
DOSEQ, DOTIMES
in sample code: (run-reports user)))

Correction: (run-report user)))

In the case above, dispatchreporting-jobs will call run-reports for each user present in the sequence all-users.

Correction: In the case above, dispatchreporting-jobs will call run-report for each user present in the sequence all-users.


2.3.4 Functional iteration
FOR
Similar to doseq, for is used for list comprehensions, which is a syntactic feature that allows sequences to be constructed out of existing ones. The general form of the for construct is as follows:

Correction: First and third instances of "for" need to be of a different font that signifies code.

The for seq-exprs can take modifiers :let, :when, and :while. To see an example of :when in use, let us first consider a function that checks to see if a number is prime –

Correction: First "for" needs to be of a font signifying code.

Now let’s use for to write a function primes-less-than which returns a list of all primes between 2 and the number passed in:

Correction: First "for" needs to be of a font signifying code.

Now let’s use for to write a function primes-less-than which returns a list of all primes between 2 and the number passed in:
(defn primes-less-than [n]
(for [x (range 2 (inc n))
:when (prime? x)]
x))

Correction: (for [x (range 2 n)

(defn pairs-for-primes [n]
(let [z (range 2 (inc n))]
(for [x z y z :when (prime? (+ x y))]
(list x y))))

Correction: (let [z (range 2 n)]

((2 3) (2 5) (3 2) (3 4) (4 3) (5 2))

Correction: ((2 3) (3 2) (3 4) (4 3))


2.4.4 Sequences

Maps
If any nested map doesn’t exist along the way, they get created and correctly associated. The next convenience function reads values out such nested maps.

Correction: If any nested maps don’t exist along the way, they get created and correctly associated. The next
convenience function reads values out of such nested maps.


3.1.1 Defining functions

Note that in this case, the function didn’t compute the result, but instead threw an AssertionError error
with an explaination of which condition failed.

Correction: Note that in this case, the function didn’t compute the result, but instead threw an AssertionError error with an explanation of which condition failed.

Having seen how to define pre and post conditions to functions, lets look at a more modular way of
approaching this.

Correction: Having seen how to define pre and post conditions for functions, lets look at a more modular way of
approaching this.

basic-line-item is defined without any conditions, and is clearly focused only on the business logic of
calculating the line-item total.

Correction: basic-item-total is defined without any conditions, and is clearly focused only on the business logic of calculating the basic-item-total.

MULTIPLE ARITY
The arity of a function is the number of operand it accepts.

Correction: The arity of a function is the number of operands it accepts.


3.1.3 Higher-order functions
PARTIAL
Consider the following function that accepts two parameters threshold and number, and it checks to
see if number is greater than threshold:

Correction: "number" and "threshold" need to be in font signifying code.

MEMOIZE
Calling it via with a call to time tells us how long it is taking to run –

Correction: Calling with time tells us how long it is taking to run –

In order for memorize to do its thing, let’s call fast-calc once with a set of arguments (say 5 and 7).

Correction: In order for memoize to do its thing, let’s call fast-calc once with a set of arguments (say 5 and 7).