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

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
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
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
andreheijstek
After running /bin/setup, the first error was: The foreman' command exists in these Ruby versions: That was easy to fix: gem install fore...
New
a.zampa
@mfazio23 I’m following the indications of the book and arriver ad chapter 10, but the app cannot be compiled due to an error in the Bas...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
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

Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
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
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
25 puzzles that will make you a better C programmer by challenging your knowledge of the language, and explaining the technical details o...
New
AstonJ
If you’re getting errors like this: psql: error: connection to server on socket “/tmp/.s.PGSQL.5432” failed: No such file or directory ...
New
PragmaticBookshelf
Get the comprehensive, insider information you need for Rails 8 with the new edition of this award-winning classic. Sam Ruby @rubys ...
New
PragmaticBookshelf
Fight complexity and reclaim the original spirit of agility by learning to simplify how you develop software. The result: a more humane a...
New

Sub Categories: