#clojure logs

2015-09-06

00:09justin_smithTEttinger: fascinating
00:10justin_smithTEttinger: always interesting to see another attempt at manual memory management in a lisp, I'll have to check out how this one approaches it
06:39skeuomorflazy question, is there a way when in smartparens-strict-mode to delete a single paren but not the pair?
06:39ska-fanIs (zipmap (map :build-id builds) builds) idiomatic?
06:42ashwink005is there a limit to the size of mysql database columns that one can make?
06:46Rurikashwink005, #mysql would know better
06:47oddcullyska-fan: looks fine to me - if your build-id is always set and unique. otherwise maybe group-by is an option
06:49ska-fanoddcully: Thanks. I just thought a terser way might be possible - build is mentioned twice.
06:49ashwink005Rurik: resolved it. Turns out you can't have a column named :desc in mysql
06:50RurikI guess that is because DESC is a keyword in SQL?
06:50wasamasawat
07:00tim_(def app-state (atom {:expanded-rows #{124}})
07:01tim_how do I add to expanded-rows with swap ?
07:02oddcully,(let [a (atom {:x #{1}})] (swap! a update-in [:x] conj 2))
07:03clojurebot{:x #{1 2}}
07:09Rurikuser=> inc
07:09Rurik#<core$inc clojure.core$inc@7fab2b22>
07:10RurikWhat does this mean
07:11wasamasathat's how a function is represented in clojure
07:12tim_oddcully: thank you
07:12Rurikyeah, but what does this strange sentence mean
07:12RurikI'm assuming @7fab2b22 is the memory address
07:12tim_I think its just a string representation of the function's location in memory
07:14tim_well, its unique id anyway - but I guess you want more detail than that - I'll leave to someone who knows what they are talking about
07:14muhukRurik: use (doc inc) if you want user readable info on a function.
07:15Rurikno, I want to know what this information means
07:17wasamasagenerated java names for the method I guess
07:27oddcully,(pr inc)
07:27clojurebot#object[clojure.core$inc 0x4c3a535c "clojure.core$inc@4c3a535c"]
08:49ashwink005how do I set default values in a JDBC connected mysql database?
08:53ashwink005helloo?
08:55vakhi all
08:57vakThere is an interesting post http://swannodette.github.io/2013/08/02/100000-processes/ and i am trying to reproduce it. But this namespace isn't found: (require ... [blog.utils.dom :refer [by-id set-html! set-class!]])
08:58vakcould i somehow get the stuff for this namespace via lein? or I'd rather have to find similar functions somewhere else?
09:10trissso any of you doing any sort of literate programming? Is Marginalia your tool of choice?
09:20vakI did a lot of literate programming, but in R/Sweave
09:31trissvak: that sounds very cool. More aimed at producing finished docs than documenting systems though is it on first glance? Can we do similar in clj yet?
09:32vaktriss: literate programming is very cool in (science) research.
09:33vaktriss: in pure/generic IT it is not that requested IMHO
09:34muhukvak: precisely. Because you often have overriding priorities.
09:34trissAgreed.
09:35trissI'm going back in to academia tho....
09:35trissand I really like what he process of getting nice documentation ready for code does to my code.
09:37trissThis seems to be true for me: "The quality of the prose in your documentation will often reflect the quality of the code itself thus highlighting problem areas. The elimination of problem areas will solidify your code and its accompanying prose. Marginalia provides a virtuous circle spiraling inward toward maximal code quality."
09:37trissstil believe code should be as self documenting as possible though
09:40vaktriss: even in science you'll get a lot of colleagues that are borred of literate programming approaches. Albeit many of them will complain on non-reproducible results and lack of possibility "re-create the whole paper after a small fix in labor data"
09:41vaktriss: the life is funny thing)
09:48crocketCan I insert a clojure plugin into lazybot?
10:00sobelcode is not self documenting. code does what code does, and intentions are sometimes correlated with intuitive idioms, but that's not a reliable documentation method
10:00sobelsome words about the actual domain and intention of code can save so much time for a reader
10:00clojurebotTitim gan éirí ort.
10:01sobelreader
10:01sobel(what triggered that?)
10:04muhukHow do you implement queries in Onyx?
10:05muhukHow would you aggreage from multiple tasks?
10:05crocketAla
10:06muhuk(or is it just intended for commands - in a CQRS sense)
10:40RurikWhy do fn and let take a vector of args/bindings
10:43justin_smithRurik: the thought was to make parens less overloaded
10:44justin_smiththey do a lot of different things in most lisps, but Hickey wanted to use other delimeters to make it easier to differentiate things
10:44Rurikah, nice
10:45RurikI always kinda got confused by the system scheme used
10:58kwladykajustin_smith, do you know place where they looking Clojure Junior?
10:58justin_smithno, I don't
10:58kwladykayou was my last hope ;)
10:59kwladykaI really try, but it is much harder then i thought to be a Clojurian :)
11:00kwladykaeven many people say Clojure is death technology and it doesn't make sense etc. I don't know history of Clojure but way many people don't like Clojure?
11:01kwladykaAll love Scala, but Clojure is evil. What is the point?
11:01RurikI don't think that is true...
11:03kwladykame too, but many people think bad about Clojure. I don't know how it look in USA or on West but in my Country and around it is not easy.
11:04scottjkwladyka: 99% of programmers don't know enough about clojure to have a worthwhile opinion about it.
11:06kwladykascottj, but it shapes the labor market (i am not sure it is correct in english :) )
11:07kwladykai like so much Clojure... and just can't find a job in this language :) I found one company but they just starting make a Clojure team and hire 1 person for now :)
11:12engblomkwladyka: To me it looks like neither Clojure nor Scala gets much love in the job market.
11:13RurikIsn't loop recur exactly like a while loop?
11:16muhukRurik: a while loop is a loop-recur.
11:17Rurikmuhuk, so loop-recur goes beyond what a while loop can do?
11:18muhukRurik: why, yes.
11:19justin_smithRurik: the difference is that loop can create new bindings each time
11:19justin_smithwhich is very helpful when your data is immutable
11:20Rurikgotcha
11:22tomjackwhen you say "while loop" do you mean a (while ...) in clojure or maybe a while loop in some imperative language?
11:36ashwink005how can I check what request have I fired to mysql server?
11:36ashwink005can I log that in repl
11:36Ruriktomjack, imperative
11:37Rurikashwink005, I guess you can use do to print a message in the repl the moment you execute the fn
11:38ashwink005Rurik: I have done that. When I execute the command in mysql command line I get a result
11:38ashwink005Rurik: but repl gives the result as nil
11:38ashwink005for the same command.
11:38ashwink005the difference being, in repl I use WHERE X=? then pass parameters
11:39ashwink005while in mysql I do WHERE X=5
11:43ashwink005anyone...?
11:51justin_smithashwink005: can you share a paste of your repl interaction?
11:51justin_smithashwink005: I think this could have to do with how you are using the return value
11:52ashwink005hello-compojure.database.db> (getFilteredOffers ["delhi"] nil nil nil nil nil nil nil nil nil nil) SELECT * FROM OFFERS WHERE budgetmin>=? AND budgetmax<=? AND year>=? AND mileage<=? AND owner<=? AND (INSTR(city,"delhi")>0) nil
11:52ashwink005SELECT... is the print
11:53ashwink005nil is the output
11:53justin_smithand where are you privoding any numeric parameters there?
11:54justin_smithcan you use refheap.com to show us the code of getFilteredOffers?
11:55ashwink005justin_smith: after this statement I add all 5 parameters
11:55ashwink005in the vector
11:56ashwink005the same query in mysql command prompt with parameters attached inline gives a row output
11:56justin_smithwhat vector? I can't tell you what's wrong without seeing the actual code you use with jdbc
11:58ashwink005justin_smith: http://txt.do/ac9el
11:59justin_smithashwink005: the key to with-query-results is you have to do something with res
11:59ashwink005justin_smith: create multi query just makes a bunch of INSTR(column,value) statements and appends with an OR
12:00ashwink005justin_smith: oooohh myyyy effin gaawd
12:00justin_smithashwink005: you provide no body to with-query results, so the block returns the same thing (do) does - nothing because no code
12:00justin_smithashwink005: this is why I asked to see your code :)
12:00ashwink005justin_smith: I'm so sorry.. thats a rookie mistake!
12:00ashwink005justin_smith: thanks man :) alot! and sorry
12:00justin_smithashwink005: every question on this channel is somebodies rookies mistake, it's all good :)
12:01ashwink005justin_smith: hee hee thanks :)
12:35kavkazIs ({:somekey :someotherkey} :somekey) faster than (first '(:somekey :somekey2))?
12:38justin_smithkavkaz: they are not even doing comparable things, but no, it should be a little slower
12:39justin_smithyou've got two different kinds of data structures there of course
12:43kavkazjustin_smith: I see. I'm just trying to figure out a better data structure for my algorithm, or perhaps I just haven't thought of the right way of doing it
12:43kavkazI think my logic is all there though
12:43justin_smithkavkaz: do you need associative lookup?
12:43justin_smithdo you need ordered storage?
12:44kavkazjustin_smith: I need associative lookup more than anything. I'm making a lazy sequence of primes, something is slowing it down though and I'm trying to figure out what
12:45justin_smithOK, because '(:somekey :somekey2) is not associative - it might be efficient as eg. a stack, but not for looking anything up
12:48justin_smithkavkaz: with numeric stuff, I would be sure to turn on warn-on-reflection and warn-on-boxing
12:53kavkazjustin_smith: Oh thanks! I'll have to look up what those things are but perhaps it'll help me (:
12:58justin_smithkavkaz: :global-vars {*warn-on-reflection* true *unchecked-math* :warn-on-boxed}
12:58justin_smith(those are the options for project.clj)
12:59kavkazThanks, I was just putting :warn-on-boxed in project.clj and was wondering why it wasn't working
13:02kavkazMaybe I have too much branching going on
13:19kavkazjustin_smith: I figured it out, it had nothing to do with boxed math, reflection or branching. In my lazy sequence of primes I was iterating +1 starting from 2
13:19kavkazWhere I should have been iterating +2 starting from 3
13:20kavkazLiterally cut my time in half
13:20justin_smithkavkaz: nice!
13:20justin_smiththough eliminating boxing or reflection will make big differences too (if there are places to eliminate it)
13:22kavkazjustin_smith: For sure. I'm still not 100% sure what reflection is, but I would prefer to keep boxed math in case I'm going to try and compute huge primes
13:23justin_smithkavkaz: if the numbers get large enough you can auto-promote, that's not incompatible with unboxed computations when you are low enough
13:23kavkazAh
13:24justin_smithreflection is when the compiler has no way to know which actual class is being provided, so it needs to emit code that figures out which math operations to actually invoke at runtime
13:24kavkazI'll look into that. I'm probably going to refactor my code, then make a blog post on the whoe experience
13:24justin_smithyou can literally make code 100x faster by eliminating reflection in a bottleneck
13:24kavkazHmmm
13:24justin_smith(in some cases :))
13:25kavkazjustin_smith: I see. I'm only working with a map and BigInteger
13:25justin_smithkavkaz: does the compiler know this?
13:25kavkazOh and I guess lazy-seq creates an object
13:25kavkazjustin_smith: No, I'm not sure how to specify these things for the clojure compiler
13:26kavkazor JVM that is
13:26kavkazor Java compiler, idk lol
13:26justin_smithkavkaz: type hints, if needed. First you need to turn on reflection warnings, then provide hints to eliminate the warnings.
13:26justin_smithclojure does not use the java compiler, it's the clojure compiler that needs to figure out if you need runtime reflection or not
13:27justin_smithkavkaz: type hints are done via metadata
13:28kavkazjustin_smith: Ah I see. I'll refactor my code and then I'll play around with that
13:28kavkazthanks for all the advice btw
13:29justin_smithnp
14:35ashwink005can I distribute my hashmap into 2 seperate vectors one containing keys and one containing values?
14:35ashwink005like { :x 2 :y 3} to [:x :y] [2 3]
14:36amalloydo you know how to get the keys of a map? or to get the values of a map?
14:37ashwink005amalloy: umm no
14:37AeroNotixashwink005: ((juxt keys vals) map)
14:37ashwink005AeroNotix: thats a typo or its actually juxt?
14:37lokien_Hello my friends! Have anyone here used Clojure for gamedev?
14:39ashwink005amalloy: how do I get just the values?
14:47ashwink005does anyone know how to get all the values in a Hashmap?
14:47ashwink005google ain't helping
14:48luma,(vals {:x 2, :y 3})
14:48clojurebot(2 3)
14:48luma,(keys {:x 2, :y 3})
14:48clojurebot(:x :y)
14:49ecelisashwink005: vals
14:49ecelis^^ luma did a better job
14:49ashwink005ecelis: thanks!
14:49ashwink005luma: thanks
14:49ashwink005wonder why google can't show shit
14:50Rurikashwink005, conj.io
14:50ecelisashwink005: may I suggest keeping this link under your pilow
14:50ecelis?
14:50ecelishttp://clojure.org/cheatsheet
14:50amalloyan interesting alternate solution: ##(apply map vector {:x 2 :y 3})
14:50lazybot⇒ ([:y :x] [3 2])
14:51ashwink005amalloy: naah don't want a list
14:51ashwink005Rurik: Whoa! nice link!
14:52ashwink005thanks all!
15:03rhg135mapv
15:17noogaI'm writing a fairly standard android app with gradle and everything, I wanted to write some logic in clojure - is it even possible to include AOTed uberjar in android app?
15:18noogaanyone tried?
15:21rhg135Should be
15:21rhg135Maven jars are usually byte code
15:25linuxlite1983hello
15:28noogamy only problem is that I know nothing about java, maven and gradle :D
15:28amalloyin fairness, neither do many people who use java, maven, and gradle
15:31noogaamalloy: +100
15:31nooga:D
15:48rhg135So true
15:57noogahah, apparently dexopt fails when I put my jar in deps and try to install the app
16:04noogayeah
16:04noogaI imagined that it won't be so easy
16:09rhg135You might need to look into multidex
16:11superfuncis there a way to evaluate an expression in a branch of a match statement ala match [(inc x)] [(inc someOtherNumber)] ?
16:12amalloyevaluating expressions is basically the only thing you *can* do in match branches
16:14amalloyalthough the example you've written is incomprehensible to me. what do you wish that did?
16:16superfuncI was playing around with the play-clj tut. Essentially, I wanted to match on key input and branch on the different possibilities. Like: match [(:key screen)] [(key-code :dpad-up)] (... do something about it)
16:16nooganope, fighting Dalvik is too much for me I think :F
16:16superfuncif I throw those up into a let expr, then its no problem
16:16superfuncI was just hoping to write them inline
16:52noogaHA take that! It somehow worked
16:54noogaand of course it was Lollipop bug
16:58ashwink005_hey if I take the :cookies keyword's value from my request, do I get a hashmap or a json?
16:58ashwink005_can't test
16:59justin_smithashwink005_: it would depend on your middleware, it could be the raw data as bytes, the data slurped into a string, or the data parsed and put into key value pairs in a hash map
17:01ashwink005_justin_smith: I'm using wrap-defaults
17:01ashwink005_that good?
17:03ashwink005_wait found it wrap-cookies middleware
17:04felipedvorakDoes anybody know of a list of best packages to work with Clojure besides cider?
17:06justin_smith ashwink005_ yeah, if wrap-cookies is being used, you should be getting a hash map. But you can also find out what is in your request by using prn (which is like println but shows data types more clearly) or by printing (type (:cookies request)) for example
17:07Mohikanerexit
17:07justin_smithashwink005_: another trick I have used is saving the request in an atom so I can use it from the repl
17:07TEttingerfelipedvorak: clojure toolbox IIRC has a good list
17:08ashwink005_justin_smith: yeah I know about destructuring, but right now I can't access any cookies. Dev mode.
17:08ashwink005_when I deploy it then maybe I'll test it out
17:08justin_smithI don't get it?
17:08justin_smithyou can use cookies locally
17:08TEttingerhttp://www.clojure-toolbox.com/
17:09felipedvorakTEttinger: thanks, what do you use?
17:10noogafelipedvorak: clj-refactor is awesome
17:10TEttingerI develop clojure with IntelliJ and Cursive
17:10TEttinger(I am not a clojure language developer, I mean I use it)
17:11justin_smithTEttinger: what is your take on IntelliJ's new licensing?
17:11TEttingerI also work on a lazybot fork but I just use jEdit to edit it (not recommended)
17:11noogafelipedvorak: I basically got emacs-live from the overtone people and it works for me when it comes to general development
17:11TEttingerjustin_smith: ?
17:11ashwink005_yeah but I'll have to set them. I only want to get cookies.
17:11TEttingerdon't know about it, justin_smith
17:11felipedvoraknooga: thanks
17:12TEttingerjustin_smith: I'm using IntelliJ IDEA Community 14.1.4
17:12felipedvoraknooga: I'm desperate to find a way to have better font-locking for clojure but it seems its a lot harder than I thought and there aren't any packages to improve on clojure-mode
17:13justin_smithTEttinger: they are moving to a pay as you go "cloud" app, similar to adobe's model for photoshop
17:13justin_smithTEttinger: community edition may not be effected by this
17:13TEttingerhuh is that for Cursive too?
17:13TEttingerI literally only develop open source stuff
17:13noogafelipedvorak: no idea, I'm quite content with emacs-live - I did some changes though
17:13justin_smithTEttinger: well, Cursive is a separate product, but one you can't do a lot with without IntelliJ
17:14justin_smithI hope this new payment / pricing model doesn't fuck with cursive :(
17:14justin_smithTEttinger: which is why I asked, I hoped you might have better info about the implications of the new pricing
17:14TEttingerI hadn't heard of it
17:15TEttingerI'd probably just stick with an older version if I had to pay
17:15justin_smithTEttinger: yeah, I dunno if old versions will stop working without subscription payments, or if it's only a new thing for future versions...
17:16felipedvoraknooga: never heard of emacs live but it looks very interesting
17:16TEttingerjustin_smith: since I'm using community, I doubt they can make it stop working remotely?
17:16justin_smithTEttinger: https://www.jetbrains.com/idea/buy/
17:17justin_smithTEttinger: that's probably true, this probably only effects the pro versions
17:17justin_smithTEttinger: https://www.jetbrains.com/buy/opensource/?product=idea
17:18justin_smitheven the open source licenses are 1 year with yearly renewal
17:18TEttingerhttps://github.com/JetBrains/intellij-community
17:19justin_smithaha, so you are probably safe using that one
17:19TEttingerjustin_smith: do you uh use IntelliJ Community?
17:19justin_smithTEttinger: I'm a big fan of cursive and I really want a fully featured tool like that to exist, but I just bang on parens with a rock like a cave man
17:20justin_smithwhich is to say I use emacs but not cider, and run repls in vanilla terminals manually reloading code with require
17:20TEttingerthere's a weird thing with "open source development only" pro version of intellij, closed-source IDE... and "open source development only" community version of intellij, open source IDE
17:20justin_smith~justin_smith bangs on parens with a rock, like a cave man.
17:20clojurebotExcuse me?
17:20justin_smith:P
17:20justin_smithTEttinger: that is weird
17:30noogajustin_smith: why not cider?
17:31justin_smithnooga: I break it too easily
17:31justin_smithI'm probably not smart enough to use cider effectively, I just end up wasting my time with deleting byte code and debugging my tooling and wondering why my editor is freezing up.
17:32noogafor me, usually M-x cider-interrupt / M-x cider-restart does the job
17:32noogaif something goes wrong that is
17:32justin_smithhave you ever upgraded versions?
17:33noogaI'm running 0.9.0 updated from 0.8.1 I think
17:33noogaor something
17:34justin_smithclearly you have some talent I do not
17:35noogaI mean it was confusing and stupidly hard but I managed :D
17:36nooga+ in 0.9.0, there's this debugger thing
17:36noogawhich is quite awesome
17:36justin_smithI heard about that
17:58justin_smithTEttinger2: so how hard do you think it would be to make an algorithm that simulated ancient handwriting? http://www.english.cam.ac.uk/ceres/ehoc/manuscripts/kkca346-7v/
17:58justin_smithfor all I know this is already a thing
18:06noncom|2justin_smith: how did they ever read this...
18:07noncom|2looks like a write-only thing
18:08oddcullythe perl of the past
18:12noogayeah, I basically forgot how to write by hand
18:12noogaI use pen for signatures only these days
18:15noncom|2i like both writing and drawing with pen, but true, not much chance a day i get to do this
18:16noogaoh, drawing is cool, I used to doodle a lot and now I draw diagrams everywhere
18:17noogabut my handwriting is write-only
18:21justin_smithI've actually taken to using a fountain pen and writing ideas on paper - it's a nice break from keyboards and screens
18:21justin_smithit encourages a different kind of thinking
18:22justin_smithbut I'm fascinated by that ancient handwriting - before super regular cursives like copperplate and such were invented (the kind of writing on the declaration of independence and the constitution)
18:22justin_smithbut yeah, it's so illegible I was imagining a program that could just invent it
18:23justin_smithrandom combinations of simulated ink strokes that look like they are probably words
18:23tmtwdoh so clojure has partial functions allowed in core?
18:23noogalooks like a task for a *deep learning* network
18:23tmtwdit doesn't require a special keyword?
18:24justin_smithtmtwd: well, we have the function "partial" if that's what you mean
18:24tmtwdjustin_smith, but its not necessary to use partial?
18:24noncom|2yes, i too sometimes take the initiative to do some handwriting. and also some fine handwork, even if it seems pointless. my main motivation is that fine motorics (as it is called in my language at least), things when you have to put much thought into controlling fine finger moves, stimulates the frontal cortex in a very good way
18:24tmtwdfor example, we could use macros
18:24noncom|2*neocortex
18:25noncom|2sry
18:25justin_smithnoncom|2: exactly - hand writing is good for memory too
18:25justin_smithtmtwd: OK, but we don't have currying - don't get those confused
18:25noogaI play guitar
18:25noncom|2yep, instruments too
18:26noncom|2i play mainly keys. i also want to get an ukulele
18:26noogain fact, I've arranged a small music room in my office :D
18:26noogasince most of us there play some instrument
18:26noncom|2haha :) that's so cool, really
18:27noncom|2justin_smith: i think that a neural net could be well put to work with handwriting
18:27justin_smithnoncom|2: oh yeah, that's probably true (as nooga mentioned also)
18:27noncom|2yep
18:28tmtwdcan we have recursive macros?
18:28noncom|2tmtwd: use macros? how
18:28noncom|2tmtwd: sure
18:28noogatmtwd: what would you like to get?
18:29tmtwdnoncom|2, http://pastebin.com/Bv7ucjeh
18:29noncom|2tmtwd: umm, i don't know what you're trying to acheive..
18:29noncom|2ah, currying..
18:30noncom|2i guess..
18:30TEttingertmtwd: currying is... tricky with variadic argument lists
18:30TEttinger,(+)
18:30clojureboteval service is offline
18:30TEttinger&(+)
18:30lazybot⇒ 0
18:30TEttinger&(+ 1)
18:30lazybot⇒ 1
18:31noncom|2wow! what's up with cljbot
18:31TEttinger&(-)
18:31lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: core/-
18:31TEttinger&(- 1)
18:31lazybot⇒ -1
18:31TEttinger&(- 1 1)
18:31lazybot⇒ 0
18:31TEttingerthat's an oddity of unary -
18:31noncom|2yep
18:33noncom|2no, seriously, currying is good, but not something i'd be too zealous about...
18:33noncom|2esp that there's (partial)
18:34TEttingerShen has an interesting approach to it. it doesn't allow (+) or (+ 1) to return, but does make them curried. they're roughly equivalent to (partial +) and (partial + 1)
18:34noogabtw. is there something to flip args positions in the core?
18:34justin_smithrecursive macros:
18:34justin_smith,(defmacro tweedle-dee [args] (if (> (count args) 3) (cons 'list args) (list 'tweedle-dumb (cons :dee args))))
18:34clojureboteval service is offline
18:34justin_smith:P
18:35justin_smith,(defmacro tweedle-dumb [args] (list 'tweedle-dee (cons :dumb args)))
18:35clojureboteval service is offline
18:35justin_smithanyway, those macros are recursive, if you call (tweedle-dee nil) you get (:dumb :dee :dumb :dee) as the output
18:35noncom|2whats up with clojurebot?
18:36justin_smithnoncom|2: I don't know if he likes doing macros
18:36justin_smith,(+ 1 1)
18:36clojureboteval service is offline
18:36justin_smithoh, something worse
18:36noncom|2,run-self-diagnostics
18:36clojureboteval service is offline
18:36noncom|2dammit
18:37nooga,(defn clojurebot [_] "eval service is offline")
18:37clojurebot#'sandbox/clojurebot
18:37noogaWOW
18:37justin_smithanyway, those macros are totally useless, but it was fun inventing recursive macros
18:37justin_smith,(defmacro tweedle-dee [args] (if (> (count args) 3) (cons 'list args) (list 'tweedle-dumb (cons :dee args))))
18:37clojurebot#'sandbox/tweedle-dee
18:37noogaI fixed it!!!!
18:37justin_smith,(defmacro tweedle-dumb [args] (list 'tweedle-dee (cons :dumb args)))
18:37clojurebot#'sandbox/tweedle-dumb
18:37justin_smith,(tweedle-dee nil)
18:37clojurebot(:dumb :dee :dumb :dee)
18:37TEttingernooga: what's the situation that calls for flipping arg positions? how does it work with more than 2 args?
18:37noncom|2nooga: haha :D
18:38justin_smithnooga: periodically clojure bot resets
18:38TEttinger,(defn rev-args [f & args] (apply f (reverse args))
18:38clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:38noogaTEttinger: sometimes there's a fn of 2 args, on which I'd like to use partial but they're in wrong order
18:39TEttinger,(defn rev-args [f & args] (apply f (reverse args)))
18:39clojurebot#'sandbox/rev-args
18:39noogaTEttinger: and I wouldn't expect it to work on more than 2 args
18:39TEttinger,(rev-args - 1 2 3)
18:39clojurebot0
18:39noogayeah
18:39TEttingeryou could define your own partial...
18:39noogathat's what I do sometimes, I was just wondering if there was something in clojure.core for that already
18:40justin_smithflatland/useful has a few of these kinds of things that people coming from haskell wish clojure had
18:41noogajustin_smith: nice one, thanks
18:45TEttinger,(defmacro flipper [f & a] `(fn [& args#] (apply ~f (concat args# ~a))))
18:45clojurebot#'sandbox/flipper
18:46TEttinger,(map (flipper - 3) [10 20 30])
18:46clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
18:46TEttingersigh
18:46justin_smith,(def flipper' (constantly 'EEEeeeEEEeeEEE....SPLASH))
18:46clojurebot#'sandbox/flipper'
18:46justin_smith,(map flipper' [10 20 30])
18:46clojurebot(EEEeeeEEEeeEEE....SPLASH EEEeeeEEEeeEEE....SPLASH EEEeeeEEEeeEEE....SPLASH)
18:48gargsmsI have a list of hash-maps ( { :name "Anonymous" :job "Jobless" } { :name "John" :job "Doe" } ... [many more such name job hash-maps] ) and I need to convert it to this
18:48gargsms{ "Anonymous" { :name "Anonymous" :job "Jobless" } "John" { :name "John" :job "Doe" } ... }
18:48gargsmsI tried doseq with no success
18:49justin_smithgargsms: ##(group-by :name [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}])
18:49lazybot⇒ {"al" [{:name "al", :job "mcdonalds"}], "joe" [{:name "joe", :job "president"}]}
18:49justin_smiththat's not identical (it uses vectors in case two people have the same name) but it's close to being your logic
18:50justin_smithgargsms: doseq is not for creating values, it can only ever return nil
18:51gargsmsjustin_smith, it does help but it returns the map with vectors
18:51justin_smith,(into {} (map (juxt :name identity) [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}]
18:51justin_smithoops
18:51clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:51justin_smith,(into {} (map (juxt :name identity) [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}])
18:51clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:51justin_smith,(into {} (map (juxt :name identity) [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}]))
18:51clojurebot{"al" {:name "al", :job "mcdonalds"}, "joe" {:name "joe", :job "president"}}
18:51justin_smithfinally
18:51gargsmsHaha
18:51justin_smithsorry for that flailing-about
18:52gargsmsjuxt is for?
18:52justin_smithjust returns a vector of the result of each function
18:52justin_smith,((juxt inc identity dec) 0)
18:52clojurebot[1 0 -1]
18:53justin_smith,((juxt remove filter) even? (range 5))
18:53clojurebot[(1 3) (0 2 4)]
18:54noncom|2btw just found out here they allow to excersise in clojure https://www.codingame.com/games
18:55gargsmsjustin_smith, just a quick question. The returned map from what you gave me has a comma separated pairs. Are { "a" {:name "b"} "c" {:name "d"} } and { "a" {:name "b"}, "c" {:name "d"} } equivalent?
18:55justin_smithgargsms: yes, commas are whitespace
18:56justin_smith,(= [1 2 3], [1, 2, 3], [,,,,,1,,,,,,2,,,,,,3,,,,,,],,,,,,,)
18:56clojurebottrue
18:56noncom|2,,,,,,,,,,,,,,,,,,,
18:56clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:56gargsmsAh. Thanks a lot. I will need to understand the function you gave me first. I am starting with clojure.
18:56justin_smithfor obviously we avoid doing excessive silliness with commas, but they are not meaningful in clojure :)
18:57AeroNotix,[1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1]
18:57justin_smith*for obvious reasons
18:57clojurebot[1 1]
18:57justin_smithI sometimes abuse commas to make the beginning of a line in my editor line up a specific way
18:57noogaNaNNaNNaNNaNNa...
18:57noncom|2,"it's coma party"
18:57clojurebot"it's coma party"
18:58noncom|2,NaN
18:58clojurebot#error {\n :cause "Unable to resolve symbol: NaN in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: NaN in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: NaN in this conte...
18:58justin_smithnoncom|2: you probably want Double/NaN
18:58noncom|2,Double/Nan
18:58clojurebot#error {\n :cause "Unable to find static field: Nan in class java.lang.Double"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: Nan in class java.lang.Double, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to find st...
18:58noncom|2,Double/NaN
18:58clojurebotNaN
18:58justin_smith,(/ 0 0)
18:58clojurebot#error {\n :cause "Divide by zero"\n :via\n [{:type java.lang.ArithmeticException\n :message "Divide by zero"\n :at [clojure.lang.Numbers divide "Numbers.java" 158]}]\n :trace\n [[clojure.lang.Numbers divide "Numbers.java" 158]\n [clojure.lang.Numbers divide "Numbers.java" 3808]\n [sandbox$eval299 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval299 invoke "NO_SOURCE_FILE" -1]\n [clojure.la...
18:58justin_smitherr
18:59noncom|2,(- Double/NaN Double/Nan)
18:59justin_smith,(/ 0 0.0)
18:59clojurebot#error {\n :cause "Unable to find static field: Nan in class java.lang.Double"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to find static field: Nan in class java.lang.Double, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to find st...
18:59clojurebotNaN
18:59noncom|2,(- Double/NaN Double/NaN)
18:59clojurebotNaN
18:59justin_smith,(hash-map (/ 0 0.0) :a (/ 0 0.0) :b)
18:59clojurebot{NaN :a, NaN :b}
19:00noncom|2wooooow
19:00noncom|2heeey wait..
19:00noncom|2how so
19:00justin_smith,(contains? (hash-map (/ 0 0.0) :a (/ 0 0.0) :b) (/ 0 0.0))
19:00clojurebotfalse
19:00justin_smiththat's why
19:00noncom|2boxed?
19:00justin_smiththe hash map doesn't think a key is duplicate if it isn't equal
19:00justin_smith,(= (/ 0 0.0) (/ 0 0.0))
19:00clojurebotfalse
19:00noncom|2ah..
19:00noncom|2no equality for NaN
19:01justin_smithright
19:01justin_smithwell - almost!
19:01justin_smith,(let [nana (/ 0 0.0)] (= nana nana))
19:01clojurebotfalse
19:01noncom|2hmm
19:01justin_smitherr... there's a trick here to make it return true...
19:01justin_smithforgetting the trick
19:01noncom|2yeah, but i got the idea
19:01justin_smith,(let [nana (/ 0 0.0)] (hash-map nana :a nana :b))
19:01clojurebot{NaN :a, NaN :b}
19:02justin_smithBronsa figured out how to make two NaNs equal in some context - it was weird
19:02noncom|2hm
19:02noncom|2oh yeah, he could do this, he know everything about evaluation
19:06justin_smithwelcome
19:07gargsmscoming from JavaScript background, I can relate to (= NaN NaN) being false
19:07justin_smithgargsms: that's actually specified by IEEE floating point
19:07gargsmsWhat exactly is NaN then?
19:08justin_smithit's a value that isn't a number - it's an undefined arithmetical result that is not equal to any number, nor itself
19:08justin_smithit's the specified result for operations that are nonsense
19:08justin_smithlike (/ 0.0 0.0)
19:08gargsmsWell, in JS you can have !NaN === !NaN
19:08justin_smith,(not Double/NaN)
19:08clojurebotfalse
19:09justin_smith,(= (not Double/NaN) (not Double/NaN))
19:09clojurebottrue
19:09gargsmsYes
19:09justin_smithbut not always returns a boolean, never a numeric
19:10justin_smithoh which is true in js too
19:10gargsmsHow else can you make (= NaN NaN) true without coercion then?
19:10noncom|2,(= (read-string "NaN") (read-string "NaN"))
19:10clojurebottrue
19:10justin_smithnoncom|2: those were symbols
19:10gargsmsHa!
19:11justin_smith,(type (read-string "NaN"))
19:11clojurebotclojure.lang.Symbol
19:11danielle_romes,(= "NaN" "NaN")
19:11clojurebottrue
19:11justin_smithgargsms: it's a trick where in a specific context you can make clojure use a boxed number and compare by hash value and not true equality
19:11justin_smithgargsms: it's somewhat tricky to set up and I forget how
19:12gargsmssome other time
19:12justin_smithI'm sure next time Bronsa is around he will remember how it worked
19:21TEttingerwoo finally I can copy things without sometimes crashing my IRC client!
19:22TEttingersorry about the join/crash spam
19:28wasamasayou could grab a znc and put it somewhere with a good connection
19:29TEttingerit wasn't a connection issue, it was a UI doesn't like whatever locked the clipboard issue...
19:29TEttinger,(defmacro flipper [f# & a#] `(fn [& args#] (apply ~f# (concat args# [~@a#]))))
19:29clojurebot#'sandbox/flipper
19:30TEttinger,(map (flipper - 3) [10 20 30])
19:30clojurebot(7 17 27)
19:31ashwink005_can I convert a url query string to a Hashmap in clojure?
19:31justin_smithashwink005_: yeah, ring's wrap-query-params middleware will do that for you
19:32ashwink005_justin_smith: and I can refer to it using what keyword?
19:32ashwink005_not :params I guess
19:32justin_smithashwink005_: :query-params
19:33justin_smithashwink005_: wrap-params merges query-params with body params etc. into one :params map
19:33ashwink005_hmm.. is this the correct syntax?
19:33ashwink005_wait
19:34ashwink005_ (def app (-> (wrap-defaults app-routes site-defaults) (wrap-cookies) ))
19:34ashwink005_app-routes is my handler
19:42gargsmsashwink005_, avoid wrap-defaults or you may end up having ANTI-FORGERY token issues
19:42ashwink005_gargsms: jaa yahan se
19:45rhg135You can disable just that. See the site
19:51gargsmsjustin_smith, I am securing some of my routes with friend and I want some routes open. Can I have different route groups?
19:52gargsmsI tried it and only one of them seems to work, whichever I pass first
19:53justin_smithgargsms: I'm not good with compojure (I don't use it myself beacuse it is hard to do higher order stuff with it in my experience) but there is definitely a way to combine two groups of routes in compojure.
19:53ashwink005_justin_smith: doing wrap params only. Still the request params are coming inside the query-string keyword
19:53justin_smithI assume that is what you are using for routing.
19:53gargsmsjustin_smith, Yes, in fact I am.
19:54justin_smithashwink005_: wrap-params will take request params and query params etc. and merge them into one :params, but iirc you still need the other middlewares to parse those
19:54justin_smithwrap-params itself doesn't do all that parsing I don't think
19:56ashwink005_justin_smith: I'm actually printing the request received. It still shows me a query string inside :query-string keyword.
19:56ashwink005_justin_smith: do confirm the syntax
19:56ashwink005_(-> (wrap-params app-routes)(wrap-cookies))
19:58justin_smith,(macro-expand '(-> (wrap-params app-routes)(wrap-cookies)))
19:58clojurebot#error {\n :cause "Unable to resolve symbol: macro-expand in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: macro-expand in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol:...
19:58justin_smith,(macroexpand '(-> (wrap-params app-routes)(wrap-cookies)))
19:58clojurebot(wrap-cookies (wrap-params app-routes))
19:58justin_smithyeah, looks right
19:59justin_smithremember that -> is just a convenience, the more middleware you have the more helpful it gets
19:59justin_smithbut it's just a convenient way to do function wrapping
20:01ashwink005_could u suggest some middleware that could cause this problem?
20:01ashwink005_params empty and query-string full
20:01justin_smithashwink005_: like I said it's because you are not using wrap-query-params
20:03justin_smithor at least that's what I meant to say
20:03ashwink005_justin_smith: okie I'll give it a shot
20:05ashwink005_justin_smith: whats the dependency?
20:06justin_smithoh, I was wrong
20:06justin_smithjust use wrap-params
20:06justin_smith:params will be all param types merged
20:06justin_smith:query-params will be just the query params
20:07ashwink005_yeah I am using the wrap-params
20:07ashwink005_still no luck. The params map is empty
20:07justin_smithand you are providing query parameters?
20:07justin_smithbecause in my experience that middleware works
20:08ashwink005_justin_smith: yes
20:08ashwink005_the parameters are coming inside the query-string keyword likeI said
20:09justin_smithOK, :params is supposed to be the merge of query params with form-params
20:09justin_smith:query-string isn't the param map, it's the raw string
20:09ashwink005_yup thats how it looks
20:10justin_smithhave you restarted your server since putting wrap-params in there?
20:10ashwink005_I just want my parameters added in my js file to come inside the params map
20:10ashwink005_justin_smith: yup did that
20:12domokatowhat's the best way to model a one-to-one relationship between two kinds of data? For example, A "has a" B and B "has an" A (the same A). I could use a pair of maps, A->B and B->A, but maintaining them is repetitive and potentially error prone
20:12domokatois there something built-in that is more appropriate?
20:13justin_smithdomokato: I think there's a bi-map out there somewhere, but beware duplicate keys of course
20:17tmtwdwhat is the difference between these 2 macros? they seem to do the same thing http://pastebin.com/8PUKsgKq
20:20justin_smithtmtwd: in the second one, weird things can happen with x
20:20justin_smithvia capture
20:23TEttingerdomokato: there's the set of sets approach
20:24TEttinger,#{ #{:A :B} #{:A :C :D} }
20:24clojurebot#{#{:A :D :C} #{:A :B}}
20:25cflemingjustin_smith: TEttinger: Yeah, the new pricing is, um, interesting. I hope it won't affect what I have to do with Cursive.
20:25cflemingThey have confirmed that the OSS versions will not be affected, and Cursive will always work with them.
20:26TEttingerI wonder if Android Studio will be affected
20:26cflemingCurrently they're not planning to change their release model, i.e. moving to a rolling update model or anything like that, which would have been much more complicated for me.
20:26cflemingNo, that's free and based on the community edition AFAIK
20:27TEttingerwhat does the pro version of IDEA even... offer above Community?
20:28domokatoTEttinger: it's not many-to-many, it's one-to-one
20:28domokatothanks tho
20:36ashwink005_has anyone used ring.util.codec ?
20:36ashwink005_(ring.util.codec/form-decode "baz=3&bar=2&foo=1") gives {"foo" "1", "bar" "2", "baz" "3"}
20:36ashwink005_how can I retain the keywords?
20:38ashwink005_hellooo?
20:40rhg135Retain implies they were once
20:44amalloyashwink005_: once you start paying for IRC tech support you can offer indignant "hellooo?" when nobody answers at a time that's convenient for you. but while people here are helping you just because they want to help, it is rather tacky
20:44ashwink005_amalloy: ok sorry didn't know that
20:45ashwink005_amalloy: new to IRC, will keep in mind
20:45amalloyanyway, once you have that map you can convert to keywords if you want, the same way you would for any map; the fact that it came from form-decode is no longer relevant
20:46justin_smiththough some keys that would be legal in a form context might not be good keywords, which is one reason for not converting them
20:52amalloyyes, better to either look them up as strings or to convert a fixed set of form parameters that you actuall expect, rather than converting any old junk into a keyword
20:52ashwink005_yeah I'm using the keywordize-keys function from the walk library
20:53ashwink005_does the job
20:53cflemingTEttinger: It offers lots of Java enterprise stuff you probably don't care about, and a lot of very useful web tech stuff that you might care about.
21:24beginnerHello! I am a beginner to clojure. I need an asynchronous library to do some web scraping and mining but there's so many that I am unable to decide. I have some experience with asyn stuff from programming in Go. Which library is the best to get started with? Aleph manifold core.async etc.?
22:40taliosanyone here using the https://github.com/leonardoborges/bouncer library? ( or have suggestions for a better validations library ) - want to return multiple validation results from a single validation, which I don't think I can with bouncer