Re: Pesky java interop bug with 0xFFFFFFF error in BuferredReader

2021-12-27 Thread Hank Lenzi
This is embarassing. ;-) Thanks

-- 
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/3a4fb35a-a282-4762-bf08-4f891447b7b9n%40googlegroups.com.


Re: Pesky java interop bug with 0xFFFFFFF error in BuferredReader

2021-12-27 Thread LaurentJ
Hank,

Your last version does not work because your `if` condition is wrong, your 
code stops on the first read ;)

Laurent

Le lundi 27 décembre 2021 à 21:34:05 UTC+1, hank@gmail.com a écrit :

> Ooops my bad, there's a typo in '(.toString sb1)' which sould be 'sb'.
> It doesn't change anything, it still won't work, only Laurent's version 
> works. 
>
> user> (defn pt%% [file]
>
> (let [afr (FileReader. file)
>  bfr (BufferedReader. afr)]
>(loop [x (.read bfr)
>   sb (StringBuilder.)]
>  (if (not (= x -1))
>  (.toString sb)
>  (recur  (.append sb (char x)) (.read bfr))
>
> #'user/pt%%
> user> (pt%% ribs)
> ""
>
> Which makes no sense to me...
> -- 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/9252a765-a5ff-46d9-8c49-b9affb9d2651n%40googlegroups.com.


Re: Pesky java interop bug with 0xFFFFFFF error in BuferredReader

2021-12-27 Thread Hank Lenzi
Ooops my bad, there's a typo in '(.toString sb1)' which sould be 'sb'.
It doesn't change anything, it still won't work, only Laurent's version 
works. 

user> (defn pt%% [file]
(let [afr (FileReader. file)
 bfr (BufferedReader. afr)]
   (loop [x (.read bfr)
  sb (StringBuilder.)]
 (if (not (= x -1))
 (.toString sb)
 (recur  (.append sb (char x)) (.read bfr))

#'user/pt%%
user> (pt%% ribs)
""

Which makes no sense to me...
-- 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/310d27b9-1f6e-4017-9465-14ee8c7a4e15n%40googlegroups.com.


Re: Pesky java interop bug with 0xFFFFFFF error in BuferredReader

2021-12-27 Thread Hank Lenzi
Hi --
Thanks so much, Laurent!
I was actually kind of close (you told me not to peep, so I didn't hehe).

(defn pt30 [file]
(def ^:dynamic *asb* (StringBuilder.))
(let [afr (FileReader. file) 
 bfr (BufferedReader. afr)]
   (loop [x (.read bfr)
  *asb* (StringBuilder.)]
 (when (not (= x -1))
 (recur (.read bfr) (.append *asb* (java.lang.Character/toChars 
x)))

with  (def ribs "/path/to/ribs.txt")

which looks similar. But, for some reason, the *asb* variable didn't 
populate with rib advertisements:

user> (pt30 ribs)
nil
user> *asb*
#object[java.lang.StringBuilder 0x29f4eb0c ""]

When I convert this practically to the same you did,
user> (defn pt34 [file]
(let [afr (FileReader. file) 
 bfr (BufferedReader. afr)]
   (loop [x (.read bfr)
  sb (StringBuilder.)]
 (if (not (= x -1))
 (.toString sb1)
   (recur (.read bfr) (.append sb (char x)))
#'user/pt34
user> (pt34 ribs)
""
I still get no beef (err, ribs). Doesn't print anything either. 

Weird. Just weird.

-- 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/3c1312f9-619b-4056-a54d-d880fcf80cf4n%40googlegroups.com.


Re: What is this notation? "-a"

2021-12-27 Thread Hank Lenzi
Thanks!

-- 
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/d46da6c5-9409-4994-83eb-6cb13aefe7f7n%40googlegroups.com.