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
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.
Popular Pragmatic Bookshelf topics
Modern front-end development for Rails, second edition - Struggling to get the first chapter to work
Other popular topics
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /java
- /clojure
- /emacs
- /haskell
- /typescript
- /svelte
- /onivim
- /kotlin
- /c-plus-plus
- /crystal
- /tailwind
- /react
- /gleam
- /ocaml
- /elm
- /flutter
- /vscode
- /html
- /ash
- /deepseek
- /zig
- /opensuse
- /centos
- /php
- /scala
- /react-native
- /lisp
- /textmate
- /sublime-text
- /nixos
- /debian
- /agda
- /deno
- /django
- /kubuntu
- /arch-linux
- /nodejs
- /ubuntu
- /spring
- /revery
- /manjaro
- /julia
- /diversity
- /lua
- /quarkus
- /markdown









