lein cljsbuild once hello-- i expect hello.js to be output, but instead it throws errors related to the stuff in the clojure namespace/src folder
I'm a bit confused with the following:
(:require [ring.adapter.jetty :as jetty]
[ring.util.response :as response]
[ring.middleware.reload :refer [wrap-reload]]))
(defn handler [request]
(str "<html><body> your IP is: "
(defn wrap-nocache [handler]
(assoc-in [:headers "Pragma"] "no-cache"))))
(defn -main 
(-> handler var wrap-nocache wrap-reload)
censor-wordfunc works fine, and
playis updated in
play-with-wordonly outputs all-censored word and game never ends.
@YuriMostardeiro Hey. You're asking two questions here:
atomand not a
@fileA/myDef. Or maybe don't use an atom at all, if you don't need to change its value
reversebefore you reduce it: https://clojuredocs.org/clojure.core/reverse
Hi everyone, I'm new to clojure, appreciate if you can point out how shall I implement this
I want to format byte size into human-friendly format.
But I feel
reduce isn't the right approach if the list is huge (I call
format-size on a large list), is there a way to early return (without using exception) ?
One approach I can think of is to use recursive function with, so I can stop iteration, but then I'll have to urgly decompose in each loop, like
(first c) and (first (rest c))
@beenotung There's no need for iteration at all. If you prepend an empty string to the vector of units, the index of that vector becomes a corresponding power of 1024 that corresponds to that unit (1024^0 - no unit, 1024^1 - KB, and so on).
So, you need to just get the logarithm of the input number to the base of 1024, round it down, and get the unit from the units vector.
Of course, you can still use iteration to actually find the logarithm. Or you could use the built-in math function.
On a side note - you can stop a reduction early by using