Fork me on GitHub
Steve Upstill01:03:19

I'm embarrassed to be asking this, but it's one of those questions that should be obvious, but... So: I'm in IntelliJ Idea with Cursive, and I want to get keyboard input when I'm running a project. Is there a window for typing into a running project? Otherwise, how does one get to attend to the keyboard?


@steve171 Normally you'd just call (read-line), but with the REPL in Cursive I believe you need to set up one choosing “Use clojure.main in normal JVM process” to get it to work.


Yeah it’s a side effect of nRepl not being a true repl


Ahh, I forgot, in Cursive, (read-line) will work with nRepl; it just pops up some UI for you to type into. The recommendation I gave above regarding the REPL configuration simply lets you type into the REPL box in the lower right corner of the IDE.

Steve Upstill01:03:45

@mfikes @tbaldridge Thank you! Again, the obvious solution is the correct one. Duh.


What’s the best channel to ask about compojure/compojure-api?


@duminda Beginner questions are best asked here -- there's no channel for Compojure but there is a channel for #ring ...


quick question on java interop why does (Math/round 2.5) work but (map #(Math/round %) [1.5 2]) does not and return a "no matching method found" error?


round is not defined for Long


oh okay, thanks


you could make a multimethod if you need to accept both Long and Double args


or even just use #(Math/round (double %))


Looks like this is illegal: (map #(update % :received_at #(.toString %)) records) I guess it’s because nested %? So, just use fn?


correct. you can also replace #(.toString %) by str


hey guys


is there a problem when learning clojurescript instead of clojure first?


can we use clojure script with datomic?


via node.js


@dl I started from clojurescript but on frontend where clojurescript realy shine. I have one side project using clojurescript on node only because i need some libs from npm and its not so nice. You dont have clojurescript libs for testing (request-mock) and db access so need to use js interop really heavy.


ok so its recommended to use clojure for the backend?


its depends:D but clojure with jvm ecosystem can save your time


ok thx man


I will use cljs + npm for frontend and backend to get my first experiences then


and move over to clj+datomic for serious projects


if you know js picking clojurescript is nice way to speedup learning


How to build cljs project to AMD/CommonJS module?


@dl the biggest reason to choose clojure when you can is that the tooling (ide integration, repl connection, libraries, no need for closure compiler) is quite a bit smoother. if i were doing something on the backend with clojure i’d go with clojure instead of cljs/node for that reason unless i really needed something from the js ecosystem (or maybe if i was doing something that needed to start up quickly). just somethign to think about


What does <!! mean?


It's just a regular function, in the core.async library:;!!


In Clojure, symbols (names of functions etc) can include a lot of characters that would be operators and/or punctuation in other languages.


Hello all! I have simple form :

  (form-to ["POST" "/items"]
    (label :text "Text:")
    (text-field :input)
    [:p errors]
    [:button {:type "submit"} "Send"])]
and compojure route:
(POST "/items" [input]
    (if-not (empty? input)
        (items-db/record input)
        (redirect "/"))
      (items-view/create-item "empty input")))
How test this route with ring.mock.request (or another way) ? I don't know how send not-json body? My try:
(deftest items-post-test
  (let [body {:input ""}
        { status :status headers :headers} (app-routes (-> 
                                                          (mock/request :post "/items" {:input "test"})))]                      
(is (= 302 status))))
I also find this example - But I can't understand, where route-path (I mean "/test") here?
(testing "string body"
    (let [resp (body {} "Hello World")]
      (is (instance? InputStream (:body resp)))
      (is (= (slurp (:body resp)) "Hello World"))
      (is (= (:content-length resp) 11))))


I have a list of maps (which I am receiving from a ui) I want to save to the database which contains some new rows and some already existing rows. The way to differentiate the two, is that any object with an ID is an existing object that needs updated, any without an ID are new rows. I can 1. return them as two separate lists from the front end, 2. loop over the maps inserting / updating the rows one by one depending on if it’s new or not, or 3. split them into 2 separate lists allowing me to do bulk inserts and updates. What would be the most idiomatic approach to take in clojure?


Also if I was to split the list into 2 separate lists based on a property, how would I do that?


@josmith2016 split-with might work for you


Oh, sorry you have intermixed items…


Maybe group-by where f is the propery


As in (vals (group-by even? (range 11)))


Thanks I’ll try that


Could the predicate be where (empty? :id item-in-array) an empty string or (!empty? :id item-in-array) its not empty?