#clojure logs

2016-03-02

02:55solatisare promises/futures actually used often by clojure programmers? or is it more often core.async?
02:56solatisor do they complement each other?
03:00prohoboHAHA!
03:00prohobo(= is the ONLY equality operator in clojure <3
03:00prohobothank god
03:01amalloyaside from ==, and identical?, and...
03:02prohobodamn it
03:02prohobostill better than clisp's eq eql equal equalp
03:03tolstoy I don't think I've ever used == or identical?, come to think of it.
03:09amalloy== is tough to justify. identical? is useful sometimes
03:10prohoboi assume identical isn't just looking for truthy/falsy but more along the lines of same address space?
03:10prohobosame object?
03:10prohoboerrr form/atom
03:11ridcullyits the java ==: object identity
03:12ridcullywhere = is along .equals
03:12ridcullyi assume there is more to it, but thats my naive view on the world here
03:30renlhi in clojure destructing, i can destruct a map like [{:keys [a b c]} map1] what if I wanna destruct 2 similar maps in the same local binding like [{:keys [a b c]} map1 {:keys [a b c]} map2]?
03:31opqdonutdon't use :keys, just normal map destructuring
03:32opqdonutyou could use something like [{a1 :a b1 :b c1 :c} map1 {a2 :a b2 :b c2 :c} map2] if you really must
03:32opqdonutbut I'
03:32opqdonutd just use (map1 :a) etc in the body
03:33renlthanks :D that was what i guessed but was wondering if there were some other magic i wasnt aware of heh
03:59prohoboclojure makes the simplest things moderately confusing
04:00prohobocool
04:04shadow6ram420slow loris still in my search bar. :)
04:05TEttingerha
04:05TEttingershadow6ram420: you mentioned tech support? are you programming in clojure or just looking for tech experts?
04:06TEttingerthere's a pretty good supply for both topics here :)
04:06shadow6ram420i just miss the old chris pirillo chat i used to visit
04:07shadow6ram420 have been looking any tech community to lurk and just somthing for the second screen.
04:08shadow6ram420i am not a programmer but have fallowed along to a few c++ lessons.
04:12prohoboshadow6ram420: i recommend #ubuntu-offtopic or something akin to that
04:12TEttingerah ok, yeah clojure's a good friendly community
04:12TEttingerthat too
04:12prohoboif you want random discussions about computer stuff
04:13prohobohere we talk about dangerous mammals and clojure
04:14prohobobtw, what's the point of destructuring function args?
04:14prohobowell i can see the use for destructuring a map
04:15prohobobut a vector? what difference does it make
04:15shadow6ram420who me? i cmae here for deadly mammal chat ty tho.
04:43TEttingerprohobo: actually it can be quite handy
04:43TEttingerlike you could use [10 20 30] to represent a 3d point
04:44TEttingerif you want to bind that to x, y, z, you could destructure to (let [[x y z] pt] ...) where pt is the above three-element vector
04:51prohoboTEttinger: ah i haven't gotten to let yet
04:52TEttingerah, it's the same destructuring as in fn args
04:52prohoboi just saw something like (defn foo [[arg1 arg2 & opts]] ...)
04:52TEttingerah!
04:52TEttingerthere's a good benefit there
04:52prohoboand that essentially works exactly the same as (defn foo [arg1 arg2 & opts] ...)
04:53prohobowhat's the benefit?
04:53tdammersit's not exactly the same
04:53tdammersyou pass the vector as one argument
04:53TEttingernormally, if you wanted to pass a collection to the second kind of fn you just entered, you'd need apply
04:54prohobohmmm
04:54prohoboi guess ill see
04:54TEttinger,(defn foo [a b & more] (+ a b (count more)))
04:54clojurebot#'sandbox/foo
04:54TEttinger,(foo 1 2 3 4 5)
04:55clojurebot6
04:55TEttinger,(defn bar [[a b & more]] (+ a b (count more)))
04:55clojurebot#'sandbox/bar
04:55TEttinger,(bar (range 1 6))
04:55clojurebot6
04:55TEttingersimilar to
04:55TEttinger,(apply foo (range 1 6))
04:55clojurebot6
04:56prohoboo_o
04:56prohoboi cant see it
04:56TEttingernot sure I picked a good example
04:56TEttingerapply lets you turn a seq of arguments into individual args, essentially
04:56TEttinger,(+ 1 2 3 4)
04:56clojurebot10
04:57TEttinger,(apply + [1 2 3 4])
04:57clojurebot10
04:57TEttingerif you just did that last one without apply... not working
04:57TEttinger,(+ [1 2 3 4])
04:57clojurebot#error {\n :cause "Cannot cast clojure.lang.PersistentVector to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "Cannot cast clojure.lang.PersistentVector to java.lang.Number"\n :at [java.lang.Class cast "Class.java" 3176]}]\n :trace\n [[java.lang.Class cast "Class.java" 3176]\n [clojure.core$cast invokeStatic "core.clj" 351]\n [clojure.core$_PLUS_ invokeStatic "co...
04:58TEttingerif you know something is going to give you a vector or seq of some kind, you can either use apply along with a fn that takes individual args, or you can use a fn that destructures that vector or seq
04:59TEttinger(if you have that kind of logic where you know there's a bunch of elements, but other fns aren't a good fit like map or reduce)
04:59prohoboah i see
04:59prohoboapply is like a split
04:59TEttingeryeah, similar indeed
05:00TEttingerit's one of the most common fns in clojure, along with map, filter, reduce...
05:00TEttingerI'm only mentioning the fns that take other fns as args, because they're the most useful in general
05:01tdammerson a related note; I wonder why function composition isn't anywhere near as popular in clojure as it is in other FP languages
05:01tdammerssame for currying
05:01TEttingertdammers: have you seen justin_smith's one-liners in here? :)
05:01tdammersnot that I consciously remember :D
05:01TEttingerhe's gotten some pretty good point-free style stuff working before
05:02tdammersyeah, but it's not a very common idiom, is it
05:02TEttingerand that often uses comp, juxt, and partial
05:02TEttingeryeah, it isn't as practical I suppose as in haskell where currying is there anyway
05:02tdammerse.g., in Haskell I'd write sth like: foo = apply bar
05:03TEttinger(partial apply bar) might come close, but I agree that it isn't as common
05:03tdammersyeah
05:03TEttingernot quite sure why
05:03tdammersespecially not to *define* foo
05:03tdammers(def foo (partial apply bar))
05:03TEttingerthe fns are a bit more verbose, partial instead of the implicit currying
05:04mpenetwell, the more you write clojure code the more you tend to avoid apply in my exp.
05:04TEttingermpenet: I think it largely depends on how much you control the environment too
05:04TEttingerif using a lib that has weird conventions, it may be more common, I'd think
05:05mpenetJust checked our (large'ish) codebase, 3 apply calls (on external libs that do unrolled option maps in api)
05:05mpenetyeah
05:05TEttingerwoah
05:06mpeneton carmine too sometimes
05:07TEttingerI'm going to be writing a clojure wrapper for a large-ish java lib I've been writing. I haven't quite figured out cursive yet, there seems to be a bug that is normally intermittent and resolves itself but isn't for me
05:07TEttingerI'm pretty rusty with clojure though
05:28tangled_zugh, got disconnected.
05:38sunset-shimmerhello!
05:39prohobohello
05:42sunset-shimmerI've created macros that help me wrap requests to database in something like "with-connection" form. So, now I can write (def-db-cmd [fname args] (cmd args)) and it expands in (defun fname [cmd args] (with-connection *conn* (cmd args))). I like it, but
05:43ridcullysunset-shimmer: your text got cut herish: `I like it, but`
05:43sunset-shimmerI am Cursive user and Cursive cannot help me with autocompletion of such functions (functions that was generated with macro)
05:43sunset-shimmerthe question is - is it possible in principle?
05:47tangled_zHi guys, can anyone advice how I could add middleware to a compojure-api api?
05:50sunset-shimmerBy "it" I mean autocompletion for such functions. May be anyone who uses Cursive too can help me?
05:53sunset-shimmertangled_z: hi! Did you try did it like in this example https://github.com/metosin/compojure-api/wiki/Building-Documented-Apis#middleware
05:55Leonidas,@(java.util.concurrent.FutureTask. (fn [& _] 42))
05:55clojureboteval service is offline
05:55LeonidasAny idea why this code does not terminate?
05:56LeonidasCalling .get on it does not work either.
06:01amalloyfuturetask doesn't run a thing unless you ask it to
06:01amalloy@(doto (...) (.run))
06:07tangled_zsunset-shimmer: hi! thanks for replying
06:08tangled_zI didnt see that example before, but I tried working with it now, and am getting a bit confused about this part: (middleware [wrap-head [wrap-params {:keywords true}]]
06:08tangled_zsunset-shimmer: could you explain what the [wrap-head [wrap-params reffer to?
06:09tangled_zIm trying to put wrap-cors into it
06:09tangled_zbut Im not sure if (wrap-cors) should replace "wrap-head" or "wrap-params" in the example
06:17sunset-shimmertangled_z: I haven't used cors but it looks as you can put it in place of any. Like :middleware [wrap-cors]. I think wrap-head and wrap-params are just examples.
06:22tangled_zsunshet-shimmer: hmm, it keeps giving me weird errors when I try to put in my code for wrap-cors into it. would you know of any working examples of any other middleware I could have a look at?
06:31sunset-shimmertangled_z: I did't know any. I can try to compose one myself if you have some time for waiting.
06:31tangled_zsunset-shimmer: sure! that would be nice of you.
06:32tangled_zIm trying to basically put the example from here https://github.com/r0man/ring-cors into the compojure-api middleware
06:34sunset-shimmerokay! I'll be back in a moment.
06:47sunset-shimmerwell, http://pastebin.com/PhgqsRDS that code compiled without errors at any rate
06:47sunset-shimmerdid you have compile time errors?
06:48sunset-shimmerGET http://localhost:3000/api/ping -> {"ping":"pong"}
06:50tangled_zsunset-shimmer: ooh that made progress,thanks! no compile errors
06:50sunset-shimmerbut if we need params like in example... http://pastebin.com/ixhEkKyH that gives error!
06:51tangled_zyeah i was about to say, i just tried that
06:51tangled_z:(
06:51tangled_zany idea why?
06:53sunset-shimmernot yet. but lets try to replace vector with lambda.
06:54tangled_zhmm
06:55sunset-shimmerhttp://pastebin.com/ZSaf9qfP
06:55sunset-shimmerlike here
06:56tangled_zoooh no errors!
06:56sunset-shimmergreat!
06:56tangled_z:D
06:56tangled_zlet me see if this works for data transfer
06:56sunset-shimmeryes
06:57sunset-shimmerI mean, let's go.
06:59tangled_zOk, hmmm... Nope. chrome still says that cross origin requests are not supported
06:59Empperiyou can do that with CORS
07:00Empperibut yeah, it still says that and will *always* say that
07:00Empperithank god
07:01tangled_zEmpperi: what do you mean?
07:01tangled_zIm trying to use cors and it's not working. I cant figure out where the problem is.
07:02EmpperiCORS is a slightly tricky beast which requires multiple pieces to be put together to make it work
07:02Empperiunnecessarily many imho
07:02tangled_zEmpperi: yeah it is always a pain for me. :( Struggled with it when I was learning django an
07:02tangled_zand now again with clj
07:02Empperihttps://www.refheap.com/52e1ce4a5a560301a3d952909
07:03Empperithat's what you need on the server side
07:04Empperiafter that it should be relatively straightforward
07:05Empperiwhen you try to make a cross domain request browser first sends an OPTION request
07:06Empperithen it'll receive those headers and find that the domain it is currently sitting on is declared at Access-Control-Allow-Origin:
07:06Empperiafter that you can make the XHR request to that domain
07:06Empperioh and yeah, that "Auth" header part: specific to our app :)
07:07Empperibut generic enough
07:07Empperiit's a bit tedious since you need to list *every* HTTP method you like to use and *every* HTTP header
07:07tangled_zEmpperi: thanks a lot for the code and explanation!
07:07tangled_zErm
07:07tangled_zThough
07:08tangled_zIt's more low level than what Im working with, Im not sure how to connect it with my own code.
07:08tangled_zWould you have a use-example?
07:08Empperiunfortunately no, this is a closed source project
07:08Empperibut you pretty much need to add that stuff into HTTP responses sent from the server
07:09Empperiafter that browsers will handle everything else automatically
07:09Empperiso you can just make a GET request or whatever and browser will under the hood make that OPTION request
07:09tangled_zOhhhh, I see!
07:09tangled_zand so the "host" is the host that I am allowing the connection to?
07:09Empperibut of course you need to handle that OPTION request :)
07:10Empperiyeah
07:10Empperithat is the host which is serving the javascript trying to make the cross domain XHR request
07:11Empperiif you're serving that js from eg. https://foo.com and making a cross domain request to https://bar.com then the OPTION responses from bar.com should declare foo.com as allowed host
07:11tangled_zWhat do you mean by "handling the option request"? will that not be done automatically?
07:11Empperidepends on your application
07:12Empperibut OPTIONS is a HTTP request just like GET is
07:12Empperilet's say you're trying to make GET https://bar.com/api/save-the-world
07:13Empperibrowser will first call OPTIONS https://bar.com/api/save-the-world
07:13Empperiand checks if the appropriate CORS headers are in place and if a) current host is allowed to make requests b) if GET method is allowed
07:13Empperiif both match then it proceeds to make the original GET request
07:14Empperiso, if you don't have a proper http request mapping for OPTIONS /api/save-the-world then the caller side will not receive the CORS headers and it will not work
07:14Empperithe easiest way to handle this is to make a universal OPTIONS mapping which receives all OPTIONS requests
07:15Empperiand just return the headers
07:15Empperithe reason why it is like this is that there might be a scenario where one would want to limit cross domain requests per URL
07:16Empperiso in essence when your javascript calls *any* cross domain URL it'll first do that OPTIONS call - always
07:16Empperiso you'll end up doubling your XHR requests
07:16tangled_zEmpperi: Ahh yes, that makes sense!
07:17Empperiso make damn sure your OPTIONS handler is lightning fast, meaning it doesn't do any additional stuff :)
07:17Empperiwe created a middleware for that
07:18Empperiit rules out using OPTIONS within our application in route mappings but that shouldn't be a problem
07:18sunset-shimmerI should save your conversation for the future use...
07:19tangled_zso that means you can't use cors?
07:19Empperisure you can use it
07:19tangled_zsunset-shimmer: Oh, I always save helpful conversations :)
07:19Empperiit just makes stuff slightly slower
07:20tangled_zHmm. But if you need OPTIONS to pass cors, and you've disabled OPTIONS using the middleware.. hmm.. I am a bit confused!
07:20Empperiwe can't do OPTIONS mappings within our application if the middleware stops those requests and handle those itself
07:20sunset-shimmertangled_z: did you test it at localhost? Chrome doesn't support localhost for CORS
07:21Empperiyes, that is an additional hassle, forgot that
07:21Empperibut you can tell chrome to accept those
07:21Empperiit's ok for development
07:22tangled_zWait what
07:22tangled_zYeah I tested it with chrome -_-
07:27Empperianyway, I need to do some work :)
07:27Empperihope that clarified a bit
07:27tangled_zAlright! Thanks for the advice! :)
07:27tangled_zYeah that was a massive help :)
07:27EmpperiCORS is pretty complex beast but security stuff tends to be :P
07:27tangled_zYeahh it makes sense why
07:28tangled_zJust a paaaaain atm
07:28Empperiindeed
07:28tangled_zSpent far far longer on it than id want to
07:28amoeI'm finding the auto-reloading functionality of "lein ring server" to be very flaky, as in it doesn't notice changed files half the time, and I can't figure out why
07:28Empperiwe had to do CORS requests since we had to serve our app on HTTP (don't ask) but we still wanted to make all our XHR requests with HTTPS
07:28Empperiand that equals as cross domain request for browsers
07:29tangled_zThat sounds frustrating
07:29tangled_zAll I'm doing is trying to communicate between localhost:3000 and localhost:3994 at the moment!
07:32sunset-shimmeramoe, me too
07:33tangled_zOh my god WHAT
07:34tangled_zIt was a typo on the f'cking client the entire time
07:34tangled_zGod damn it.
07:34tangled_zOk, thanks for the help sunset-shimmer and Empperi. (At least now I know about middle-ware and headers more in depth)
07:35sunset-shimmeryou are welcome!
07:35tangled_z:D
07:35tangled_zYeah it was helpful.
07:35Empperilol
07:35tangled_zI am so annoyed with myself right now. Like, I was so convinced that "CORS is difficult so I MUST have made the mistake on the server" that I never double checked the client-side stuff
07:41amoeWhy would someone write "(let [] (some-expr))"? what use is a let without any bindings?
07:42opqdonutamoe: well you can use (let [] ...) instead of (do ...) to turn multiple expressions into one
07:42opqdonutamoe: but yeah, let [] doesn't make much sense
07:42Empperibut it's just stupid to do it like that
07:43EmpperiI didn't even know that compiles :)
07:43sunset-shimmerlol
07:43opqdonutwell it's nice for macro-writing that you can have empty lets
07:43opqdonutand empty dos
07:43opqdonutetc
07:45Empperitrue, with macros empty let can make sense
07:46Empperione doesn't have to handle the special case then
12:28morbid_apehi everyone
12:28morbid_apeburn all jews in oven
12:28morbid_apedeath to infidel
12:28morbid_apeallahu akhbar
12:35phillordIs there a syntax for getting a short int in Clojure?
12:37Bronsaphillord: there's no real short type in the JVM
12:37morbid_apeBronsa you filthy jew
12:37Bronsaonly int/long exist at the VM level
12:37morbid_apeburn in oven you foul jew
12:37morbid_apedeath to infidels
12:37morbid_apeyou foul infidel
12:37Bronsapuredanger: ping
12:38phillordBronsa: learn something every day!
12:39morbid_apeallahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!!
12:39demophoonops?
12:39Bronsaamalloy_:
12:55justin_smithphillord: it is possible to put a short into a ByteBuffer though
12:55morbid_apeallahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!!
12:55morbid_apeallahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!!
12:55justin_smith(or the universally agreed representation of one)
12:55morbid_ape4allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!!
12:56phillordjustin_smith: true -- I guess I am not worried about performance here, though. Really I just need a range which is smaller than int. There are probably better ways to do this, now that I think more clearly
12:56justin_smithphillord: you could just use bitwise-and
12:57justin_smith,(doc short)
12:57morbid_apebitwise operators are for infidels
12:57morbid_apedeath to infidels
12:57clojurebot"([x]); Coerce to short"
12:57justin_smith,(short 32768)
12:58clojurebot#error {\n :cause "Value out of range for short: 32768"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Value out of range for short: 32768"\n :at [clojure.lang.RT shortCast "RT.java" 1153]}]\n :trace\n [[clojure.lang.RT shortCast "RT.java" 1153]\n [sandbox$eval47 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval47 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang.Compiler eval "Co...
12:58justin_smith,(short 32767)
12:58clojurebot32767
12:58morbid_apeCLOJURE IS INFIDEL PROGRAMMING LANGUAGE
12:59justin_smith,(type (short 1)) ; haha
12:59clojurebotjava.lang.Short
12:59justin_smithoh wait, in my repl at home that returns java.lang.Long
12:59justin_smiththe plot thickens!
13:00rcassidyweird, i get Short
13:00rcassidy,(clojure-version)
13:00clojurebot"1.8.0"
13:00justin_smithrcassidy: never mind, PEBKAC on my end
13:00rcassidyha, gotcha
13:00justin_smithso yeah, it does return a Short
13:01morbid_apeSIEG HEIL
13:01morbid_apeHEIL HITLER
13:02justin_smithBronsa's info is usually good, so I wonder what's going on there - the official docs mention short as a primitive and Short as a class https://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html
13:02WorldsEndlessHow to relative paths work in a project? If I specify a file at "resources/myfile.docx" where is it actually going to look relative to my application dir?
13:02justin_smithWorldsEndless: it depends who is looking
13:02justin_smithWorldsEndless: many lookups are classpath relative
13:02justin_smithbut some are file system relative
13:02justin_smiththe latter is very prone to breaking in deployed code though
13:03WorldsEndlessSounds like a messy problem...
13:03WorldsEndlessHow can I reliably reference files shipped with my app?
13:03justin_smithWorldsEndless: the best practice is that unless you specifically need something that is on disk, use classpath relative lookup
13:03justin_smithWorldsEndless: use clojure.java.io/resource and that returns something as found on the classpath
13:04morbid_apesieg heil
13:04justin_smithyour resources and your source dirs are all on the classpath, both at dev time and when running from a jar
13:04morbid_ape4allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!! allahu akhbar!!!!
13:05WorldsEndlessjustin_smith: So are you saying that a resources/myapp.docx call will check in each location until it finds a matching one, or not?
13:06justin_smithWorldsEndless: I'm saying that if you have a file in resources/myapp.docx and resources in in your resources-path (which is the default in lein) then (io/resource "myapp.docx") will find that as a readable resource as runtime
13:07justin_smithWorldsEndless: note it will give you something you can read from, but not a file- because things inside jars are not yet files
13:07justin_smith(at deploy time that is)
13:07WorldsEndlessI don't see a :resources-path specified in my project.clj, so I guess it just checks project/resources ?
13:07rhg135Usually url
13:07justin_smithbut you can slurp it or send it via a ring handler or whatever
13:07justin_smithWorldsEndless: the default is resources
13:08justin_smithWorldsEndless: in a repl, try io/resource - you should get a non-nil return value for things in your resources directory, and they will be included in an uberjar
13:09justin_smithand the point of io/resource is it works the same, whether in a repl with files on disk or in a java process with files inside the same jar
13:10WorldsEndlessAh! I see. beautiful
13:25cortexmanis there a version of conj that preserves the order of the arguments?
13:26cortexmanmaybe i just need to reverse the order of my arguments
13:26cortexmani'm doing conj on a bunch of dicts, and the last one comes first
13:27justin_smithcortexman: it has nothing to do with conj, hash-maps do not preserve order
13:27cortexmani need a vector of maps that are in a certain order
13:27justin_smithand vectors always conj to the end, and lists always conj to the beginning
13:27cortexmani see.. hmm..
13:28cortexmanah.
13:28justin_smithso by picking between () and [] as your starting value, you should get the order you want, right?
13:28morbid_apeYOU ARE A FILTHY HOMOSEXUAL JUDEN ANIMAL PERPETRATOR
13:28cortexmanyep
14:03@amalloyoh, he left already
15:40ShayanjmSo I have (yet another) optimization question. I need to perform a transformation as efficiently as reasonably possible - essentially taking a list of 'filters' with their owners attached, and turning it into a list of owners with their filters attached
15:41Shayanjmhere's a direct example of the input/expected output: https://gist.github.com/shayanjm/2f731644ffd964df6961
15:41ShayanjmI could trivially build the output using a bunch of nested loops but was wondering if anyone had anything more performant/elegant in mind?
15:52wgatorlist T>1
15:52wgator\list T>1
15:58TimMcShayanjm: One reduce and a map oughtta do it.
16:04justin_smithTimMc: or a transduce with a map transducer, since efficiency was mentioned after all
16:11TimMc...I still haven't tried out transducers.
16:22amalloyisn't Shayanjm's problem just "implement group-by"?
16:26Shayanjmexactly amalloy
16:26amalloyso, why implement group-by instead of using group-by?
16:41justin_smithamalloy: I'd say it's more three filters in a vector, maps show up in more than one of the outputs, I don't see how that can be done with group-by?
16:42amalloyi see. i hadn't noticed that part
16:43amalloyi guess i would say, how sure are you that performance matters here? start with the really dumb thing of like (apply merge-with into (for [filter filters, user (:users filter)] {user [filter]})) and see what happens
16:44amalloy(this is way more trivial than "a bunch of nested loops")
16:47justin_smithyeah, that actually looks close to the answer
16:51amalloywell it's a correct solution. whether it's fast enough is one Shayanjm can measure
16:52justin_smith{:user-id user :filters [filter]} but sure
16:54boomcould i trouble someone for help with an error?
16:55justin_smithboom: you can always just go ahead and describe the error, but if you need to share more than one line of code, or a stack trace, use a paste site
16:55boomok, I don't think it will take too many lines to describe
16:56boomI have a compojure application, and when attempting to build an uberjar, it gives me an error
16:56boomCompiling myapp.routes Uberjar aborting because jar failed: clojure.lang.MapEntry cannot be cast to clojure.lang.IPersistentMap
16:56justin_smithboom: what that means usually is that you provided a single map where it wanted a sequence of maps
16:56boomI've looked at myapp.routes, and the file seems to be fine, but I'm not sure if the error that 'lein uberjar' gives is related to the previous file or not
16:57boomI'll double check
16:57justin_smithboom: does the app actually run outside the uberjar context, if you just use lein run or whatever?
16:57boomyes it runs fine
16:58justin_smith,(def filters [{:data "DATA1" :name "NAME1" :users #{1 2 3} :url "URL1" :title "TITLE1"} {:data "DATA2" :name "NAME2" :users #{1 3} :url "URL2" :title "TITLE2"}])
16:58clojurebot#'sandbox/filters
16:58justin_smith,map (fn [[n fs]] {:user-id n :filters fs}) (sort (apply merge-with into (for [filter filters user (:users filter)] {user [filter]}))))
16:59clojurebot#object[clojure.core$map 0x4a52f74d "clojure.core$map@4a52f74d"]
16:59justin_smith,(map (fn [[n fs]] {:user-id n :filters fs}) (sort (apply merge-with into (for [filter filters user (:users filter)] {user [filter]}))))
16:59clojurebot({:user-id 1, :filters [{:data "DATA1", :name "NAME1", :users #{1 3 2}, :url "URL1", :title "TITLE1"} {:data "DATA2", :name "NAME2", :users #{1 3}, :url "URL2", :title "TITLE2"}]} {:user-id 2, :filters [{:data "DATA1", :name "NAME1", :users #{1 3 2}, :url "URL1", :title "TITLE1"}]} {:user-id 3, :filters [{:data "DATA1", :name "NAME1", :users #{1 3 2}, :url "URL1", :title "TITLE1"} {:data "DATA2", ...
17:03Shayanjmlooks great, thanks for your help both justin_smith & amalloy
17:12boomok so I commented out the entire file except for a single route definition, and I'm still receiving the same error from 'lein uberjar'
17:14TimMcboom: Maybe post it on a pastebin.
17:18amalloywhy would you call sort on a map like that? just build a sorted map to begin with. (apply merge-with into (sorted-map) (for ...))
17:19cortexmani am getting Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: :db.error/not-a-data-function Unable to resolve data function: :db/id when i try to transact this: [{:db/id #db/id[:db.part/ some-part] :some/id someval}]
17:19cortexmandriving me mad
17:20tolstoyMaybe try (d/tempid :some-part) instead of the reader macro thing?
17:22cortexmantolstoy, no difference
17:22cortexmandoes it matter that i have a vec of hashmaps
17:23tolstoyI'm not sure. Got a paste with the full function call?
17:24tolstoy@(d/transact conn [{:db/id (d/temp-id :part) :user/id (d/squuid) :user/name "Ezzie Boof"} {:db/id (d/temp-id :part) :org/name "Dance Club"}])
17:24tolstoyThat sort of thing works for me all the time.
17:25tolstoyUnless I 1) forget the vector, or 2) use an incorrect value for "conn", or 3) forget the conn parameter.
17:30cortexmanthe error message is just so inscrutable
17:30cortexmanas far as i can tell, i'm doing what you pasted
17:31tolstoyHm. Maybe I can fire up an app here and see if I can reproduce it.
17:33cortexmani'm going to keep hacking on it
17:41amalloyso i'm having a problem editing this macro: https://gist.github.com/amalloy/76a82d8f736afcb9ccd8 - it's a simplified version of my real problem, but the issue that i can't seem to get metadata on the list `(force ~delay-sym). you can see what i mean via: (set! *print-meta* true) (macroexpand-1 '(let-later [^String foo "test"] (.length foo)))
17:42amalloywait never mind, somehow when i wrote it out like that it totally works. what was i doing before that is not working. brb
17:42justin_smithamalloy: as an aside, I'm fascinated to see force
17:42justin_smith,(force 1)
17:42clojurebot1
17:43justin_smith,(force (delay 42))
17:43clojurebot42
17:43justin_smithcool!
17:43justin_smithI always just used deref on delays but that's super handy
17:44tolstoyThinking it makes things clearer?
17:44justin_smithtolstoy: yeah, and also it's handy that force on non-delayed things works
17:44tolstoyAh, ok.
17:45amalloy~justin_smith is fascinated by force
17:45clojurebotIk begrijp
17:50amalloysigh. now it works perfectly, but it does me no actual good because clojure.tools.macro discards the metadata i went to all the trouble of putting on my forms
18:48eeepci just want to get kicked out of a bunch of channels
18:48eeepcwhy is no one cooperating??
18:48eeepc#trump2016
18:48eeepccant stump the trump
18:48eeepccant stump the trump
18:48eeepccant stump the trump
18:48eeepccant stump the trump
18:48eeepccant stump the trump
20:30renlis there a way for filter to produce 2 vectors one which pass the condition and one that does not
20:30renlas opposed to doing filter twice with inverse conditions
20:31renloh partition-by i answered my own question heh
20:41amalloythat's not what partition-by does
20:44amalloy,(partition-by even? (range 6))
20:44clojurebot((0) (1) (2) (3) (4) ...)
20:46pilneok, now this time i won't fubar my smeggin install by futzing around with too many languages >.< can i get an a-men?