Fork me on GitHub
#clojure
<
2017-06-25
>
lxsameer11:06:07

does any one knows how should i use fast-resource or even resource to server some static files on pedestal ? how should the route be like ?

Busy escaping the comfort zone13:06:01

Hey fellow Clojurians, I'm looking for a lein plugin that can deploy binaries directly to github releases (similar to https://github.com/aktau/github-release) any ideas?

noisesmith15:06:50

seems like something you could do with lein shell if it doesn't need to be cross platform https://github.com/hyPiRion/lein-shell

tdantas22:06:19

guys, I’m struggling to make my own flat tail call, can you guys give me some enlightenment ?

(defn flat
  [[h & t :as list]]
  (cond
    (empty? list) nil
    (sequential? h) (concat (flat h) (flat t))
    :else (cons h (flat t))))

noisesmith22:06:32

are you aware that clojure never optimizes tail calls?

noisesmith22:06:15

generally with list processing, you don't want to use recur (which acts like an optimized tail self call) but instead make a lazy-seq, which works with your current code if you wrap the else (lazy-seq (cons h (flat t)))

tdantas22:06:39

> are you aware that clojure never optimizes tail calls? yeah, but the loop-recur ( looks like uses go-to ) can help me with that, isn’t ?

noisesmith22:06:47

you could use recur, but that tends to be clumsy for sequences

noisesmith22:06:03

especially with a function that has a tree call structure

tdantas22:06:23

what you mean by tree call structure ?

noisesmith22:06:09

every call leads to 0 or more self-calls

noisesmith22:06:31

as opposed to 0 or 1, which is linear, 0 or more means you end up with a tree of calls

noisesmith22:06:22

and a linear series of calls is neccesary for tail call -you can't have two tail calls

noisesmith22:06:07

you can force it by adding a state accumulator which makes the code more complex and moves data out of the stack and into the heap

tdantas22:06:29

correct me if I’m wrong, but all tail call function they have some kind of accumulator, isn’t ?

noisesmith22:06:18

not always - but it's very common

noisesmith22:06:57

actually I think a tail call function with no accumulator would be pretty weird

tdantas22:06:16

i can’t see

noisesmith22:06:21

but I could see it for eg. something that repeatedly accesses a resource and eventually returns a result

tdantas22:06:36

clojure is not lazy by default, like haskell right, how the lazy works on clojure , (lazy-seq (cons h (flat t)))

noisesmith22:06:53

right - but many functions are lazy

alice22:06:54

Lazy is only there when you don't want it to be >.>

noisesmith22:06:55

including concat

alice22:06:07

> trying to print something > LAZY SEQ HELLO

noisesmith22:06:43

that's only if you call str - just printing won't do that

noisesmith22:06:28

+user=> (str (map inc (range 10)))
"clojure.lang.LazySeq@c5d38b66"
+user=> (println (map inc (range 10)))
(1 2 3 4 5 6 7 8 9 10)
nil

noisesmith22:06:36

and if you need to build up a string, pr-str will help

user=> (str "fixed: " (pr-str (map inc (range 10))))
"fixed: (1 2 3 4 5 6 7 8 9 10)"

alice22:06:56

Well how-about-that

alice22:06:08

learn something every day