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

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
New
johnp
Running the examples in chapter 5 c under pytest 5.4.1 causes an AttributeError: ‘module’ object has no attribute ‘config’. In particula...
New
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
alanq
This isn’t directly about the book contents so maybe not the right forum…but in some of the code apps (e.g. turbo/06) it sends a TURBO_ST...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
New
fynn
This is as much a suggestion as a question, as a note for others. Locally the SGP30 wasn’t available, so I ordered a SGP40. On page 53, ...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
jwandekoken
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: d...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

PragmaticBookshelf
Stop developing web apps with yesterday’s tools. Today, developers are increasingly adopting Clojure as a web-development platform. See f...
New
PragmaticBookshelf
Ruby, Io, Prolog, Scala, Erlang, Clojure, Haskell. With Seven Languages in Seven Weeks, by Bruce A. Tate, you’ll go beyond the syntax—and...
New
AstonJ
Or looking forward to? :nerd_face:
503 15149 280
New
PragmaticBookshelf
From finance to artificial intelligence, genetic algorithms are a powerful tool with a wide array of applications. But you don't need an ...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
PragmaticBookshelf
Build highly interactive applications without ever leaving Elixir, the way the experts do. Let LiveView take care of performance, scalabi...
New
PragmaticBookshelf
Use WebRTC to build web applications that stream media and data in real time directly from one user to another, all in the browser. ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
As digital systems increasingly run the world, mastery of the recurring patterns of software development risk is the key to fast and effe...
New

Sub Categories: