Fork me on GitHub
#beginners
<
2022-01-02
>
Benjamin09:01:34

(into {} (remove (comp #{:f} first) {:f 10 :a 11}))
  ;; I like to say 
  (remove-keys #{:f} {:f 10 :a 11})
does this function exist?

delaguardo09:01:08

Not exactly the same but you can use it to write the function that takes a set

Benjamin09:01:28

yea apply dissoc m set

rmxm19:01:36

is it possible to print to repl from ring jetty adapter? (from jetty actually)

seancorfield21:01:22

@roguas println always prints to the console. Can you explain what you're asking about the REPL in relation to the Ring Jetty Adapter?

seancorfield21:01:36

If you start your program from the REPL, println in the program is going to print "to the REPL" because that's what stdout is bound to by default. But if you start your program from the command-line and then connect a REPL into that, your program has its stdout, and your REPL has its stdout -- separate.

rmxm21:01:47

Well mount lib should hold the same logic right? If I (mount/start) my http-server using repl it will pipe all (println) to repls stdout?

seancorfield21:01:01

If you're starting the server from the REPL, I would expect println output from the server to come back to the REPL.

rmxm21:01:11

I am starting server from the REPL, (jetty/run-jetty handler {:port 8000 :join? false}), inside mounts defstate, i have taken it out now... the handler is simple just returns (defn h [_] (println "hello2") {:status 200 :body "hello"}), when i pass the req to reitit.ring/ring-handler it prints fine

seancorfield22:01:26

Starting the server from the REPL with a handler that prints, that output shows up in the REPL:

e$ clj -Sdeps '{:deps {ring/ring {:mvn/version "RELEASE"}}}'
Clojure 1.10.3
user=> (require '[ring.adapter.jetty :refer [run-jetty]])
2022-01-02 14:29:09.337:INFO::main: Logging initialized @29617ms to org.eclipse.jetty.util.log.StdErrLog
nil
user=> (defn h [_] (println "Hello!") {:status 200 :body "Hiya!"})
#'user/h
user=> (def server (run-jetty #'h {:join? false :port 8000}))
2022-01-02 14:30:23.412:INFO:oejs.Server:main: jetty-9.4.42.v20210604; built: 2021-06-04T17:33:38.939Z; git: 5cd5e6d2375eeab146813b0de9f19eda6ab6e6cb; jvm 17.0.1+1
2022-01-02 14:30:23.473:INFO:oejs.AbstractConnector:main: Started [email protected]{HTTP/1.1, (http/1.1)}{0.0.0.0:8000}
2022-01-02 14:30:23.474:INFO:oejs.Server:main: Started @103754ms
#'user/server
user=> ; hit  in a browser
Hello!

rmxm22:01:53

I just checked and works fine, I think it was calvas repl messing it up

seancorfield22:01:43

I've heard people have problems with nREPL-based stuff with process output sometimes.

seancorfield22:01:13

You can probably solve it by starting the REPL outside Calva and connecting to it in Calva, instead of jacking-in?

rmxm22:01:12

yes, helped indeed