Does this give you the results you are looking for?

(doall
  (for [i (range 1 1000)
        :let [val (Math/sqrt i)
              diff (Math/abs (- (Math/pow val 2) (* val val)))]
        :when (> diff 1.1755025E-38)]
    (println (format "Different for %d (%e)" i diff))))

cldwester...@gmail.com writes:

> In common lisp I had the following code:
> (let (
>       (difference)
>       (i)
>       (val)
>       )
>   (loop for i from 1 to 10000000 do
>        (setq val (sqrt i))
>        (setq difference (abs (- (expt val 2) (* val val))))
>        (unless (< difference 1.1755025E-38)
>          (print (format nil "Different for ~D (~F)." i difference))
>          )))
>
> Clojure works a little bit different. Until now I have the following with
> comes near the above:
>   (for [i (range 1 1000)]
>        (do
>        (def ^:dynamic val (Math/sqrt i))
>        (def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
> val))))
>        (when (> difference 1.1755025E-38)
>          (println (format "Different for %d (%e)" i difference))
>          )))
>
> But beside that this defines the two variables val and difference, it also
> generates a lot of nil values.
>
> What would be a better way to do this in Clojure?
>
>
> --
> Cecil Westerhof

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to