2014-04-08 22:01 GMT+02:00 Walter van der Laan
:
> This will only give you one nil:
> (doseq [i (range 1 1)]
> (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)
That last line is the repl printing out the result of the for, which
returns a seq of the return values from the for body (in this case, the
return value of println). If you run this code as part of an
application, you would not see the seq of nils printed. To suppress
printing them in the repl, an
This will only give you one nil:
(doseq [i (range 1 1)]
(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)
On Tuesday, April 8, 2014 9:28:44 PM UTC+2, Cecil Westerhof wr
2014-04-08 20:49 GMT+02:00 Toby Crawley :
> 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 "
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
In common lisp I had the following code:
(let (
(difference)
(i)
(val)
)
(loop for i from 1 to 1000 do
(setq val (sqrt i))
(setq difference (abs (- (expt val 2) (* val val
(unless (< difference 1.1755025E-38)
(print (format nil "Differ