Yes - I do get the result of the print function in the repl (i.e. nil), and I'm 
trying to see how I can somehow prevent that nil from printing to stdout.

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.


On Dec 30, 2011, at 11:51 AM, gaz jones wrote:

> are you sure you're not just seeing the result of the function call in
> the repl? for example this:
> 
> (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
> $
> 
> 
> On Fri, Dec 30, 2011 at 1:38 PM, Frank Siebenlist
> <frank.siebenl...@gmail.com> wrote:
>> I'm trying to write some filters in clojure from stdin to stdout, but I have 
>> this nil at the end of the stream, which is what print returns.
>> 
>> 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.
>> 
>> --
>> 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 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 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

Reply via email to