This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-26
Channels
- # aws-lambda (2)
- # beginners (10)
- # boot (17)
- # cider (19)
- # clara (1)
- # cljs-dev (13)
- # cljsjs (22)
- # cljsrn (1)
- # clojure (132)
- # clojure-austin (2)
- # clojure-berlin (2)
- # clojure-dusseldorf (1)
- # clojure-germany (2)
- # clojure-italy (7)
- # clojure-spec (6)
- # clojure-uk (5)
- # clojurescript (45)
- # core-matrix (3)
- # cursive (4)
- # datomic (8)
- # emacs (3)
- # keechma (3)
- # lein-figwheel (1)
- # leiningen (2)
- # lumo (24)
- # nyc (1)
- # off-topic (29)
- # om (68)
- # onyx (5)
- # perun (50)
- # planck (5)
- # protorepl (5)
- # re-frame (128)
- # reagent (10)
- # remote-jobs (1)
- # ring (4)
- # rum (41)
- # untangled (28)
- # yada (4)
touch = update time stamp of a file; does clojure have a builtin for touching a file, or do I need to make a sytem call to call the touch command ?
qqq: yeah that you should work! For trivial parsing im use to do just. "a b c".split("\\s+") in java.
for non trivial i suggest taking a look, https://github.com/Engelberg/instaparse
the context of my question was actually http servelets, doGet, and reading out arguments (not using ring, doing stuff in java apis)
sorry, i missed that, and just thought you splitting a string, java docs for enumeration encourage to use Iterable/Iterator
I am using: http://docs.oracle.com/javaee/7/api/javax/servlet/ServletRequest.html#getAttributeNames--
Enumeration? i thought that was deprecated. If the collections implements Iterable , you can do: (seq coll)
Enumeration is from like java 1
its not, but is more common to use Iterables from java 5 forward
when using webservers in clojure, can I directly reply with edn, or do I have to do clojure dta -> edn -> wrap it in a singleton json string ?
http://cognitect.github.io/transit-clj/ mentions:
Usage: (writer out type)
(writer out type {:keys [handlers]})
Creates a writer over the provided destination `out` using
the specified format, one of: :msgpack, :json or :json-verbose.
An optional opts map may be passed. Supported options are:
:handlers - a map of types to WriteHandler instances, they are merged
with the default-handlers and then with the default handlers
provided by transit-java.
is there any preference between msgpack, json, and json-verbose ?Not a strictly clojure question, but is it correct to say that (-> col (map f) (filter g)) is more efficient if the map and filter functions are lazy?
Yes, I meant map and filter. So my assumption is that it's closer to O(N) than it would be if map and filter were strict
nowadays you're better of using transducers when you have to chain map/filter & co, when you're looking to optimise things at least
So transducers basically solve the problem of intermediate collections, so that the number of passes doesn't go up with the number of filter/map/reduce... you want to apply, right?
you still get chunkiness depending on how the seq was produced, but you at least skip intermediary seq instance creation
but depending on how you realize them (via sequence or into) you can make it totally eager
depends on range
in that case for chunkiness, but sequence respect lazyness of the underlying seq compared to into
Right, very nice. It always bothered me that I need to do multiple full passes on a collection when doing something very specific
Yeah, I know. It still irks me (which perhaps is more my fault 🙂 ). And there have been a few times where it was a problem
hi! what should I do in cider after editing project.clj with a new dependency? restart emacs and do a cider-jack-in or is there some better solution?
@pwrflx you never need to restart Emacs 😉
M-x cider-restart
is enough
@andrea.crotti thanks a lot!
hey guys I am trying to iterate over a vector and create a channel with all of its elements, what is the best way of doing that in a let block?
;(let [names [:a :b: :c]] (doseq [chan-name names] (let [cn (name chan-name)] (def cn (chan)))))
this does exactly that, unless you are not saying correctly what it means to "dynamically create 3 channels":
(defn get-chan
[v]
(let [c (chan 1 (map name))]
(a/onto-chan c v)
c))
(let [c (get-chan [:a :b :c])]
(<!! c))
creating global state from a function is allowed, but usually a bad idea and unnecessary @istvan
is there a way to show parameter info in CIDER? eg show the documentation of the parameter I'm about to enter for the current function call.. I mean something that is similar to CTRL+P in IDEA
for instance, in CIDER, it uses eldoc to show the signature of a function as you type and will bold the parameter that you are currently on
but there is no convention that lumps documentation about parameters that i know of in clojure
@dpsutton : ah ok! then eldoc is what I need! 😄 I've seen it on the modeline of some youtube tutorials but never cared to install.. I'll look into it! thanks!
plugflow.main=> (doseq [x ["a" "b" "c"]] (intern *ns* (symbol x) (chan)))
nil
plugflow.main=> a
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x35aab37b "clojure.core.async.impl.channels.ManyToManyChannel@35aab37b"]
plugflow.main=> b
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x271ce487 "clojure.core.async.impl.channels.ManyToManyChannel@271ce487"]
plugflow.main=> c
#object[clojure.core.async.impl.channels.ManyToManyChannel 0x6011ced2 "clojure.core.async.impl.channels.ManyToManyChannel@6011ced2"]
if it's not global, but only in the let binding, what do you care what they are named?
and i don't mean that in a rude way, but if they exist inside of your let binding, why can't you just refer to them with whatever name you like?
but if you need to take three channels in from a consumer of your code, why not make a function that takes three channels as input?
and you want to go on the convention that the var name of the channel is how they are bound?
and you are searching through the ns-vars that are already interned to see which chans are created?
(this sounds like you should use a map of names to channels — not actual named vars)
@istvan so, the customer gives you a channel name, call it "xyz". You have a global atom that maps "xyz" and all other names to a channel
(def chan-map (atom {}))
(defn add-chan
[m n]
(swap! m assoc n (chan)))
(add-chan chan-map "xyz")
i really think your structure of recovering logic flow of your program from variable names is a bad first attempt
@istvan you will be happy that you did it this way, or rather, you will never know the unhappiness you saved yourself by doing it this way 😉
since clojure keywords are lookup functions you can just use the keyword and lookup pretty easily something in a map
this is one reason why keywords are the most common types of keys in maps. if you use a string as a key though, you can also easily do (get map' str-key)
, to avoid converting between str<->keywords. but yes, keywords work well
@keymone For many uses, clojure.java.shell
suffices: https://clojure.github.io/clojure/clojure.java.shell-api.html