As an alternative, I can return strings, but then I have the surrounding "s.
Or I could end by printing (symbol ""), like (do (print "hi")(symbol "")) which kind of gives me what I'm looking for but seems to include a newline at the end.
Any other suggestions maybe?
Thanks, Frank.
(ns filter.core
(:require [clojure.string :as string])
(:gen-class))
(defn -main
[& args]
(loop []
(when-let [line (read-line)]
(println (string/upper-case line))
(recur))))
when run, produces:
$ echo -e 'foo\nbar\nbaz' | java -cp lib/*:filter-1.0.0-SNAPSHOT.jar filter.core
FOO
BAR
BAZ
$
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
I understand that you do not see any nil's in your example as you stay inside of your loop and there is no result only side effects.
(which is the same reason why the printing of the repl-prompt doesn't add an additional nil as it is called in the repl-loop…)
(…actually wonder why you wouldn't get one printed nil or false when you exit the loop when the when-let doesn't yield truthy anymore as that would be the final result… maybe that -main function is special… (?))
-Frank.
Yeah, the point I was making is that you are always going to see that
'nil' printed at the repl because it always evaluates and prints the
result of the function, where as in reality that 'nil' would never get
written to stdout (unless you explicitly captured it and wrote it
yourself). It's the repl that's special - not the -main function.
It's a little tricky, but that does allow me to turn the printing of results on/off, which would give me what I was looking for.
Thanks for your help!
-Frank.