#clojure log - Sep 06 2015

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:09 justin_smith: TEttinger: fascinating

0:10 TEttinger: always interesting to see another attempt at manual memory management in a lisp, I'll have to check out how this one approaches it

6:39 skeuomorf: lazy question, is there a way when in smartparens-strict-mode to delete a single paren but not the pair?

6:39 ska-fan: Is (zipmap (map :build-id builds) builds) idiomatic?

6:42 ashwink005: is there a limit to the size of mysql database columns that one can make?

6:46 Rurik: ashwink005, #mysql would know better

6:47 oddcully: ska-fan: looks fine to me - if your build-id is always set and unique. otherwise maybe group-by is an option

6:49 ska-fan: oddcully: Thanks. I just thought a terser way might be possible - build is mentioned twice.

6:49 ashwink005: Rurik: resolved it. Turns out you can't have a column named :desc in mysql

6:50 Rurik: I guess that is because DESC is a keyword in SQL?

6:50 wasamasa: wat

7:00 tim_: (def app-state (atom {:expanded-rows #{124}})

7:01 how do I add to expanded-rows with swap ?

7:02 oddcully: ,(let [a (atom {:x #{1}})] (swap! a update-in [:x] conj 2))

7:03 clojurebot: {:x #{1 2}}

7:09 Rurik: user=> inc

7:09 #<core$inc clojure.core$inc@7fab2b22>

7:10 What does this mean

7:11 wasamasa: that's how a function is represented in clojure

7:12 tim_: oddcully: thank you

7:12 Rurik: yeah, but what does this strange sentence mean

7:12 I'm assuming @7fab2b22 is the memory address

7:12 tim_: I think its just a string representation of the function's location in memory

7:14 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

7:14 muhuk: Rurik: use (doc inc) if you want user readable info on a function.

7:15 Rurik: no, I want to know what this information means

7:17 wasamasa: generated java names for the method I guess

7:27 oddcully: ,(pr inc)

7:27 clojurebot: #object[clojure.core$inc 0x4c3a535c "clojure.core$inc@4c3a535c"]

8:49 ashwink005: how do I set default values in a JDBC connected mysql database?

8:53 helloo?

8:55 vak: hi all

8:57 There 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!]])

8:58 could i somehow get the stuff for this namespace via lein? or I'd rather have to find similar functions somewhere else?

9:10 triss: so any of you doing any sort of literate programming? Is Marginalia your tool of choice?

9:20 vak: I did a lot of literate programming, but in R/Sweave

9:31 triss: vak: 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?

9:32 vak: triss: literate programming is very cool in (science) research.

9:33 triss: in pure/generic IT it is not that requested IMHO

9:34 muhuk: vak: precisely. Because you often have overriding priorities.

9:34 triss: Agreed.

9:35 I'm going back in to academia tho....

9:35 and I really like what he process of getting nice documentation ready for code does to my code.

9:37 This 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."

9:37 stil believe code should be as self documenting as possible though

9:40 vak: triss: 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"

9:41 triss: the life is funny thing)

9:48 crocket: Can I insert a clojure plugin into lazybot?

10:00 sobel: code 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:00 some words about the actual domain and intention of code can save so much time for a reader

10:00 clojurebot: Titim gan éirí ort.

10:01 sobel: reader

10:01 (what triggered that?)

10:04 muhuk: How do you implement queries in Onyx?

10:05 How would you aggreage from multiple tasks?

10:05 crocket: Ala

10:06 muhuk: (or is it just intended for commands - in a CQRS sense)

10:40 Rurik: Why do fn and let take a vector of args/bindings

10:43 justin_smith: Rurik: the thought was to make parens less overloaded

10:44 they do a lot of different things in most lisps, but Hickey wanted to use other delimeters to make it easier to differentiate things

10:44 Rurik: ah, nice

10:45 I always kinda got confused by the system scheme used

10:58 kwladyka: justin_smith, do you know place where they looking Clojure Junior?

10:58 justin_smith: no, I don't

10:58 kwladyka: you was my last hope ;)

10:59 I really try, but it is much harder then i thought to be a Clojurian :)

11:00 even 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:01 All love Scala, but Clojure is evil. What is the point?

11:01 Rurik: I don't think that is true...

11:03 kwladyka: me 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:04 scottj: kwladyka: 99% of programmers don't know enough about clojure to have a worthwhile opinion about it.

11:06 kwladyka: scottj, but it shapes the labor market (i am not sure it is correct in english :) )

11:07 i 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:12 engblom: kwladyka: To me it looks like neither Clojure nor Scala gets much love in the job market.

11:13 Rurik: Isn't loop recur exactly like a while loop?

11:16 muhuk: Rurik: a while loop is a loop-recur.

11:17 Rurik: muhuk, so loop-recur goes beyond what a while loop can do?

11:18 muhuk: Rurik: why, yes.

11:19 justin_smith: Rurik: the difference is that loop can create new bindings each time

11:19 which is very helpful when your data is immutable

11:20 Rurik: gotcha

11:22 tomjack: when you say "while loop" do you mean a (while ...) in clojure or maybe a while loop in some imperative language?

11:36 ashwink005: how can I check what request have I fired to mysql server?

11:36 can I log that in repl

11:36 Rurik: tomjack, imperative

11:37 ashwink005, I guess you can use do to print a message in the repl the moment you execute the fn

11:38 ashwink005: Rurik: I have done that. When I execute the command in mysql command line I get a result

11:38 Rurik: but repl gives the result as nil

11:38 for the same command.

11:38 the difference being, in repl I use WHERE X=? then pass parameters

11:39 while in mysql I do WHERE X=5

11:43 anyone...?

11:51 justin_smith: ashwink005: can you share a paste of your repl interaction?

11:51 ashwink005: I think this could have to do with how you are using the return value

11:52 ashwink005: hello-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:52 SELECT... is the print

11:53 nil is the output

11:53 justin_smith: and where are you privoding any numeric parameters there?

11:54 can you use refheap.com to show us the code of getFilteredOffers?

11:55 ashwink005: justin_smith: after this statement I add all 5 parameters

11:55 in the vector

11:56 the same query in mysql command prompt with parameters attached inline gives a row output

11:56 justin_smith: what vector? I can't tell you what's wrong without seeing the actual code you use with jdbc

11:58 ashwink005: justin_smith: http://txt.do/ac9el

11:59 justin_smith: ashwink005: the key to with-query-results is you have to do something with res

11:59 ashwink005: justin_smith: create multi query just makes a bunch of INSTR(column,value) statements and appends with an OR

12:00 justin_smith: oooohh myyyy effin gaawd

12:00 justin_smith: ashwink005: you provide no body to with-query results, so the block returns the same thing (do) does - nothing because no code

12:00 ashwink005: this is why I asked to see your code :)

12:00 ashwink005: justin_smith: I'm so sorry.. thats a rookie mistake!

12:00 justin_smith: thanks man :) alot! and sorry

12:00 justin_smith: ashwink005: every question on this channel is somebodies rookies mistake, it's all good :)

12:01 ashwink005: justin_smith: hee hee thanks :)

12:35 kavkaz: Is ({:somekey :someotherkey} :somekey) faster than (first '(:somekey :somekey2))?

12:38 justin_smith: kavkaz: they are not even doing comparable things, but no, it should be a little slower

12:39 you've got two different kinds of data structures there of course

12:43 kavkaz: justin_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:43 I think my logic is all there though

12:43 justin_smith: kavkaz: do you need associative lookup?

12:43 do you need ordered storage?

12:44 kavkaz: justin_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:45 justin_smith: OK, because '(:somekey :somekey2) is not associative - it might be efficient as eg. a stack, but not for looking anything up

12:48 kavkaz: with numeric stuff, I would be sure to turn on warn-on-reflection and warn-on-boxing

12:53 kavkaz: justin_smith: Oh thanks! I'll have to look up what those things are but perhaps it'll help me (:

12:58 justin_smith: kavkaz: :global-vars {*warn-on-reflection* true *unchecked-math* :warn-on-boxed}

12:58 (those are the options for project.clj)

12:59 kavkaz: Thanks, I was just putting :warn-on-boxed in project.clj and was wondering why it wasn't working

13:02 Maybe I have too much branching going on

13:19 justin_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:19 Where I should have been iterating +2 starting from 3

13:20 Literally cut my time in half

13:20 justin_smith: kavkaz: nice!

13:20 though eliminating boxing or reflection will make big differences too (if there are places to eliminate it)

13:22 kavkaz: justin_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:23 justin_smith: kavkaz: if the numbers get large enough you can auto-promote, that's not incompatible with unboxed computations when you are low enough

13:23 kavkaz: Ah

13:24 justin_smith: reflection 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:24 kavkaz: I'll look into that. I'm probably going to refactor my code, then make a blog post on the whoe experience

13:24 justin_smith: you can literally make code 100x faster by eliminating reflection in a bottleneck

13:24 kavkaz: Hmmm

13:24 justin_smith: (in some cases :))

13:25 kavkaz: justin_smith: I see. I'm only working with a map and BigInteger

13:25 justin_smith: kavkaz: does the compiler know this?

13:25 kavkaz: Oh and I guess lazy-seq creates an object

13:25 justin_smith: No, I'm not sure how to specify these things for the clojure compiler

13:26 or JVM that is

13:26 or Java compiler, idk lol

13:26 justin_smith: kavkaz: type hints, if needed. First you need to turn on reflection warnings, then provide hints to eliminate the warnings.

13:26 clojure does not use the java compiler, it's the clojure compiler that needs to figure out if you need runtime reflection or not

13:27 kavkaz: type hints are done via metadata

13:28 kavkaz: justin_smith: Ah I see. I'll refactor my code and then I'll play around with that

13:28 thanks for all the advice btw

13:29 justin_smith: np

14:35 ashwink005: can I distribute my hashmap into 2 seperate vectors one containing keys and one containing values?

14:35 like { :x 2 :y 3} to [:x :y] [2 3]

14:36 amalloy: do you know how to get the keys of a map? or to get the values of a map?

14:37 ashwink005: amalloy: umm no

14:37 AeroNotix: ashwink005: ((juxt keys vals) map)

14:37 ashwink005: AeroNotix: thats a typo or its actually juxt?

14:37 lokien_: Hello my friends! Have anyone here used Clojure for gamedev?

14:39 ashwink005: amalloy: how do I get just the values?

14:47 does anyone know how to get all the values in a Hashmap?

14:47 google ain't helping

14:48 luma: ,(vals {:x 2, :y 3})

14:48 clojurebot: (2 3)

14:48 luma: ,(keys {:x 2, :y 3})

14:48 clojurebot: (:x :y)

14:49 ecelis: ashwink005: vals

14:49 ^^ luma did a better job

14:49 ashwink005: ecelis: thanks!

14:49 luma: thanks

14:49 wonder why google can't show shit

14:50 Rurik: ashwink005, conj.io

14:50 ecelis: ashwink005: may I suggest keeping this link under your pilow

14:50 ?

14:50 http://clojure.org/cheatsheet

14:50 amalloy: an interesting alternate solution: ##(apply map vector {:x 2 :y 3})

14:50 lazybot: ⇒ ([:y :x] [3 2])

14:51 ashwink005: amalloy: naah don't want a list

14:51 Rurik: Whoa! nice link!

14:52 thanks all!

15:03 rhg135: mapv

15:17 nooga: I'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:18 anyone tried?

15:21 rhg135: Should be

15:21 Maven jars are usually byte code

15:25 linuxlite1983: hello

15:28 nooga: my only problem is that I know nothing about java, maven and gradle :D

15:28 amalloy: in fairness, neither do many people who use java, maven, and gradle

15:31 nooga: amalloy: +100

15:31 :D

15:48 rhg135: So true

15:57 nooga: hah, apparently dexopt fails when I put my jar in deps and try to install the app

16:04 yeah

16:04 I imagined that it won't be so easy

16:09 rhg135: You might need to look into multidex

16:11 superfunc: is there a way to evaluate an expression in a branch of a match statement ala match [(inc x)] [(inc someOtherNumber)] ?

16:12 amalloy: evaluating expressions is basically the only thing you *can* do in match branches

16:14 although the example you've written is incomprehensible to me. what do you wish that did?

16:16 superfunc: I 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:16 nooga: nope, fighting Dalvik is too much for me I think :F

16:16 superfunc: if I throw those up into a let expr, then its no problem

16:16 I was just hoping to write them inline

16:52 nooga: HA take that! It somehow worked

16:54 and of course it was Lollipop bug

16:58 ashwink005_: hey if I take the :cookies keyword's value from my request, do I get a hashmap or a json?

16:58 can't test

16:59 justin_smith: ashwink005_: 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:01 ashwink005_: justin_smith: I'm using wrap-defaults

17:01 that good?

17:03 wait found it wrap-cookies middleware

17:04 felipedvorak: Does anybody know of a list of best packages to work with Clojure besides cider?

17:06 justin_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:07 Mohikaner: exit

17:07 justin_smith: ashwink005_: another trick I have used is saving the request in an atom so I can use it from the repl

17:07 TEttinger: felipedvorak: clojure toolbox IIRC has a good list

17:08 ashwink005_: justin_smith: yeah I know about destructuring, but right now I can't access any cookies. Dev mode.

17:08 when I deploy it then maybe I'll test it out

17:08 justin_smith: I don't get it?

17:08 you can use cookies locally

17:08 TEttinger: http://www.clojure-toolbox.com/

17:09 felipedvorak: TEttinger: thanks, what do you use?

17:10 nooga: felipedvorak: clj-refactor is awesome

17:10 TEttinger: I develop clojure with IntelliJ and Cursive

17:10 (I am not a clojure language developer, I mean I use it)

17:11 justin_smith: TEttinger: what is your take on IntelliJ's new licensing?

17:11 TEttinger: I also work on a lazybot fork but I just use jEdit to edit it (not recommended)

17:11 nooga: felipedvorak: I basically got emacs-live from the overtone people and it works for me when it comes to general development

17:11 TEttinger: justin_smith: ?

17:11 ashwink005_: yeah but I'll have to set them. I only want to get cookies.

17:11 TEttinger: don't know about it, justin_smith

17:11 felipedvorak: nooga: thanks

17:12 TEttinger: justin_smith: I'm using IntelliJ IDEA Community 14.1.4

17:12 felipedvorak: nooga: 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:13 justin_smith: TEttinger: they are moving to a pay as you go "cloud" app, similar to adobe's model for photoshop

17:13 TEttinger: community edition may not be effected by this

17:13 TEttinger: huh is that for Cursive too?

17:13 I literally only develop open source stuff

17:13 nooga: felipedvorak: no idea, I'm quite content with emacs-live - I did some changes though

17:13 justin_smith: TEttinger: well, Cursive is a separate product, but one you can't do a lot with without IntelliJ

17:14 I hope this new payment / pricing model doesn't fuck with cursive :(

17:14 TEttinger: which is why I asked, I hoped you might have better info about the implications of the new pricing

17:14 TEttinger: I hadn't heard of it

17:15 I'd probably just stick with an older version if I had to pay

17:15 justin_smith: TEttinger: yeah, I dunno if old versions will stop working without subscription payments, or if it's only a new thing for future versions...

17:16 felipedvorak: nooga: never heard of emacs live but it looks very interesting

17:16 TEttinger: justin_smith: since I'm using community, I doubt they can make it stop working remotely?

17:16 justin_smith: TEttinger: https://www.jetbrains.com/idea/buy/

17:17 TEttinger: that's probably true, this probably only effects the pro versions

17:17 TEttinger: https://www.jetbrains.com/buy/opensource/?product=idea

17:18 even the open source licenses are 1 year with yearly renewal

17:18 TEttinger: https://github.com/JetBrains/intellij-community

17:19 justin_smith: aha, so you are probably safe using that one

17:19 TEttinger: justin_smith: do you uh use IntelliJ Community?

17:19 justin_smith: TEttinger: 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:20 which is to say I use emacs but not cider, and run repls in vanilla terminals manually reloading code with require

17:20 TEttinger: there'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:20 justin_smith: ~justin_smith bangs on parens with a rock, like a cave man.

17:20 clojurebot: Excuse me?

17:20 justin_smith: :P

17:20 TEttinger: that is weird

17:30 nooga: justin_smith: why not cider?

17:31 justin_smith: nooga: I break it too easily

17:31 I'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:32 nooga: for me, usually M-x cider-interrupt / M-x cider-restart does the job

17:32 if something goes wrong that is

17:32 justin_smith: have you ever upgraded versions?

17:33 nooga: I'm running 0.9.0 updated from 0.8.1 I think

17:33 or something

17:34 justin_smith: clearly you have some talent I do not

17:35 nooga: I mean it was confusing and stupidly hard but I managed :D

17:36 + in 0.9.0, there's this debugger thing

17:36 which is quite awesome

17:36 justin_smith: I heard about that

17:58 TEttinger2: 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:58 for all I know this is already a thing

18:06 noncom|2: justin_smith: how did they ever read this...

18:07 looks like a write-only thing

18:08 oddcully: the perl of the past

18:12 nooga: yeah, I basically forgot how to write by hand

18:12 I use pen for signatures only these days

18:15 noncom|2: i like both writing and drawing with pen, but true, not much chance a day i get to do this

18:16 nooga: oh, drawing is cool, I used to doodle a lot and now I draw diagrams everywhere

18:17 but my handwriting is write-only

18:21 justin_smith: I've actually taken to using a fountain pen and writing ideas on paper - it's a nice break from keyboards and screens

18:21 it encourages a different kind of thinking

18:22 but 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:22 but yeah, it's so illegible I was imagining a program that could just invent it

18:23 random combinations of simulated ink strokes that look like they are probably words

18:23 tmtwd: oh so clojure has partial functions allowed in core?

18:23 nooga: looks like a task for a *deep learning* network

18:23 tmtwd: it doesn't require a special keyword?

18:24 justin_smith: tmtwd: well, we have the function "partial" if that's what you mean

18:24 tmtwd: justin_smith, but its not necessary to use partial?

18:24 noncom|2: yes, 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:24 tmtwd: for example, we could use macros

18:24 noncom|2: *neocortex

18:25 sry

18:25 justin_smith: noncom|2: exactly - hand writing is good for memory too

18:25 tmtwd: OK, but we don't have currying - don't get those confused

18:25 nooga: I play guitar

18:25 noncom|2: yep, instruments too

18:26 i play mainly keys. i also want to get an ukulele

18:26 nooga: in fact, I've arranged a small music room in my office :D

18:26 since most of us there play some instrument

18:26 noncom|2: haha :) that's so cool, really

18:27 justin_smith: i think that a neural net could be well put to work with handwriting

18:27 justin_smith: noncom|2: oh yeah, that's probably true (as nooga mentioned also)

18:27 noncom|2: yep

18:28 tmtwd: can we have recursive macros?

18:28 noncom|2: tmtwd: use macros? how

18:28 tmtwd: sure

18:28 nooga: tmtwd: what would you like to get?

18:29 tmtwd: noncom|2, http://pastebin.com/Bv7ucjeh

18:29 noncom|2: tmtwd: umm, i don't know what you're trying to acheive..

18:29 ah, currying..

18:30 i guess..

18:30 TEttinger: tmtwd: currying is... tricky with variadic argument lists

18:30 ,(+)

18:30 clojurebot: eval service is offline

18:30 TEttinger: &(+)

18:30 lazybot: ⇒ 0

18:30 TEttinger: &(+ 1)

18:30 lazybot: ⇒ 1

18:31 noncom|2: wow! what's up with cljbot

18:31 TEttinger: &(-)

18:31 lazybot: clojure.lang.ArityException: Wrong number of args (0) passed to: core/-

18:31 TEttinger: &(- 1)

18:31 lazybot: ⇒ -1

18:31 TEttinger: &(- 1 1)

18:31 lazybot: ⇒ 0

18:31 TEttinger: that's an oddity of unary -

18:31 noncom|2: yep

18:33 no, seriously, currying is good, but not something i'd be too zealous about...

18:33 esp that there's (partial)

18:34 TEttinger: Shen 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:34 nooga: btw. is there something to flip args positions in the core?

18:34 justin_smith: recursive macros:

18:34 ,(defmacro tweedle-dee [args] (if (> (count args) 3) (cons 'list args) (list 'tweedle-dumb (cons :dee args))))

18:34 clojurebot: eval service is offline

18:34 justin_smith: :P

18:35 ,(defmacro tweedle-dumb [args] (list 'tweedle-dee (cons :dumb args)))

18:35 clojurebot: eval service is offline

18:35 justin_smith: anyway, those macros are recursive, if you call (tweedle-dee nil) you get (:dumb :dee :dumb :dee) as the output

18:35 noncom|2: whats up with clojurebot?

18:36 justin_smith: noncom|2: I don't know if he likes doing macros

18:36 ,(+ 1 1)

18:36 clojurebot: eval service is offline

18:36 justin_smith: oh, something worse

18:36 noncom|2: ,run-self-diagnostics

18:36 clojurebot: eval service is offline

18:36 noncom|2: dammit

18:37 nooga: ,(defn clojurebot [_] "eval service is offline")

18:37 clojurebot: #'sandbox/clojurebot

18:37 nooga: WOW

18:37 justin_smith: anyway, those macros are totally useless, but it was fun inventing recursive macros

18:37 ,(defmacro tweedle-dee [args] (if (> (count args) 3) (cons 'list args) (list 'tweedle-dumb (cons :dee args))))

18:37 clojurebot: #'sandbox/tweedle-dee

18:37 nooga: I fixed it!!!!

18:37 justin_smith: ,(defmacro tweedle-dumb [args] (list 'tweedle-dee (cons :dumb args)))

18:37 clojurebot: #'sandbox/tweedle-dumb

18:37 justin_smith: ,(tweedle-dee nil)

18:37 clojurebot: (:dumb :dee :dumb :dee)

18:37 TEttinger: nooga: what's the situation that calls for flipping arg positions? how does it work with more than 2 args?

18:37 noncom|2: nooga: haha :D

18:38 justin_smith: nooga: periodically clojure bot resets

18:38 TEttinger: ,(defn rev-args [f & args] (apply f (reverse args))

18:38 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

18:38 nooga: TEttinger: sometimes there's a fn of 2 args, on which I'd like to use partial but they're in wrong order

18:39 TEttinger: ,(defn rev-args [f & args] (apply f (reverse args)))

18:39 clojurebot: #'sandbox/rev-args

18:39 nooga: TEttinger: and I wouldn't expect it to work on more than 2 args

18:39 TEttinger: ,(rev-args - 1 2 3)

18:39 clojurebot: 0

18:39 nooga: yeah

18:39 TEttinger: you could define your own partial...

18:39 nooga: that's what I do sometimes, I was just wondering if there was something in clojure.core for that already

18:40 justin_smith: flatland/useful has a few of these kinds of things that people coming from haskell wish clojure had

18:41 nooga: justin_smith: nice one, thanks

18:45 TEttinger: ,(defmacro flipper [f & a] `(fn [& args#] (apply ~f (concat args# ~a))))

18:45 clojurebot: #'sandbox/flipper

18:46 TEttinger: ,(map (flipper - 3) [10 20 30])

18:46 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

18:46 TEttinger: sigh

18:46 justin_smith: ,(def flipper' (constantly 'EEEeeeEEEeeEEE....SPLASH))

18:46 clojurebot: #'sandbox/flipper'

18:46 justin_smith: ,(map flipper' [10 20 30])

18:46 clojurebot: (EEEeeeEEEeeEEE....SPLASH EEEeeeEEEeeEEE....SPLASH EEEeeeEEEeeEEE....SPLASH)

18:46 * justin_smith is sorry.

18:48 gargsms: I 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:48 { "Anonymous" { :name "Anonymous" :job "Jobless" } "John" { :name "John" :job "Doe" } ... }

18:48 I tried doseq with no success

18:49 justin_smith: gargsms: ##(group-by :name [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}])

18:49 lazybot: ⇒ {"al" [{:name "al", :job "mcdonalds"}], "joe" [{:name "joe", :job "president"}]}

18:49 justin_smith: that's not identical (it uses vectors in case two people have the same name) but it's close to being your logic

18:50 gargsms: doseq is not for creating values, it can only ever return nil

18:51 gargsms: justin_smith, it does help but it returns the map with vectors

18:51 justin_smith: ,(into {} (map (juxt :name identity) [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}]

18:51 oops

18:51 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

18:51 justin_smith: ,(into {} (map (juxt :name identity) [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}])

18:51 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

18:51 justin_smith: ,(into {} (map (juxt :name identity) [{:name "al" :job "mcdonalds"} {:name "joe" :job "president"}]))

18:51 clojurebot: {"al" {:name "al", :job "mcdonalds"}, "joe" {:name "joe", :job "president"}}

18:51 justin_smith: finally

18:51 gargsms: Haha

18:51 justin_smith: sorry for that flailing-about

18:52 gargsms: juxt is for?

18:52 justin_smith: just returns a vector of the result of each function

18:52 ,((juxt inc identity dec) 0)

18:52 clojurebot: [1 0 -1]

18:53 justin_smith: ,((juxt remove filter) even? (range 5))

18:53 clojurebot: [(1 3) (0 2 4)]

18:54 noncom|2: btw just found out here they allow to excersise in clojure https://www.codingame.com/games

18:55 gargsms: justin_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:55 justin_smith: gargsms: yes, commas are whitespace

18:56 ,(= [1 2 3], [1, 2, 3], [,,,,,1,,,,,,2,,,,,,3,,,,,,],,,,,,,)

18:56 clojurebot: true

18:56 noncom|2: ,,,,,,,,,,,,,,,,,,,

18:56 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

18:56 gargsms: Ah. Thanks a lot. I will need to understand the function you gave me first. I am starting with clojure.

18:56 justin_smith: for obviously we avoid doing excessive silliness with commas, but they are not meaningful in clojure :)

18:57 AeroNotix: ,[1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1]

18:57 justin_smith: *for obvious reasons

18:57 clojurebot: [1 1]

18:57 justin_smith: I sometimes abuse commas to make the beginning of a line in my editor line up a specific way

18:57 nooga: NaNNaNNaNNaNNa...

18:57 noncom|2: ,"it's coma party"

18:57 clojurebot: "it's coma party"

18:58 noncom|2: ,NaN

18:58 clojurebot: #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:58 justin_smith: noncom|2: you probably want Double/NaN

18:58 noncom|2: ,Double/Nan

18:58 clojurebot: #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:58 noncom|2: ,Double/NaN

18:58 clojurebot: NaN

18:58 justin_smith: ,(/ 0 0)

18:58 clojurebot: #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:58 justin_smith: err

18:59 noncom|2: ,(- Double/NaN Double/Nan)

18:59 justin_smith: ,(/ 0 0.0)

18:59 clojurebot: #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:59 NaN

18:59 noncom|2: ,(- Double/NaN Double/NaN)

18:59 clojurebot: NaN

18:59 justin_smith: ,(hash-map (/ 0 0.0) :a (/ 0 0.0) :b)

18:59 clojurebot: {NaN :a, NaN :b}

19:00 noncom|2: wooooow

19:00 heeey wait..

19:00 how so

19:00 justin_smith: ,(contains? (hash-map (/ 0 0.0) :a (/ 0 0.0) :b) (/ 0 0.0))

19:00 clojurebot: false

19:00 justin_smith: that's why

19:00 noncom|2: boxed?

19:00 justin_smith: the hash map doesn't think a key is duplicate if it isn't equal

19:00 ,(= (/ 0 0.0) (/ 0 0.0))

19:00 clojurebot: false

19:00 noncom|2: ah..

19:00 no equality for NaN

19:01 justin_smith: right

19:01 well - almost!

19:01 ,(let [nana (/ 0 0.0)] (= nana nana))

19:01 clojurebot: false

19:01 noncom|2: hmm

19:01 justin_smith: err... there's a trick here to make it return true...

19:01 forgetting the trick

19:01 noncom|2: yeah, but i got the idea

19:01 justin_smith: ,(let [nana (/ 0 0.0)] (hash-map nana :a nana :b))

19:01 clojurebot: {NaN :a, NaN :b}

19:02 justin_smith: Bronsa figured out how to make two NaNs equal in some context - it was weird

19:02 noncom|2: hm

19:02 oh yeah, he could do this, he know everything about evaluation

19:03 * gargsms plans to hang out here often

19:06 justin_smith: welcome

19:07 gargsms: coming from JavaScript background, I can relate to (= NaN NaN) being false

19:07 justin_smith: gargsms: that's actually specified by IEEE floating point

19:07 gargsms: What exactly is NaN then?

19:08 justin_smith: it's a value that isn't a number - it's an undefined arithmetical result that is not equal to any number, nor itself

19:08 it's the specified result for operations that are nonsense

19:08 like (/ 0.0 0.0)

19:08 gargsms: Well, in JS you can have !NaN === !NaN

19:08 justin_smith: ,(not Double/NaN)

19:08 clojurebot: false

19:09 justin_smith: ,(= (not Double/NaN) (not Double/NaN))

19:09 clojurebot: true

19:09 gargsms: Yes

19:09 justin_smith: but not always returns a boolean, never a numeric

19:10 oh which is true in js too

19:10 gargsms: How else can you make (= NaN NaN) true without coercion then?

19:10 noncom|2: ,(= (read-string "NaN") (read-string "NaN"))

19:10 clojurebot: true

19:10 justin_smith: noncom|2: those were symbols

19:10 gargsms: Ha!

19:11 justin_smith: ,(type (read-string "NaN"))

19:11 clojurebot: clojure.lang.Symbol

19:11 danielle_romes: ,(= "NaN" "NaN")

19:11 clojurebot: true

19:11 justin_smith: gargsms: 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:11 gargsms: it's somewhat tricky to set up and I forget how

19:12 gargsms: some other time

19:12 justin_smith: I'm sure next time Bronsa is around he will remember how it worked

19:21 TEttinger: woo finally I can copy things without sometimes crashing my IRC client!

19:22 sorry about the join/crash spam

19:28 wasamasa: you could grab a znc and put it somewhere with a good connection

19:29 TEttinger: it wasn't a connection issue, it was a UI doesn't like whatever locked the clipboard issue...

19:29 ,(defmacro flipper [f# & a#] `(fn [& args#] (apply ~f# (concat args# [~@a#]))))

19:29 clojurebot: #'sandbox/flipper

19:30 TEttinger: ,(map (flipper - 3) [10 20 30])

19:30 clojurebot: (7 17 27)

19:31 ashwink005_: can I convert a url query string to a Hashmap in clojure?

19:31 justin_smith: ashwink005_: yeah, ring's wrap-query-params middleware will do that for you

19:32 ashwink005_: justin_smith: and I can refer to it using what keyword?

19:32 not :params I guess

19:32 justin_smith: ashwink005_: :query-params

19:33 ashwink005_: wrap-params merges query-params with body params etc. into one :params map

19:33 ashwink005_: hmm.. is this the correct syntax?

19:33 wait

19:34 (def app (-> (wrap-defaults app-routes site-defaults) (wrap-cookies) ))

19:34 app-routes is my handler

19:42 gargsms: ashwink005_, avoid wrap-defaults or you may end up having ANTI-FORGERY token issues

19:42 ashwink005_: gargsms: jaa yahan se

19:45 rhg135: You can disable just that. See the site

19:51 gargsms: justin_smith, I am securing some of my routes with friend and I want some routes open. Can I have different route groups?

19:52 I tried it and only one of them seems to work, whichever I pass first

19:53 justin_smith: gargsms: 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:53 ashwink005_: justin_smith: doing wrap params only. Still the request params are coming inside the query-string keyword

19:53 justin_smith: I assume that is what you are using for routing.

19:53 gargsms: justin_smith, Yes, in fact I am.

19:54 justin_smith: ashwink005_: 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:54 wrap-params itself doesn't do all that parsing I don't think

19:56 ashwink005_: justin_smith: I'm actually printing the request received. It still shows me a query string inside :query-string keyword.

19:56 justin_smith: do confirm the syntax

19:56 (-> (wrap-params app-routes)(wrap-cookies))

19:58 justin_smith: ,(macro-expand '(-> (wrap-params app-routes)(wrap-cookies)))

19:58 clojurebot: #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:58 justin_smith: ,(macroexpand '(-> (wrap-params app-routes)(wrap-cookies)))

19:58 clojurebot: (wrap-cookies (wrap-params app-routes))

19:58 justin_smith: yeah, looks right

19:59 remember that -> is just a convenience, the more middleware you have the more helpful it gets

19:59 but it's just a convenient way to do function wrapping

20:01 ashwink005_: could u suggest some middleware that could cause this problem?

20:01 params empty and query-string full

20:01 justin_smith: ashwink005_: like I said it's because you are not using wrap-query-params

20:03 or at least that's what I meant to say

20:03 ashwink005_: justin_smith: okie I'll give it a shot

20:05 justin_smith: whats the dependency?

20:06 justin_smith: oh, I was wrong

20:06 just use wrap-params

20:06 :params will be all param types merged

20:06 :query-params will be just the query params

20:07 ashwink005_: yeah I am using the wrap-params

20:07 still no luck. The params map is empty

20:07 justin_smith: and you are providing query parameters?

20:07 because in my experience that middleware works

20:08 ashwink005_: justin_smith: yes

20:08 the parameters are coming inside the query-string keyword likeI said

20:09 justin_smith: OK, :params is supposed to be the merge of query params with form-params

20:09 :query-string isn't the param map, it's the raw string

20:09 ashwink005_: yup thats how it looks

20:10 justin_smith: have you restarted your server since putting wrap-params in there?

20:10 ashwink005_: I just want my parameters added in my js file to come inside the params map

20:10 justin_smith: yup did that

20:12 domokato: what'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:12 is there something built-in that is more appropriate?

20:13 justin_smith: domokato: I think there's a bi-map out there somewhere, but beware duplicate keys of course

20:17 tmtwd: what is the difference between these 2 macros? they seem to do the same thing http://pastebin.com/8PUKsgKq

20:20 justin_smith: tmtwd: in the second one, weird things can happen with x

20:20 via capture

20:23 TEttinger: domokato: there's the set of sets approach

20:24 ,#{ #{:A :B} #{:A :C :D} }

20:24 clojurebot: #{#{:A :D :C} #{:A :B}}

20:25 cfleming: justin_smith: TEttinger: Yeah, the new pricing is, um, interesting. I hope it won't affect what I have to do with Cursive.

20:25 They have confirmed that the OSS versions will not be affected, and Cursive will always work with them.

20:26 TEttinger: I wonder if Android Studio will be affected

20:26 cfleming: Currently 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:26 No, that's free and based on the community edition AFAIK

20:27 TEttinger: what does the pro version of IDEA even... offer above Community?

20:28 domokato: TEttinger: it's not many-to-many, it's one-to-one

20:28 thanks tho

20:36 ashwink005_: has anyone used ring.util.codec ?

20:36 (ring.util.codec/form-decode "baz=3&bar=2&foo=1") gives {"foo" "1", "bar" "2", "baz" "3"}

20:36 how can I retain the keywords?

20:38 hellooo?

20:40 rhg135: Retain implies they were once

20:44 amalloy: ashwink005_: 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:44 ashwink005_: amalloy: ok sorry didn't know that

20:45 amalloy: new to IRC, will keep in mind

20:45 amalloy: anyway, 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:46 justin_smith: though some keys that would be legal in a form context might not be good keywords, which is one reason for not converting them

20:52 amalloy: yes, 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:52 ashwink005_: yeah I'm using the keywordize-keys function from the walk library

20:53 does the job

20:53 cfleming: TEttinger: 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:24 beginner: Hello! 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:40 talios: anyone 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

Logging service provided by n01se.net