Hank, Welcome. Great efforts- it certainly seems like you're learning a lot, and quickly.
`clojure.core/slurp` is related, in case you haven't seen it yet: https://clojuredocs.org/clojure.core/slurp The implementation may also be enlightening: https://github.com/clojure/clojure/blob/clojure-1.10.3/src/clj/clojure/core.clj#L6944-L6954 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, -Harold 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 clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- 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 https://groups.google.com/d/msgid/clojure/87069aee-1320-4774-b214-bae29e0062f3n%40googlegroups.com.