Welcome. Great efforts- it certainly seems like you're learning a lot, and 

`clojure.core/slurp` is related, in case you haven't seen it 
yet: https://clojuredocs.org/clojure.core/slurp

The implementation may also be 

It's natural when coming from non-functional languages to write `loop`-y 
code like you did, and while it's neat that Clojure enables writing code in 
that style (essential, actually, to the stated goal of pragmatism), it's 
not always helpful. In this case, the implementation of `slurp` also 
interops with Java to produce strings, but does so at a more helpful level 
of abstraction.

I'll also note here that the https://ask.clojure.org/ site may be more fun 
for these types of discussions than the mailing list- though getting help 
anywhere (there are quite a few places actually) is of course fine.

Best of luck, and warm wishes,

On Saturday, December 25, 2021 at 6:35:47 PM UTC-7 hank....@gmail.com wrote:

> Thank for the answers.
> Trying to recur with '(recur (.read bfr))' resulted in a:
> Syntax error (UnsupportedOperationException) compiling recur at 
> (*cider-repl ~:localhost:41097(clj)*:237:9).
> Can only recur from tail position
> So I changed the code (see below). 
> And now it complains that a previous form that was working '(.append 
> etc..') doesn't and the same error remains. 
> user> (pt5 myfile)
> Execution error (IllegalArgumentException) at java.lang.Character/toChars 
> (Character.java:8572).
> Not a valid Unicode code point: 0xFFFFFFFF
> (defn pt5 [file]
>    (let [afr (FileReader. file); instances of FileReader, BufferedReader, 
> StringBuffer
>          bfr (BufferedReader. afr)
>          ct (StringBuilder.)
>          this-list (list afr bfr ct)]
>          ; (apply println this-list)
>          (loop [val (.read bfr)]
>                (when (not (= val -1))
>                  (.append ct (Character/toChars (.read bfr))))
>                (recur val))
>                 ; when finished...
>                 (.toString ct)))
> Harder then it seemed at first sight...
> -- Hank

You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
For more options, visit this group at
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to