daboone1972

daboone1972

Programming Clojure, Fourth Edition: General Introduction defn blank (p. 4)

So I have the 3rd edition hard copy which is how as a newbie I was confident there was an error.

I’m comming back to Clojure for fun so thought I’d get the latest edition and start with that.

In the 4th edition PDF I have. I haven’t seen the printed copy yet.

(defn blank? [str]
  (every? Character/isWhitespace str))

Versus the 3rd edition in the Clojure is Elegant seciton and inside the examples downloaded source.

(defn blank? [str]
  (every? #(Character/isWhitespace %) str))

Which works. It makes me wonder how the book was made if it was from a LaTex source file say and the examples were sourced from an old zip. That would mean every errata that applied to the early 3rd editionalso applies to the fourth edition. If each chapter is generated unique and the examples are hard wired then errors could be confined to each chapter.

That’s all.

Daniel

First Post!

daboone1972

daboone1972

I mentioned this in a Discord and someone pointed out to me it’s a Clojure version problem.

The code works fine in 1.12.5

Clojure 1.12.5
(defn blank? [str]
  (every? Character/isWhitespace str))
#'user/blank?
(def blank-string "")
#'user/blank-string
(blank? blank-string)
true
user=>

But you do get an error with 1.10

 lein repl
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
nREPL server started on port 39471 on host 127.0.0.1 - nrepl://127.0.0.1:39471
REPL-y 0.4.3, nREPL
Clojure 1.10.1
OpenJDK 64-Bit Server VM 19.0.2+7-Ubuntu-0ubuntu322.04
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

user=> (defn blank? [str]
  #_=>   (every? Character/isWhitespace str))
Syntax error compiling at (REPL:2:3).
Unable to find static field: isWhitespace in class java.lang.Character

So that suggests the only issue I had was the source I downloaded was out of sync with that in the book. I just redownloaded the source now and it is correct in the introduction.clj

I attempted to learn Clojure a while ago and started with lein so returned to it thinking Clojure was relatively stable so code examples should work between versions.

So we’re all good at the moment just use clj or clojure > 1.12 and you’ll be fine.

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
New
iPaul
page 37 ANTLRInputStream input = new ANTLRInputStream(is); as of ANTLR 4 .8 should be: CharStream stream = CharStreams.fromStream(i...
New
GilWright
Working through the steps (checking that the Info,plist matches exactly), run the demo game and what appears is grey but does not fill th...
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
curtosis
Running mix deps.get in the sensor_hub directory fails with the following error: ** (Mix) No SSH public keys found in ~/.ssh. An ssh aut...
New
jskubick
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint. How to replicate: load chapter-7 from zipfile i...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
brunogirin
When trying to run tox in parallel as explained on page 151, I got the following error: tox: error: argument -p/–parallel: expected one...
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New

Other popular topics Top

dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
Rainer
My first contact with Erlang was about 2 years ago when I used RabbitMQ, which is written in Erlang, for my job. This made me curious and...
New
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
PragmaticBookshelf
Tailwind CSS is an exciting new CSS framework that allows you to design your site by composing simple utility classes to create complex e...
New
PragmaticBookshelf
Programming Ruby is the most complete book on Ruby, covering both the language itself and the standard library as well as commonly used t...
New
PragmaticBookshelf
Develop, deploy, and debug BEAM applications using BEAMOps: a new paradigm that focuses on scalability, fault tolerance, and owning each ...
New
PragmaticBookshelf
A masterclass in the fundamentals and principles of functional programming. Minh Quang Tran The Art of Functional Programming is a ma...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New

Sub Categories: