Fork me on GitHub
#clojure
<
2018-01-18
>
Victor Ferreira03:01:56

Hey guys, anyone can help me?

justinlee03:01:21

ask away. someone will probably try at least 🙂

cmal06:01:52

@noisesmith Thank you very much. It seems subseq can perfectly solve my problem. đŸ»

qqq10:01:45

what is the best way to concat a collection of Vectors into a single vector, i.e. [[1 2 3] [a b c] [:d :e :f]] -> [1 2 3 a b c :d :e :f]

turkkam13:01:12

(apply concat [[1 2 3] [a b c] [:d :e :f]])

qqq10:01:14

(flatten [[1 2 3] [:a [[:b]] :c]])
(comment
 (1 2 3 :a :b :c))

qqq10:01:25

flatten does too much, I'd want [1 2 3 :a [[:b]] :c] as output

moxaj10:01:39

@qqq (reduce into ...)

yogidevbear10:01:09

(into [] (concat [1 2 3] [a b c] [:d :e :f]))

sundarj10:01:23

(into [] cat '[[1 2 3] [a b c] [:d :e :f]])
[1 2 3 a b c :d :e :f]

qqq10:01:23

@moxaj: damn it, I could have sworn I understand recursion, but reduce always gets me

qqq10:01:29

@sundarj: how does your solution work, are yuo invoking transducers ?

sundarj10:01:43

yes cat is a transducer

qqq10:01:18

I'm going to stick with (reduce into [] ...) for now; I still don't feel comfortable with transducedrs

sundarj10:01:53

fair enough

sundarj10:01:24

@qqq indeed it is :~)

theeternalpulse14:01:57

I'm trying to create a function spec and get it to throw the spec error, but even after defining an fspec it doesn't throw a spec related error, just the standard clojure error. For example

(defn test-inc [s] (inc s))

(s/fdef test-inc
  :args (s/cat :i number?)
  :ret number?)

(test-inc "s")
This only throws the runtime ClassCastExcception, not the spec error. Is it something I have to enable for the repl or is there another step?

theeternalpulse14:01:17

Thanks for that.

luskwater15:01:37

@theeternalpulse And if you don’t notice, that’s a backtick that’s used in

(stest/instrument `test-inc)
(I didn’t notice for a few days, wondered why I got nowhere
 but I have old old eyes)

joshkh16:01:06

i have a yogthos/config + clojure + maven + gradle question if anyone feels daring. we have a larger java project that includes our clojure project as a dependency. gradle fetches the clojar and executes it correctly (we can see the output), but the clojure project doesn't seem to pick up our config.edn (something it does see it standalone development and production):

task blueGenesStart(type: JavaExec) {
    main = "bluegenes.server"
    classpath = configurations.providedRuntime
    args = [ '-Dconfig=/path/to/config.edn' ]
}
...nor does it work if we use gradle to place config.edn on the classpath. any ideas? 🙂

octahedrion16:01:53

why do some people use 2 semicolons for comments instead of 1 ?

octahedrion16:01:38

it's a Scheme style ?

hiredman16:01:58

in clojure typically only the code and margin levels are used

hiredman17:01:16

emacs with actually indent single ';' comments out to the margin

ghadi17:01:39

Why does

(with-open [w (jio/writer (.getOutputStream proc))]
      (binding [*out* w]
        (doseq [[k v] uri]
          (printf "%s=%s\n" k v))))
not work but removing the binding does? (proc is a java.lang.Process)

hiredman17:01:04

also clojure-mode inserts ';;' when you M-;, so I pretty much never type a ';'

hiredman17:01:45

ghadi: I think out may need to be a PrintWriter not just a Writer

hiredman17:01:09

what does "not work" mean?

ghadi17:01:36

the process is not given anything over stdin

ghadi17:01:53

closing should flush...

bronsa17:01:02

seems to be working fine here

user=> (.exec (Runtime/getRuntime) "cat")
#object[java.lang.UNIXProcess 0x6ee6f53 "java.lang.UNIXProcess@6ee6f53"]
user=> (def p *1)
#'user/p
user=> (require '[ :as jio])
nil
user=> (def is (jio/reader (.getInputStream p)))
#'user/is
user=> (with-open [w (jio/writer (.getOutputStream p))] (binding [*out* w] (print "asd")))
nil
user=> (.readLine is)
"asd"

ghadi17:01:19

got it -- I was calling the process incorrectly 😃

craftybones17:01:55

Was there a state of clojure for 2017? Doesn’t that usually come out now?

Alex Miller (Clojure team)18:01:23

we kind of missed the 2017 window :) 2018 survey coming next week

jmb18:01:28

Hey guys. I'm doing a personal project using Compojure for routing and Selmer for HTML and templating. I set :resource-paths to ["resources/public"] in my project.clj and tried to link my CSS files in my HTML files, but it couldn't find the css files. I don't know why that issue is happening

jmb18:01:05

My HTML files are in resources/public and my CSS files are in resources/public/css

noisesmith18:01:21

do the paths your templates ask for match the relative path from resources/public ?

noisesmith18:01:10

also, usually you would set [“resources”] as resource-paths and then use (wrap-resources "public") as a middleware to specify which resources to serve to clients

noisesmith18:01:28

because most of the time you have non-code resources that you don’t want to serve to clients over http

jmb18:01:06

Let me try the second thing you said an I'll post it if it works. Thanks

alexstokes20:01:09

anyone know where the multimethod for clojure.core/print-method is defined for java.lang.Object instances?