#clojure logs

2015-09-01

00:05andyfTEttinger: The multicore revolution has already ended? You mean, not in hardware, but in that so much software uses only one virtual core per process, and typically one thread, but they scale out by having many processes, not many threads?
00:05TEttingerI mean we aren't doubling the hardware cores available every 2 years :)
00:13Wild_Catwhat's Clojure's story for high-concurrency HTTP?
00:13Wild_Cat(as in, when one wants to process more than one concurrent request per thread)
00:44andyfMoore’s law/observation hasn’t shut off yet, so if it isn’t going to more cores, I guess it is going for larger caches, then?
00:54TEttingerwell I mean I can buy an octacore desktop processor today, from AMD, that still isn't very good.
00:54TEttingerintel has been making faster quad-cores and also the weird ultra-low-voltage chips for "ultrabook" laptops
00:56TEttingerGPUs are totally going above and beyond for Moore's thang though
02:05tolstoyWild_Cat: Maybe use the ztellman's Aleph lib? Has an http client with deferreds, streams, ways to chain them together, some interoperation with core.async, etc. http://aleph.io
03:19domokato_aset-float seems to be doing reflection. Am I doing something wrong?
03:20domokato_or is it unavoidable?
03:21amalloydomokato_: for reasons i dont understand, you're better off using (aset ^floats xs ...)
03:25Bronsaamalloy: looking at def-aset, it is written to always use reflective methods
03:26TEttingerhuh
03:26amalloyoh i know it uses reflection, i just don't know why
03:26BronsaI don't think there's a good reason
03:27domokato_(aset ^floats xs ...) seems to be about the same speed...let me dig a little more
03:28TEttingerto be perfectly honest, I think some array-heavy code is better written in java just so you don't have to deal with boxing stuff
03:28Bronsaamalloy: looks like def-aset was written before clojure had primitive support
03:29amalloyinteresting. i don't think i even knew there was such a time
03:29Bronsa2008
03:34domokato_according to the profiler, aset is also doing reflection
03:36Bronsadomokato_: how are you using it?
03:36Bronsadomokato_: aset won't do reflection IFF you use the 3-arity and the array is propertly type hinted
03:49domokato_i need to use the 4-arity, it's a 2d array
03:50domokato_i type hinted the array as ^floats, but still uses reflection
03:54domokato_ah, ^floats is inaccurate anyway since it's a 2D array...
04:02domokato_got it! i just needed to pull out each inner array and use the 3-arg version of aset on it
04:04TEttingerdomokato_: you might have just found a better way, but when I was doing this (and I hadn't thought of pulling out the inner array), I found using a 1d array to emulate a 2d array was rather high-performance
04:04TEttingerand also sorta played nicer with amap
04:05domokato_TEttinger: I would do that if I could, but the API I'm using takes 2D arrays
04:05TEttingerah ok
04:06TEttingervectorz may be a good thing to look into then
04:07amalloyhint it as ^"[[F" probably works for the 2d array
04:07TEttingeroh nvm, vectorz uses its own array stuff, not the [[ arrays
04:08HitchHello. I am looking for a simple crud-website-backend-tutorial to get me started.
04:08TEttingeramalloy: the ^"[[Z" thing for a 2d boolean array is sure weird
04:10winkthis is offtopic, but any ideas how I'd best represent a list like '(1 "a" {:foo 2}) in plain java?
04:10winkI can think of 10 non pretty ways, but nothing easy
04:10Hitchuse a class obviously...
04:11winkclass with 3 fields is one of the ugly ways, yes :P
04:11Hitchit's the appropriate way in java
04:11Hitchwhen in rome... ;)
04:12Hitchthere is lots of boilerplate in rome.
04:12winkhehe ok
04:15winkstorm's Values just uses ArrayList<Object> though
04:16Hitchstorm?
04:16winkhttps://github.com/apache/storm
04:21Hitchwould have to look at the code to figure out why they did it. unless their lists change it is probably just laziness.
04:42TEttingerwink: there's that clojure-data-structures-for-java library
04:42TEttingerhttps://github.com/rschmitt/collider is one...
04:42winkthanks
04:43winkbut I think I'll just stick to Values, I'm using Storm after all :P
04:43wink*bookmarks for later use*
04:43TEttingerah, also https://github.com/rschmitt/dynamic-object
05:47Empperioh nice. Someone actually has implemented that
05:48Empperibeen thinking on doing the exactly same thing although without clojure underneath
06:10pseudonymousIf anyone's used HoneySQL - could someone explain me the rationale behind the (insert-into) helper function ? The result from applying (honeysql.core/format) to the resulting map yields a vector which works fine with clojure.jdbc/execute! but execute only tells you the rows affected and clojure.jdbc/insert! expects a much different format
06:22ddellacostapseudonymous: honeysql doesn't really work with any of the helpers that c.j.j provides
06:23ddellacostapseudonymous: other than execute!
06:23ddellacostapseudonymous: mostly it's not a problem, but definitely it's a pain w/insert
06:23pseudonymousYea. I've arrived at the conclusion that it's best that I just write a helper of my own to transform the query map into what c.j.j/insert! expects
06:24ddellacostapseudonymous: what we end up doing is to simply pull the table name and values out of the map created by honeysql and pass that into insert!, when we care about the return value at least
06:24ddellacostapseudonymous: yep, that's basically what we do
06:24pseudonymousI guess I just asked to be sure I wasn't doing something obviously stupid :P
06:25ddellacostapseudonymous: no, it's kind of an ugly incompatible bit w/honeysql and c.j.j I think
06:25ddellacostaat least, I haven't seen any clever way around it
08:21roelofhow can I change (http://lpaste.net/140030) so 0.0.0.0 is used instead of localhost ?
08:25Bronsahttps://ring-clojure.github.io/ring/ring.adapter.jetty.html
08:26Bronsathere's a :host option
08:31roelofBronsa: I tried this : (run-jetty (var application) {:host "0.0.0.0" :port 8080 :join? false}) but still not working
08:43roelofhow can I change (http://lpaste.net/140030) so 0.0.0.0 is used instead of localhost ?
08:53zetlenok guys: https://www.refheap.com/109051 this is not parallelizing very well. i'm expecting it to get higher than 150% proc usage. should i be doing something more involved than pmap? perhaps switching from pmap to map or controlling the thread pool?
08:54zetleni mean, switching from pmap to map at a certain depth
08:54zetlenthus practically limiting the number of threads to 26
08:54zetlenhmm
08:56darth10zetlen, if you're trying to create a new collection, use fold from clojure.core.reducers
08:57zetlendarth10: i see, it takes n arguments
08:58zetlendarth10: ahem, it takes an n argument for concurrency limit
08:58darth10zetlen, what i meant was try using a reducer :)
08:59zetlendarth10: i'm quite new to clojure--what does a reducer have over pmap?
08:59zetlendarth10: the advantage to pmap is that i don't have to think about shared memory or partitioning my trie, is what it feels like
09:00darth10zetlen, actually building lazy lists may not be the best way here if you want to squeeze out more parallelism
09:00yendais anyone using pallet ?
09:01darth10zetlen, so i meant try using a reducer based computation http://clojure.org/reducers
09:01zetlendarth10: i see...then how would i stream it out to http during calculation?
09:02zetlenmy test case is joining a string, sure, but i wanna avoid that in production
09:41yendaWhat are people using in the clojure world for provisionning and task automations ?
09:52drbobbeatyyenda: like creating AWS hosts? Or more like 'cron' tasks in your apps?
09:53yendadrbobbeaty: like creating aws hosts
09:53yendaand then installing stuff
09:53yendaand configuring
09:54drbobbeatyI've used Amazonica - but most often times I still use the AWS Console on the web.
09:54drbobbeatyhttps://github.com/mcohen01/amazonica
09:57yendadrbobbeaty: seems more up to date than jclouds support in pallet
09:57yendagood for provisionning but I still need to find something for tasks excecution
09:57drbobbeatyyenda: It's nice and we've used it to make SNS and SQS assets as well.
09:58drbobbeatyyenda: I use at-at in clojure: https://github.com/overtone/at-at
09:58drbobbeatyyenda: I've had a lot of luck with it for scheduling/cron - but it's in my process space - not "just managed" by AWS. I could not find anything to do that.
10:10yendadrbobbeaty: I am rather looking for something that would that would allow me to do some configuration on the instances
10:11yendaLike ansible
10:11drbobbeatyyenda: Yeah... sorry... I got nothing for you there. We are looking into tools like that, but I'm not in the selection group.
10:25noncomi am exploring the luminus web framework and i have found that the wrap-format middleware ( https://github.com/ngrunwald/ring-middleware-format ) tries to transform a websocket object sent as a response for a websocket request and throws an exception
10:26noncomdoes this mean that i should avoid using this middleware if i am to use websockets?
10:27noncomjustin_smith: ping
10:51Deraennoncom: I remember using it with Sente. How are you sending the response the websocket request? At least with Sente you should use reply-fn or chsk-send! if I recall correctly.
10:53noncomDeraen: i am not sure what reply-fn or chsk-send! are, but the form that the existing middleware sends the websocket back is a {... :body WebSoketObject ...}
10:53noncomand this causes this error
10:53noncomi am very noob in compojure so i must be missing some fundamental piece of understanding
10:59kavkazI have a function in which i use the expression (repeat <somenumber> \tab) and I try to apply str on it and some strings
10:59kavkazbut that particular expression doesn't evaluate, when i output the string it contains clojure.lang.LazySeq
11:00kavkazHow do I go around this? Or get it to evaluate?
11:00Deraennoncom: Unfortunaltely I'm not very familar with websockets. But yeah, r-m-f will try to encode the responses and that could fail. You could go around this by providing custom predicate for r-m-f response middleware.
11:01Deraennoncom: The default implementation is here: https://github.com/ngrunwald/ring-middleware-format/blob/master/src/ring/middleware/format_response.clj#L19-L27 you could add (instance? WebSocketObject body) to the `or` to prevent r-m-f trying to encode those.
11:01noncomkavkaz: you get a lazy sequence, that is ok. if you want to see result, try (into [] ..LazySeq..)
11:01kavkaznoncom: Oh okay, I'll try that, thanks noncom
11:01noncomkavkaz: or, if the seq is big (or endless) and you want to see like 100 first elements, do (take 100 LazySeq)
11:02noncomDeraen: yeah! seems like it. i just wasn't sure that's ok... hmmm patching the lib..
11:02noncommaybe the creator did not think about websockets...
11:02Deraennoncom: the middlewares should take the predicate function as option
11:03noncomah, ok, i will look into where i can pass it
11:03Deraennoncom: https://github.com/ngrunwald/ring-middleware-format/blob/master/src/ring/middleware/format_response.clj#L369 (this version is not yet, released but I'll release it now)
11:04noncomah, it's you the author :D
11:04Deraenmaintainer
11:04Deraenthough I've been as busy lately as the author
11:05noncomheh, very cool :) well, okay, this makes much sense. i will be configuring the middleware to behave ok with the websockets!
11:20Deraennoncom: It's released: https://github.com/ngrunwald/ring-middleware-format/blob/master/Changes.md#060-2015-09-01
11:21noncomalright! i'm updating! also remember to change the lein instruction on the main readme to reflect version 6.0 (now it says 5.0)
11:22noncomthank you :)
11:28troydmcan anyone explain me how this is used? http://clojuredocs.org/clojure.core.logic/project
11:38noncomtroydm: well, there's always https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic.clj
11:38noncomhttps://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic.clj#L1327 in particular
11:38noncomas to how describe this with words - i am not sure, i'm not much into logic programming yet
11:39noncomas far as i understand, you feed it the vars and the goals and it returns you the values of the vars
11:45troydmnoncom: ah, I understand now, thank you
11:53justin_smithnoncom: pong - what server are you trying to set websockets up with?
11:54noncomjustin_smith: it's immutant! but with help of Deraen, the man behind the format middleware, we have already fixed things!
11:54justin_smithoh, cool
11:54noncomthere comes a new version of the middleware
11:55noncomit will be configurable to avoid processing what does not need to be processed, that's the solution
11:56jcrossley3noncom: if you see opportunities to change immutant in some reasonable way to make things more sensible overall, feel free to holler
11:57tcrawleynoncom: what was the problem? that the middleware was trying to encode the body returned from the as-channel call?
11:57noncomtcrawley: yes
11:57noncomit was trying to encode the websocket java object
11:57tcrawleyah. I'm curious what your predicate looks like?
11:58noncomjcrossley3: okay, i will! though i am still in the very early learning stages :)
11:58noncomtcrawley: actually, i had no predicate.. and the new version of the middleware allows specifying the predicate if needed
11:59DeraenAnother soultion could be to reorder middlewares so that r-m-f middleware doesn't see response from websocket middleware.
12:01tcrawleyDeraen: in Immutant, you can init ws from middleware, or from a standard ring request
12:02tcrawleynoncom: the easiest thing to check in the predicate is (:websocket? request)
12:02jcrossley3so if the former, re-ordering should work, right?
12:02tcrawleythen you don't have to care about the type of the :body
12:02tcrawleyjcrossley3: correct
12:03noncomtcrawley: i see... conceptually i got what you said but i will have more experiments until i really see how it works :)
12:03tcrawleysure thing. ping me here or in #immutant if you have any trouble
12:04Deraentcrawley: noncom: r-m-f predicate takes request as the first parameter so checking :websocket? should be very good option
12:04noncomtcrawley: okay, thank you!
12:05roelofHas anyone succeed in running labrepl on a other host as localhost ?
12:08troydmnoncom: https://www.refheap.com/109060
12:08troydmnoncom: can u explain why this doesn't works?
12:09noncomtroydm: i'm afraid i can't my knowledge of prolog and minikanren languages is very poor :) they are on my todo list
12:10noncomtroydm: however, i can advice you to try out on #minikanren
12:10noncomor here, when more ppl are around
12:10roelofnoncom: and when are the most people here avaible then ?
12:13Deraennoncom: I added issue to r-m-f about custom predicate for Immutant ws: https://github.com/ngrunwald/ring-middleware-format/issues/46 If it works for you, I could add a mention to docs.
12:15noncomroelof: idk, depends... sometimes it's full of ppl, sometimes, not.. and, by looking at contributors to that project ( https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic.clj ) it looks like that they are not here or afk now
12:15noncomDeraen: okay! will be checking in a half an hour!
12:17roelofnoncom Im looking for someone or a contributor to this project : https://github.com/relevance/labrepl and not core.logic
12:26roelofmaybe better make a issue on the page ?
12:33noncomroelof: oh, i am not sure. probably he'll be around here some times. or you can pm him
12:43noncomroelof: yeah, an issue about missing documentation would do i think
12:43roelof noncom but then I have to know his irc name and I get a suspion that relevance is company
12:44noncomyes, thinkrelevance is a company
12:44noncombut stuart is real
12:44noncomi remember seeing him around
12:44noncomlong time ago
12:47noncomroelof: also there is clojure google group
12:47roelofI will make issue. I tried this (defn -main [& args] (run-jetty (var application) {:host "0.0.0.0" :port 8080 :join? false}) (println "Welcome to the labrepl. Browse to http://localhost:8080 to get started!"))
12:47roelofbut no luck
12:48roelofI have asked there some questions but no answers there
12:58noncomroelof: what about {:host "localhost"} ?
12:59roelofthat does also not work. My cloud provider wants that you use 0.0.0.0 instead of localhost
12:59oddcullyi think OP want _not_ to bind to localhost but to the world
13:01noncomoddcully: quite possible! what are his options then?
13:04oddcullynoncom: any (0.0.0.0) should be fine here (for ipv4)
13:06noncomeh, but it is not..
13:08roelofoddcully: schould I do (0.0.0.0) instead of "0.0.0.0" ?
13:08oddcullyno. this where no cloj parens ;)
13:09oddcullyand just to have it asked: the host in question actually has ipv4 addresses on it?
13:11pseudonymousw/o being fully clued in. If you wanted to bind to localhost (i.e. disallow outsiders you'd use "127.0.0.1" (or the IPv6 equivalent) or simply "localhost"). If you want to bind to the outside world "0.0.0.0"/"<whatever your machine's externally facing IP is>.. If it's a Linux box, you'll probably get much better help from throwing the output of "ip addr" up on a gist
13:11roelofoddcully: yes, they say themselves to use 0.0.0.0
13:12oddcullyroelof: and regardless of what you tell to be the :host here you bind to ::1?
13:12pseudonymousAnd if this really is just a question of not having a connection. Install "netstat" on the machine and look over the list with "netstat -taupen" - try to see which interface (if any) your service bound to
13:13roelofsorry now I miss you. This is becoming very technical
13:14oddcullyfrom what i gathered your problem is, that regardless of what you configure with :host, your service there only accepts connections on 127.0.0.1 (or localhost)?
13:14oddcullythis got determined by you or by your ops folks?
13:15roelofodd : I think this is a good explantion of my problem
13:20pseudonymousroelof: I'd bet your problem isn't whatever clojure service you're trying to get going. It's way more likely that you guys aren't deploying it right. Maybe no one looked with 'netstat -taupen' to determine which IP's the service binds to but just observed that they get no response aside from 127.0.0.1 - in that case, it's most likely because of the server's firewall rules. If (say) you guys are attem
13:21pseudonymouspting to deploy this to a Ubuntu box or something like that, your best bet is to investigate the server environment further and possibly solicit help from their channels.
13:29roelofthanks all
13:44clojerTrying to get a local JAR into my project. Have setup "mvn" directory with `mvn install:install-file .....` and the JAR is under <project>/mvn/astro/swisseph but it doesn't seem to be in my classpath. What would be the correct (import ...) format?
13:45justin_smithclojer: after the mvn install you need to add the jar to your deps (in project.clj if you are using lein)
13:45justin_smithimport does not change your class path, you need to set up your class path via lein, boot, mvn, gradle, whatever
13:45clojerFollowed instructions at: http://www.thesoftwaresimpleton.com/blog/2014/12/06/om-local subsituting local java JAR for Om JAR
13:45justin_smith(or by hand if you are crazy like that)
13:46justin_smithclojer: if the install succeeded, double check your project.clj settings
13:46clojerjustin_smith: Which format for project.clj?
13:46justin_smithit should either have added the jar to classpath, or failed because it could not find the artifact
13:47justin_smithclojer: the link you just shared shows, but also you can check the documentation at leiningen.org. We can help here if you have a more specific question than "what format"
13:47clojerjustin_smith: So just add like a Clojure dep?
13:47justin_smithright, because it is a dep
13:48clojerjustin_smith: I mean no separate config section for Java JARs?
13:48justin_smiththere is no separation or difference
13:48justin_smitha dep is a dep, whether it contains clojure code, java classes, or javascript
13:48clojerjustin_smith: I mean no separate config section for Java JARs?
13:49justin_smithclojer: like I said all deps are treated the same way no matter what is in them
13:49justin_smithso no there is no separate section
13:49clojerjustin_smith: I mean no separate config section for Java JARs?
13:49justin_smithseriously, what the fuck, ignored
13:50clojerjustin_smith: Use (import .. or (require ... ?
13:50clojerSorry, repasted. Sorry
15:14ben_vulpesso i'm working to compile some clojurescript from the clojure repl, and have hit what i think is the final boss: my compiled clojurescript sez `goog.require('cljs.core')`, and that fails. when i manually edit that file to read '../cljs.core', google can find the file and my compiled clojurescript runs. does anyone know how to set that compiled path name during the cljs compilation step?
16:12justizinis there anything like maven's ~/.m2/settings.xml or a parent pom for leiningen?
16:13justin_smithjustizin: some of that is replicated in ~/.lein/profiles.clj
16:14justin_smitheg. with the :repositories key that you can add to profiles there
16:15justin_smithor :mirrors
16:18justizinjustin_smith: ah, sweet, hadn't seen profiles.clj in the docs
16:42TimMcjustizin: Careful with that, by the way -- it's great for user settings, but I really don't recommend putting anything in there that is important to the build (such as which repositories to pull from.)
16:42gganleyright now im using om to write my front end and im looking for a datastore to store edn in. I'm guessing the answer is going to be datomic but how does om talk to datomic? through JSON? through some other way? I'm just looking for some feedback
16:44justizinTimMc: we have tens of projects, so even though i agree with you in principle, it's a huge manageability improvement for us
16:45justizinand basically how our maven configs already look
16:45justizinbut yah i am considering just flattening everything, the shared nature was confusing to me when i started here
17:14TimMcjustizin: I'd almost consider using a plugin in that case... but that will only help with consistency in things that are not plugins.
17:14TimMcWe only have a handful of Clojure projects and we actually stopped relying on profiles.clj for repositories.
18:32simon1234Hi there! I have a problem with a very simple macro and arg destructuring, any insight would be great! https://www.refheap.com/109070 Cheers!
18:37ZimaBlue`hi, I'm new at this too but aren't you supplying the inner log-structured with 3 arguments, when it needs an even number?
18:38kanjaIs there a good tutorial on error handling for clojure? Is dire a good choice for new projects?
18:43sdegutisQuestion: Do you generally just write `(Date.)` or do any of you use a wrapper library for this?
18:47simon1234Hm, why does not that work? (into {} (partition 2 [:foo :bar :x :y]))
18:53justin_smithsimon1234: because maps are picky and their entries must be vectors
18:53justin_smith,(into {} (map vec (partition 2 [:foo :bar :x :y])))
18:53clojurebot{:foo :bar, :x :y}
18:53justin_smithor better yet ##(apply hash-map [:foo :bar :x :y])
18:53lazybot⇒ {:foo :bar, :x :y}
18:54sdegutis,(Date.)
18:54clojurebot#error {\n :cause "Unable to resolve classname: Date"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Unable to resolve classname: Date, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.IllegalArgumentException\n :message "Unable to resolve classname: Date"\n :at [cloj...
18:54sdegutis,(java.util.Date.)
18:54clojurebot#inst "2015-09-01T22:54:57.504-00:00"
18:55justin_smithsdegutis: I just do (Date.) but a lot of people hate java.util.Date with a passion and use clj-time always
18:55sdegutisjustin_smith: why aren't you in that camp?
18:55justin_smithlib-bloat
18:55justin_smithI usually don't need the features of clj-time, and I never try to modify my dates so the fact they are mutable doesn't become an issue
18:56sdegutisOkay cool. We're using chee.datetime (https://github.com/slagyr/joodo/blob/master/chee/src/chee/datetime.clj) simply because it's a predefined set of functions (like `now`) that I can stub out during tests, unlike Java constructor calls.
18:56justin_smithI already have like 200 deps on every project, I like having an excuse to leave a few out
18:56sdegutisThat said, I'm considering creating a "Time" Component that I can use in my System component so that it's more "natural" to do dependency injection and swap out the real version for a fake version.
18:59sdegutisOh wait, Components are meant to be things that can start and stop.
18:59sdegutisSo I guess that's a stupid plan that doesn't make sense.
18:59simon1234justin_smith: oh thanks
19:00simon1234Yeah, it seems really picky, I mean, it could just blow up... why does it have to be a vector. What guarantee does it bring?
19:05TEttingersimon1234: this is sorta an interesting topic. you can map over a hash-map, and it gives key-value pairs to the fn. ##(map identity {:a 1 :b 2 :c 3})
19:05lazybot⇒ ([:c 3] [:b 2] [:a 1])
19:05TEttinger&(map class {:a 1 :b 2 :c 3})
19:05lazybot⇒ (clojure.lang.MapEntry clojure.lang.MapEntry clojure.lang.MapEntry)
19:05justin_smithsimon1234: clojure.core tries to force things to be efficient sometimes - see also no function being defined to add an element to the end of a list, or the beginning of a vector
19:05TEttingerthey aren't exactly vectors, but MapEntry extends vector I believe?
19:06justin_smithmaybe not "tries to force things to be efficient" but more like "tries to make inefficient things a bit harder to do"
19:06justin_smithTEttinger: a mapentry is a vector
19:06justin_smithsubclass
19:06simon1234Yeah, but does it really achieve efficiency here? It just forces the construction of an intermediate vector, is it more efficient?
19:06TEttingerwhat's the term for, "is a subclass of X but is not strictly X"
19:07simon1234isa?
19:07demouserproper subclass
19:07justin_smithsimon1234: I think it's to lead you toward modifying values in an existing entry rather than replacing it with a seq? or maybe it's just a wart on clojure's design :P
19:07simon1234:)
19:08simon1234What does not strictly X mean TEttinger?
19:08TEttinger,(into {} [:foo :bar :x :y]) ; curious about this
19:08clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.lang.ATransientMap conj "ATransientMap.java" 4...
19:08TEttingersimon1234: that's sorta the reason I'm confised about it
19:09simon1234, (into {} (map vec (partition 2 (:foo :bar :baz :binz))))
19:09clojurebot#error {\n :cause "Wrong number of args passed to keyword: :foo"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Wrong number of args passed to keyword: :foo"\n :at [clojure.lang.Keyword throwArity "Keyword.java" 97]}]\n :trace\n [[clojure.lang.Keyword throwArity "Keyword.java" 97]\n [clojure.lang.Keyword invoke "Keyword.java" 150]\n [sandbox$eval49 invokeStatic "NO_SOURCE_FI...
19:09TEttingerthere's an IPersistentVector interface, and the vectors you create with [] are I think a different implementation than MapEntry is
19:09simon1234, (into {} (map vec (partition 2 '(:foo :bar :baz :binz))))
19:09clojurebot{:foo :bar, :baz :binz}
19:09TEttinger,(class [])
19:09clojurebotclojure.lang.PersistentVector
19:11TEttinger,(into {} (map vector '(:foo :baz) '(:bar :binz)))
19:11clojurebot{:foo :bar, :baz :binz}
19:11TEttingerif your keys are separate from values that could be a shortcut
19:11justin_smith,(zipmap '(:foo :baz) '(:bar :binz))
19:11clojurebot{:foo :bar, :baz :binz}
19:12simon1234TEttinger: :) yep, but it is not. But that's ok, I will do it another way, I was just curious
19:12justin_smithsimon1234: yeah, apply hash-map is really the solution if you have your hash-map as a flat seq
19:12simon1234Yep, thanks for the suggestion!
19:17amalloyclojurebot: apply hash-map is <reply>http://stackoverflow.com/q/7034685/625403
19:17clojurebotIn Ordnung
19:19amalloymy second-most popular answer on SO, curiously
19:20simon1234:) good return on investment!
20:05kavkazI'm trying to use (if (empty? <someseq>) dosomething recur *whatever*) on (range) and obviously it's an infinite recursion. I tried wrapping it in lazy-seq, and I'm still having the same problem. I guess my trouble is that I'm not sure how else to solve the problem without using recur
20:07kavkazHow would I normally recursively call a function over a sequence such as (range)?
20:07kavkazThe assumption is that the client of the function can just call (take n (myfunction <someseq>))
20:09amalloykavkaz: just call the actual function by name instead of using recur, inside the lazy seq
20:09amalloywell
20:09amalloyyou have to also produce a partial result, rather than using an accumulator. take a look at the definition of take, for example, since you mention take
20:09amalloy~def take
20:13kavkazThank you amalloy, I'll take a look at that. I think now that i've tried explaining my issue it'll be easier to try and solve it.
20:22kavkazamalloy: Oh i see
20:23pradeepchhetrihello, i want to convert ({"name" "databases", "columns" ["name"], "values" [["testdb"] ["mydb"]]}) into ({:name "testdb"} {:name "mydb"})
20:23pradeepchhetrii am unable to think for a way to do this, can someone help me out.
20:28gfredericks,(defn pradeep [data] (for [{:strs [columns values]} data, :let [k (keyword (first columns))] [v] values] {k v}))
20:28clojurebot#'sandbox/pradeep
20:29gfredericks,(pradeep '({"name" "databases", "columns" ["name"], "values" [["testdb"] ["mydb"]]}))
20:29clojurebot({:name "testdb"} {:name "mydb"})
20:29gfrederickspradeepchhetri: I think the problem as you described it is a bit underspecified, but I wrote something that did what you asked
20:30TEttinger,(let [start {"name" "databases", "columns" ["name"], "values" [["testdb"] ["mydb"]]}] (map (fn [vcoll] (map #(into {} [(keyword %1) %2]) (start "columns") vcoll)) (start "values")))
20:30clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword>
20:30TEttinger,(let [start {"name" "databases", "columns" ["name"], "values" [["testdb"] ["mydb"]]}] (map (fn [vcoll] (map (fn [a b] {(keyword a) b}) (start "columns") vcoll)) (start "values")))
20:30clojurebot(({:name "testdb"}) ({:name "mydb"}))
20:30TEttinger,(let [start {"name" "databases", "columns" ["name"], "values" [["testdb"] ["mydb"]]}] (mapcat (fn [vcoll] (map (fn [a b] {(keyword a) b}) (start "columns") vcoll)) (start "values")))
20:30clojurebot({:name "testdb"} {:name "mydb"})
20:31pradeepchhetrigfredericks: thank you very much :)
20:31TEttingergfredericks: that won't work for multiple columns I think, but that looks good
20:32mangeIf you can also have multiple columns you could do something like: (mapcat (fn [{:strs [columns values]}] (map (partial zipmap (map keyword columns)) values)) data)
20:32TEttinger,(let [start {"name" "databases", "columns" ["name" "id"], "values" [["testdb" 1] ["mydb" 2]]}] (mapcat (fn [vcoll] (map (fn [a b] {(keyword a) b}) (start "columns") vcoll)) (start "values")))
20:32clojurebot({:name "testdb"} {:id 1} {:name "mydb"} {:id 2})
20:32TEttingerhm
20:32pradeepchhetriTEttinger: thank you for the solution :)
20:33TEttingermine isn't right either!
20:33TEttingerit's partially there!
20:33pradeepchhetriyes .
20:34mangepradeepchhetri: Give my one a go if you want multiple columns as well.
20:34TEttinger,(let [start {"name" "databases", "columns" ["name" "id"], "values" [["testdb" 1] ["mydb" 2]]}] (map (fn [vcoll] (into {} (mapcat (fn [a b] {(keyword a) b}) (start "columns") vcoll))) (start "values")))
20:34clojurebot({:name "testdb", :id 1} {:name "mydb", :id 2})
20:34TEttingeryeah, mange yours looks rather concise, good job
20:34pradeepchhetrimange: cheers. i will definitely.
20:38gfredericksTEttinger: I couldn't tell what the requirements were
20:43skeuomorfWhat do you folks use to do static analysis "linting" while coding in emacs? -Something like, run linter on save-
20:43skeuomorfI'm using CIDER FWIW
20:45TEttingerjustin_smith: don't you make a tool that I can't remember the name of for lint-like stuff?
20:49TEttingerah, https://github.com/jonase/eastwood
20:49skeuomorfTEttinger: Appears to fit the bill, thanks!
20:50TEttingerhope it does, glad to do some confused googling!
20:51skeuomorfI did some googling for "cider lint" and "clojure static analysis" but failed
20:51skeuomorfI am new to the whole shebang, so had I known about "Flycheck" I might've been luckier
20:51skeuomorfShebang == emacs, clojure, CIDER
20:51TEttingerwhat got it for me was https://duckduckgo.com/?q=clojure+code+lint+tool
20:52skeuomorfnice
20:53TEttingerclojure lint found linters for Google Closure Compiler, thanks auto-"correct"
20:53skeuomorfhehe
20:53skeuomorfI might've forgotten to google clojure linters and googled CIDER linters instead
20:54zetlenlint in my cider! nooo
20:54skeuomorfzetlen: Googling CIDER lint made me sad :D
20:55skeuomorfApparently there's flycheck-clojure as well, wonder how it differs from eastwood
20:57skeuomorfAhh, flycheck-clojure is https://github.com/clojure-emacs/squiggly-clojure which is eastwood inside emacs
21:12zetlenall right, folks: https://www.refheap.com/109077
21:13zetleni got some advice earlier to "use a reducer", of which map is one. i'm trying to parallelize this
21:13zetlenmy janky little strategy is to limit the number of threads to theoretically 26, by switching out `pmap` for `map` once you're two nodes down the trie
21:14zetlenit's not working--i'm getting 20 to 30 seconds and at best 150% proc use, inside cider
21:14zetleni'm new to clojure--can anyone give me some guidance about parallelizing?
21:23justin_smithzetlen: pmap already restricts the maximum number of threads it uses
21:23justin_smith~pmap
21:23clojurebotpmap is requires syntax quoting which most of the time
21:23justin_smitherm...
21:23justin_smith~pmap
21:23clojurebotpmap is not what you want
21:23arrdemlol
21:23justin_smithI swear this bot was once more useful
21:24arrdemlazybot: ping
21:24lazybotarrdem: Ping completed in 0 seconds.
21:24arrdem$grim clj::clojure.core/pmap
21:24arrdemthat PR has been merged for what 6 months now?
21:25zetleninfobots are particularly subject to entropy
21:25zetleni don't blame it
21:25rhg135An useful bot? I miss that.
21:26zetlenjustin_smith: should i be managing my own thread pool?
21:26arrdemmaybe we should make a 3rd bot named usefulbot....
21:26zetlenand just limiting it to the number of cores?
21:27justin_smithzetlen: that's one way to do it. I recently had to make a map-reducing function for my codebase and I opted for using core.async with a shared channel, and then controlling the parallelism by deciding how many go-loop blocks shared the same input channel
21:27justin_smithbut you can also use a thread-pool
21:28justin_smithit depends on what your bottlenecks are, and you should probably be benchmarking a few options if it matters enough to go parallel
21:28zetlenjustin_smith: it does, as silly as this looks, because i need to learn those techniques :)
21:30zetlenjustin_smith: a thread pool i more or less understand, but i want to be idiomatic about this. i don't honestly understand why pmap doesn't work--the trie is shared memory, immutable, and i imagined the threads working their way down it
21:30zetlenso if i knew why i was switching to core.async it would give me direction
21:30amalloyjustin_smith: pmap restricts the number of threads for a single call to pmap
21:30amalloybut if f uses pmap to make N recursive calls to f...
21:31justin_smithamalloy: good point, yeah
21:31amalloyparticularly relevant because that's what zetlen is doing
21:31justin_smithzetlen: one issue with pmap is that it parallelizes but it waits on results in order
21:31justin_smithamalloy: oh, I missed that, sorry
21:40zetlenzoinks! yes
21:41zetlenin my impl of f, i switch out pmap with map at depth 2, and since this is the alphabet that should limit me to 26 threads, right?
21:47amalloywell i'd guess 26^2
21:47amalloybut who knows
21:48amalloyjustin_smith is right in suggesting that if you want to manage parallelism you are better off using a real tool like an executor with a thread pool, rather than a toy like pmap
21:58kanjaIs dire a good choice for new projects?
22:03tmtwdI am looking up "^ clojure" on google to find out more about the built in clojure type system
22:03tmtwdbut I am not getting what I am looking for
22:04arrdemtmtwd: http://clojure.org/java_interop#toc30
22:05arrdemtmtwd: Clojure doesn't have a "type system" in the conventional sense. ^foo hints are strictly advisory and for performance in the case of interop usage
22:05tmtwdcan you mix in type hints with normal arguments
22:05tmtwd?
22:05arrdemYep!
22:06arrdem(fn [^Long x] ..) totally works
22:06tmtwdlike (defn yo [^String foo bar] (...))
22:06tmtwdso foo must be a String and bar is optional
22:06arrdemno, foo may be any object at all, but if you try to do Java interop on it, it will be cast to a String.
22:07amalloyand bar is not optional at all
22:07arrdemalso true
22:08amalloytmtwd: type hints, via ^, have (usually) no impact on semantics at all, only performance. it is not a type system
22:08tmtwdah okay
22:08amalloyso yo has two arguments, both mandatory
22:08tmtwdokay
22:09amalloywhich can both have any type, but it is probably a bad idea to pass anything but a string in the foo slot
22:09tmtwdI meant foo would be casted to a String and bar would be treated normally
22:10amalloytmtwd: it will be cast to a string if any java interop is actually done to it. eg, ((fn [^String s] (.length s)) whatever) casts to a string. but ((fn [^String s] 5) whatever) doesn't
22:10amalloyagain, the function would have the same output whether or not you typehinted it; what's being discussed here re casting is just implementation details of how efficiently the runtime can give you that output