#clojure log - May 20 2014

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

0:00 danielcompton: dbasch does this look correct for comparing two byte-buffers? https://www.refheap.com/85670

0:04 dbasch: danielcompton: java.nio.ByteBuffer implements comparable, so you could just do (.compareTo b1 b2)

0:05 danielcompton: facepalm

0:06 dbasch that's why I was confused about the equality thing earlier

0:06 dbasch: it returns an int, so you want (= 0 (.compareTo ….))

0:07 yeah, ByteBuffer wraps byte buffers in objects with useful methods

0:07 danielcompton: dbasch the nio version?

0:07 dbasch: yes

0:07 danielcompton: dbasch wait, there is only the nio version rihgt?

0:07 dbasch: yeah, I don’t think there’s another one

0:08 danielcompton: dbasch thanks! What is = comparing on two byte-buffers, reference or value?

0:10 dbasch: danielcompton: it will do this: http://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffer.html#equals(java.lang.Object)

0:10 so it should work

0:11 danielcompton: dbasch what's the difference between equals and compareTo? They seem to be doing the same thing?

0:11 dbasch: danielcompton: compareTo is useful for sorting

0:12 it puts them in order

0:12 danielcompton: dbasch ahh

0:12 dbasch: equals is binary

0:12 compareTo is >, = or <

0:16 yeoj___: is there any function that will convert "some-var" to :some-var to some-var ? I know about names and keywords, but seems like nothing goes into some-var

0:17 dissipate: yeoj___, yep, a macro would

0:17 tolstoy: or intern

0:17 yeoj___: so in a macro i have to unquote?

0:18 tolstoy: I think some-var# generates a symbol for you.

0:19 yeoj___: ahh ok thats what i'm mising

0:19 Frozenlock: yeoj___: Is this what you are talking about? https://www.refheap.com/11818

0:20 yeoj___: Frozenlock: i think i need the opposite of mapify, i have a :thingy inside a macro, and i'm trying to pass :thing as part of a larger string

0:21 dbasch: ,(name :thing)

0:21 clojurebot: "thing"

0:22 dbasch: yeoj___: isn’t that what you want?

0:23 ddellacosta: yeoj___: if you want a symbol from what dbasch did just do

0:23 ,(-> :some-var name symbol)

0:23 clojurebot: some-var

0:24 yeoj___: i must be thinking about it the wrong way... i'm trying to do something with this: https://www.refheap.com/85672

0:25 i've never really understood macros, and am just rewriting a bunch of boilerplate korma crud stuff

0:25 i guess i want to create a function, that has a function name as a string composition.

0:27 ddellacosta: yeoj___: here's a very simple way to do it

0:28 ,(defmacro defcrudfn [name] `(defn ~(symbol name) [args#] (println args#)))

0:28 clojurebot: #'sandbox/defcrudfn

0:28 ddellacosta: ,(defcrudfn "foo")

0:28 clojurebot: #'sandbox/foo

0:28 ddellacosta: (foo {:some "args"})

0:28 do'h

0:28 ,(foo {:some "args"})

0:28 clojurebot: {:some args}\n

0:28 ddellacosta: *d'oh

0:29 * ddellacosta can't even spell d'oh right today

0:29 ddellacosta: anyways

0:29 yeoj___: if you want to concat it, you can do this

0:29 ,(defmacro defcrudfn [name] `(defn ~(symbol (str "my-crud-fn-" name) [args#] (println args#)))

0:29 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

0:29 ddellacosta: whoops

0:29 ,(defmacro defcrudfn [name] `(defn ~(symbol (str "my-crud-fn-" name)) [args#] (println args#)))

0:29 clojurebot: #'sandbox/defcrudfn

0:29 danoyoung: i was wondering if someone could offer advice on how to repeatedly take 5K line from a file, do something with those 5K, and continue getting 5K more until the file contents are exhausted.

0:30 I'm new to clojure

0:30 ddellacosta: ,(defcrudfn "foo")

0:30 clojurebot: #'sandbox/my-crud-fn-foo

0:30 ddellacosta: (my-crud-fn-foo "args")

0:30 ,(my-crud-fn-foo "args")

0:30 clojurebot: args\n

0:30 danoyoung: I have some files in S3 that I want to loop over and read, take the contents and then index them into elasticsearch using the bulk api.

0:30 yeoj___: ddellacosta: ok i'm trying to make sense of all that, 1 min

0:31 danoyoung: so far I have something like this: http://pastebin.com/3ETqp8Fg

0:31 ddellacosta: yeoj___: sure thing--if anything is not clear definitely ask

0:31 danoyoung: but I don't know how to grab 5K @ a time….

0:31 yeoj___: ddellacosta: thank you

0:33 dbasch: danoyoung: 5k lines at a time you mean?

0:33 danoyoung: yea

0:33 something like take 5000

0:34 dbasch: danoyoung: you have a sequence of lines, so you can do that, or you can partition it into chunks of 5k

0:35 then doseq over the chunks

0:35 danoyoung: dbasch: this is what I have so far: http://pastebin.com/3ETqp8Fg

0:36 so I need to look into using the clojure.core/partition? I'm new to clojure….just need some direction….

0:37 dbasch: danoyoung: you could do something like

0:38 (doseq [chunk (partition 5000 (line-seq rdr))] (index chunk))

0:38 (doc partition)

0:38 clojurebot: "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items."

0:38 danoyoung: ok…cool, let me look into those functions.

0:38 thanx!

0:40 dbasch: learning clojure has been pretty fun so far!

0:43 ddellacosta: danoyoung: awesome. :-)

0:43 dbasch: danoyoung: if you’re looking for a good clojure book, get The Joy of Clojure

0:43 danoyoung: great, thanx. Will do!

0:43 dbasch that worked like a charm! thank you.

0:43 dbasch: you’re welcome

0:46 mercwithamouth: hrmm can someone tell me why selmer is unable to find my index.html file even when the path is hard coded in? https://github.com/jamalburgess/pepper

0:47 servo: dafuq

0:47 https://github.com/fogus/lemonad/blob/7e6137fed655777963ac7b74913c78073070adc5/lib/lemonad.js#L515

0:48 https://github.com/fogus/lemonad/blob/7e6137fed655777963ac7b74913c78073070adc5/lib/lemonad.js#L470

0:48 * servo wants what fogus is smoking

0:49 mercwithamouth: lol!!!

0:50 beamso: mercwithamouth: i found that the selmer templates have to be under src

0:51 mercwithamouth: beamso: hmm really? i guess that's fine...good to know

0:53 beamso: yup! that does it...thanks

0:53 kenrestivo: servo: um, he's a fan of h.p. lovecraft and breaking bad?

0:59 yeoj___: ddellacosta: thats great i think i got it, thanks for your help.

0:59 ddellacosta: yeoj___: Great! Glad to hear it.

0:59 yeoj___: ddellacosta: i've been staring at macros like that for ages thinking d'oh

1:00 ddellacosta: yeoj___: it took me a while before it clicked. I think you just have to keep at it and eventually it'll become second nature.

1:01 yeoj___: it's also really important to understand how symbols and vars work in Clojure--I found that a lot of my confusion about macros had to do with not understanding how those worked. So definitely read up on those if you haven't yet.

1:02 yeoj___: ...as well as being clear about compile- vs. run- time.

1:06 tolstoy: mercwithamouth: Is compojure expecting index.html in /resources/public?

1:07 servo: watcher.core=> (🙈 '🙉 '🙊)

1:07 Exception Death watcher.core/🙈 (NO_SOURCE_FILE:1)

1:07 emoji all the symbols

1:16 mercwithamouth: tolstoy_: i assume the result says no. i assumed i could tell it where to pull the file from regardless but that wasn't the case

1:17 tolstoy_: mercwithamouth: I think (route/resource "/view") might do it. It's been awhile.

1:17 mercwithamouth: that comes from a previous clojurescript attempt i made wher I was allowed to pull from the public folder. i just believe client/server code should be 100% separated

1:18 tolstoy_: i think you're right...i believe that IS what I did...i can't remember. it was over a month ago and i've been inconsistent with my clojure/compojure studying

1:18 beamso: has anyone used om in anger?

1:18 tolstoy_: :)

1:18 http://weavejester.github.io/compojure/compojure.route.html

1:18 That :root thing.

1:19 servo: woo i have a legit question now after messing with emoji:

1:19 watcher.core=> (map (comp byte int) "🙈")

1:19 IllegalArgumentException Value out of range for byte: 55357 clojure.lang.RT.byteCast (RT.java:993)

1:19 is there a way to coerce that into bytes?

1:20 mercwithamouth: beamso: it's on my todo list

1:21 tolstoy_: ah ha...i've heard of this so called 'documentation' thing

1:21 ddellacosta: beamso: what's going on?

1:21 mercwithamouth: i should really work through the project in web development with clojure before i go off on my own opposed to 'glancing'

1:21 tolstoy_: mercwithamouth: The thing about documentation is you kinda already have to know it to even know how to use the documentation.

1:22 mercwithamouth: ddellacosta: tell me you use Om as well

1:22 tolstoy_: true...

1:22 beamso: ddellacosta: i was wondering how good it is/isn't

1:22 ddellacosta: beamso: I use Om almost constantly

1:22 er, that was for mercwithamouth I suppose

1:22 beamso: the things i've read about it (and react) and the tutes seem okay

1:22 mercwithamouth: om and nolen are a God send...that is all

1:22 ddellacosta: i will be harassing you when ready. =)

1:22 ddellacosta: beamso: it's good. It doesn't solve all problems, but it solves a lot of UX dev problems.

1:22 mercwithamouth: oh, sure thing. :-)

1:23 beamso: do you use anything in particular for models or just plain javascript objects?

1:23 ddellacosta: beamso: for models--you mean for the app data we pass in?

1:23 beamso: yeah

1:23 i notice the tutes send EDN across but i was concerned about that one

1:24 ddellacosta: beamso: well, it requires maps or vectors basically. Otherwise you can't create a cursor, which is the abstraction that dnolen created to coordinate Clojure data structures with React

1:24 beamso: okay

1:25 ddellacosta: beamso: ...and I think that speaks to the biggest problem with Om, is that there are some somewhat confusing concepts involved that I'm still not sure are very clear to me--even though I've been using Om in production for months. But leaving that aside, it works well.

1:26 beamso: forgive my ignorance but what would these concepts be?

1:26 ddellacosta: beamso: not at all--well, I was talking about the cursor concept in particular. I think that's the one that is hardest to grasp, and its purpose is the least clear.

1:28 beamso: although I think this explanation is decent: https://github.com/swannodette/om/wiki/Cursors, I would like to see something that is even more general. "cursors wrap up and manage updating Clojure data structures within the React render cycle" or something

1:28 mercwithamouth: what did you want to ask about btw.? You were talking about testing routes yesterday, no?

1:29 mercwithamouth: if you have something concrete I can help you with it more easily.

1:30 mercwithamouth: ddellacosta: just now getting to it. for starters...i'd like to just create a route that collects a few fields and know that it does indeed catch the data sent

1:30 two secs...i'll create a route now and push it

1:30 ddellacosta: mercwithamouth: k

1:41 mercwithamouth: ddellacosta: ok we can use this to get my feet wet https://github.com/jamalburgess/pepper

1:42 ddellacosta: mercwithamouth: k, so, what within that in particular do you want to work with/test/etc.?

1:43 mercwithamouth: like either from the repl or command line i'd like to be able to do something like http:localhost:8080/register:"user-name":"pass" and then see that something has happened correctly

1:43 ^ new developer so i'm really not sure what to ask. i'm used to rails hiding a lot of this from me

1:43 ddellacosta: mercwithamouth: gotcha

1:44 mercwithamouth: well, the first problem is that layout is throwing an error when I try to load up a repl

1:44 ah, def -> defn

1:44 also, content-type needs to be referenced

1:46 mercwithamouth: ahh hmm...disregard that. i'd just gotten to the point where selmer worked and I started to go through the code in web development in clojure where they change the template over to use selmer. let me go back

1:47 ddellacosta: mercwithamouth: also handle-registration is broken in pepper.routes.home, I just added an id arg to that fn for now

1:48 mercwithamouth: ok sorry about that. layout.clj is back to nromal and feel free to change handle registration. i'd even be fine if we were adding data to a map

1:48 ddellacosta: mercwithamouth: no worries

1:48 one sec

1:50 freaking noir

1:51 mercwithamouth: I would suggest minimizing the use of noir...but I guess you're probably following someone's guide, no?

1:51 beamso: lib-noir?

1:51 mercwithamouth: ddellacosta: i am following someone but i'm not attached to any libraries..i'm very open

1:52 beamso: yeah i was going to use lib-noir

1:52 beamso: better to use validateur for map/record validation?

1:53 ddellacosta: yeah, I lazily call lib-noir noir

1:53 hold on, making a refheap

1:54 beamso: oh, maybe i can use prismatic schema for validation

1:54 ddellacosta: mercwithamouth: so, I had to massage a few things in your code as I described--commented out noir for now--but this is a very simple way to test routes in the repl: https://www.refheap.com/85674

1:54 mercwithamouth: it's probably way easier than you had imagined. :-)

1:55 beamso: we have our own custom validation thing, but I've prismatic's schema definitely seems good

1:55 mercwithamouth: it is and that's exacty what i was looking for =P

1:56 ddellacosta: mercwithamouth: great! I think there's probably a way to get lib-noir's session working with that too, but I'd have to play with it a bit. However, you can test out a lot of the basics of passing values around this way to start.

1:56 mercwithamouth: alternatively just use the default ring session stuff for now

1:57 mercwithamouth: so like would it be as simple as (r/request :post "/register" "name" "pass")?

1:57 ddellacosta: mercwithamouth: oh, I think you pass in a map, lemme see

1:58 mercwithamouth: like if i could do (ph/app (r/request :post "/register" {:user-handle "Jamal" :pass "pastry"})) that would be interesting

1:59 ddellacosta: mercwithamouth: this should be illustrative: https://www.refheap.com/85675

1:59 mercwithamouth: yep, that's exactly what you can do.

2:00 mercwithamouth: ddellacosta: YUP!!! exactly what i wanted

2:00 thank you!

2:00 ddellacosta: mercwithamouth: those two lines of output after I call the handler are 1) the request dumped out in the fn, and 2) the redirect response. So you can get all of that easily.

2:00 mercwithamouth: Great! Glad I could be of service. I'm going to go grab some lunch but let me know if you have more questions. :-)

2:01 mercwithamouth: Ok, I definitely will be back. this gives me enough to tinker around the way that I want to

2:02 ddellacosta: aweseom.

2:02 *awesome

2:28 ivan: where do I get that neat macro to log all function calls and return values inside an expression?

2:30 I guess this could work https://github.com/flatland/useful/blob/develop/src/flatland/useful/debug.clj

2:36 amalloy: ivan: i doubt you want to log *all* function calls and return values. that's a lot of them

2:36 but useful/? is pretty good for targeted debugging

2:40 ivan: thanks

3:01 michaelr525: hi

3:01 i

3:02 mengu: hi michaelr525

3:03 michaelr525: is lein-sub the commonly used plugin for development when your code is spread over multiple leiningen projects?

3:05 beamso: i'm unsure if you need a plugin for it : https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies

3:05 michaelr525: i'd like to reload code from a common project for example without restarting the repl..

3:05 ok, let me check that link..

3:08 beamso: thanks! looks like just what I've been looking for

3:30 mercwithamouth: hmm what's the difference between ring and ring-server...and why does the compojure-app template choose the latter as a dependency?

3:32 beamso: mercwithamouth: so you can do a 'lein ring server' at the command line and start the server

3:32 it should also let the source be recompiled on the fly (so long as you don't introduce any new dependencies)

3:34 visof: i have a bin file which need to use inside clojure, but this bin need some time to load things and then get result, i tried (sh "/bin/foo" "-q")

3:35 what is the basic way to do this?

4:31 mercwithamouth: hmm are there any plans to have rows opposed to just horizontal tabsets with light table?

4:54 ahh how i miss emacs =P

4:58 visof: can i interact with utils which are reading from STDIN in clojure from inside the code?

4:59 if i have program behaves like a shell, and waits commands to run from user, can i interact with it from inside clojure, to send commands and print outs ?

5:00 xsyn: read-line?

5:00 ,(doc read-line)

5:00 clojurebot: "([]); Reads the next line from stream that is the current value of *in* ."

5:02 visof: xsyn: nope, what i meant if i have a problem called foo, when i run like /bin/foo i got >> , and after >> should write my commands to execute, that's inside shell, but i mean inside clojure can i do this?

5:03 something like open a channel between my program and clojure, and send commands to the program, and return back the results

5:04 xsyn: like nrepl?

5:04 wait

5:04 your program and clojure? what is your program?

5:05 visof: yeah like even lieningen

5:05 xsyn: well we can suppose the problem is leiningen

5:05 s/problem/program

5:05 can i run lein from inside clojure?

5:06 xsyn: yeah

5:06 hold on

5:06 visof: okay

5:06 llasram: https://github.com/pallet/alembic

5:06 Although may not be quite what you mean

5:07 Oh, you want to launch Leiningen (or whatnot) as a subprocess

5:08 xsyn: https://github.com/zcaudate/vinyasa

5:08 vinyasa/lein

5:08 llasram: xsyn: But that's also in-process

5:08 Which I don't think is what visof is trying to get a handle on

5:08 visof: llasram: yep

5:08 xsyn: I'm really not clear on the problem space, so.. :)

5:09 visof: xsyn: sorry for my English, but i'll explain again, when you open your terminal, it's waiting you to enter command to exec, can i make this behaviour in clojure ?

5:10 run anything which waits for me to enter a commands

5:10 from inside clojure

5:11 xsyn: llasram got it?

5:12 xsyn: No, but it might be my fault

5:12 like a repl?

5:12 beamso: wouldn't you just read from system.in until you get a ctrl+d?

5:13 llasram: visof: It depends on the program, and is a general Unix programming problem

5:13 ddellacosta: visof: you are trying to execute shell commands in Clojure?

5:14 llasram: Mostly depends on whether the other process expects to communicate over just stdin/out or expects to control a terminal; in which latter case things can get hairy

5:15 Either way though, is largely out of scope for Clojure

5:15 mercwithamouth: hmm how would one get autocomplete to work with emacs/clojure

5:15 https://raw.github.com/clojure-emacs/company-cider/master/screenshot.png <--

5:15 i have cider installed...repl and everything works great as expected

5:16 ddellacosta: visof: not sure if this is what you want but check out https://github.com/Raynes/conch

5:16 visof: ddellacosta: llasram xsyn thanks

5:17 ddellacosta: mercwithamouth: Hmm, I got autocomplete working w/clojure, what did I do...

5:17 llasram: mercwithamouth: ac-nrepl ?

5:17 ddellacosta: mercwithamouth: ah, I installed auto-complete via emacs default (since 24) package manager

5:18 mercwithamouth: yeah i'm using 24.3

5:18 hmm what keys? it definitely worked with emacs-live which i don't want to use again

5:19 ok i got it

5:20 well basic autocompletion...not the list that they're showing in that screenshot...but this works for now...i'm back to using emacs

5:20 ddellacosta: mercwithamouth: my config looks like this if it helps: https://www.refheap.com/85678

5:21 mercwithamouth: yeah, I don't have all of that either, perhaps needs a clojure-specific dictionary?

5:21 mercwithamouth: ddellacosta: thanks. yeah most likely

5:21 i'll play with it after i get some rest...good to be back on emacs...not that light table isn't very nice

5:22 ddellacosta: maybe ac-nrepl that llasram suggested would help too

5:22 * beamso has been using cursive with intellij idea

5:22 mercwithamouth: beamso: eww =(

5:22 beamso: it works well enough for me

5:23 the code completion and warnings are nice

5:23 ddellacosta: now now, we are accepting of non-emacs editors here in #clojure

5:23 beamso: i haven't used it to connect to a repl though

5:23 mercwithamouth: ac-nrepl IS it

5:24 beamso: just playing around, i like intellij a lot. i'd assume their clojure setup is nice as well

5:25 ddellacosta: mercwithamouth, beamso: my boss uses it w/Clojure and likes it a lot

5:25 I'm always giving him crap about not using the one true emacs though

5:25 beamso: i've used emacs for it as well

5:27 mercwithamouth: ac-nrepl then ctags... i'm a configuration junkie

5:27 i've never really mastered using ctags, i think it's time to do so

5:28 ddellacosta: mercwithamouth: me neither. :-/

5:58 CookedGryphon: does anyone know how to make midje print proper stacktraces? I'm getting an exception when I run a test, but no line numbers annoyingly

6:15 cfleming: mercwithamouth: you wouldn't have to with Cursive, of course :-)

6:16 mercwithamouth: Cursive isn't a Jetbrains product BTW, although we're trying for the same quality level

6:17 We have a ways to go yet, though.

6:23 ssideris: cfleming: is there anything obvious that you can do with emacs that cursive doesn't do in its current version?

6:23 cfleming: ssideris: Well, it has a lot more community support, so there's modes for a lot of things we don't support yet (Expectations, Midje)

6:24 ssideris: It has better REPL integration too, e.g. we don't have macroexpansion yet, there's a few other things

6:25 But I think Cursive is pretty competitive now - we have pretty complete Paredit, although again we're missing some details here and there

6:25 ssideris: cfleming: ok, thanks :-)

6:26 cfleming: The main issue is that Cursive resolves symbols statically in the editor, which requires support for libraries using macros

6:26 So some libs that are very macro-heavy (Midje, Storm, Cascalog) are a little painful till I fix them.

6:26 I'm planning an extension API for that (in fact I use it internally) but I won't open it until it's stable.

6:27 It's getting there, bit by bit.

6:27 ssideris: cfleming: about paredit: there is a "feature" that I have impemented in elisp but isn't supported in emacs paredit out of the box: re-ordering s-expressions, and moving the cursor along with the moved s-expression so that you can move it a few positions easily

6:27 I think it's useful in some situations

6:27 cfleming: ssideris: So moving an sexp up or down and moving the cursor with it?

6:27 ssideris: yes

6:28 cfleming: Yeah, I'm planning that soon - that would be really useful.

6:28 ssideris: I'm just mentioning it as an idea for a feature

6:28 cfleming: It probably means you don't need transpose any more, I guess

6:29 ssideris: oh it seems that you're way ahead of me :-) thanks for your work, even if I don't use cursive, I think it's good for the community that it exists

6:29 cfleming: I think Cursive is going to be pretty cool in a couple of months, I'm starting work soon on a bunch of features that will be difficult/impossible to do in Emacs (or other REPL based editors).

6:29 We're already marking unused locals in the editor, which is really useful.

6:30 And having a decent rename + find usages is really great

6:30 But it'll take us a while to catch up with everything Emacs does right now

6:31 Thanks, it's a fun product to work on.

6:32 ssideris: I'm intrigued by what you said about features being impossible in emacs

6:32 cfleming: Maybe not impossible, but difficult

6:33 The main difference is that Cursive resolves symbols statically in the editor

6:33 So for a particular symbol, I know where it was declared, and thus what type of thing it is

6:33 clgv: cfleming: I saw that unused locals features - it seemed it had false alarms on macros that have binding definitions

6:34 cfleming: That allows me to mark unused locals right now

6:34 clgv: Really? I'd be interested to see a case of that.

6:35 None of this will ever be perfect with Clojure unfortunately, the language is just too flexible to do everything in an IDE you can do with Java

6:35 clgv: cfleming: I think the examples where in compojure code that a student showed me in cursive

6:35 cfleming: But you can get a long way

6:35 Ok - do you mean that the IDE said that it couldn't resolve symbols?

6:36 Yeah, that's what I mean by the fact that macros will require some code to identify those symbols

6:36 clgv: ah right. that's the exact description

6:36 cfleming: The unused locals is something else - this is where for a let-binding or a function parameter, or something similar, Cursive will tell you if it's never used.

6:36 clgv: I mixed up unused locals with undeclare symbols, sorry

6:36 cfleming: No worries

6:36 It's really useful, since that is nearly always a bug

6:37 We'll be marking unused imports and requires in the editor soon too.

6:37 clgv: cfleming: I know that ccw does a lot of this editor features via static analysis as well. I always thought it shouldnt be that complicated to run an additional repl for the UI which can provide exact infos, is it?

6:37 cfleming: You could probably do this in Emacs, and of course you can always use something like Slamhound externally, but having it live in the editor is really nice

6:38 clgv: I don't think ccw does anything statically, it's all done in the REPL, like Emacs or Vim would do it.

6:38 clgv: cfleming: yeah, I definitiely wont argue against nice to have features. I hardly use emacs ;)

6:38 cfleming: the outline is definitely static

6:38 cfleming: AFAIK they don't even provide rename right now.

6:39 clgv: auto completion and such is done via the REPL

6:39 cfleming: Hehe, yeah, I'm not trying to start an editor war by any means, it's just interesting to compare them.

6:39 clgv: yeah, thought so ;)

6:39 cfleming: Emacs et al never have the problem of undefined symbols, even if they're generated by some gnarly macro

6:40 Although with a REPL you can't do anything with local symbols, only globals

6:40 Swings and roundabouts

6:40 clgv: cfleming: but again, do you think it would be that complicated to combine the static analysis with information from evaluating the project?

6:41 cfleming: No, and it's something I've thought about. The issue is that you need a REPL, and you either wait for the user to set one up (and have no support till that's done) or you try to do it automatically

6:41 But people do some crazy things with macros, you can get all kinds of side effects, or it can require odd startup.

6:42 clgv: cfleming: I'd choose the automatic option and separate it completely from any repl the user launches

6:42 cfleming: Storm creates a bunch of vars from fields of a Java class, so for that to work you have to compile + load the class, and there's no way to know from looking at the code that you need to do that.

6:42 clgv: but depending on the features some communication might be needed between that repl and a user repl

6:42 cfleming: clgv: but you can't automatically start a REPL and just try to load everything into it.

6:43 The user would have to specify what they want loaded.

6:43 I dunno, it's messy.

6:43 But you can't do macroexpansion without a REPL - for the moment I'll be using whatever the user has open

6:43 clgv: cfleming: you could lazyily load the namespace as soon as they are needed because the user edits a namespace

6:44 cfleming: clgv: yeah, but that wouldn't load Storm's Java class

6:44 clgv: when you open an editor for a namespace it can be loaded in the background to provide needed information

6:44 cfleming: Yeah, you can do that. I'm not sure, I'm going to see how far fully static will take me - combining the information from the two would be tricky

6:45 But it might turn out to be necessary

6:45 I'm hoping not, though :-)

6:47 clgv: cfleming: well, how can you do anything useful for custom macros defining symbols or functions?

6:47 cfleming: I think thats the main problem that static analysis will not solve

6:50 cfleming: clgv: I have an extension API, which is what I use internally - I'll open that up.

6:51 It's pretty simple, you basically provide a function that takes a form and returns a map that looks very like var metadata

6:51 clgv: cfleming: ah, the user can provide the syntax of custom macros so that cursive is able to interprete them correctly?

6:51 cfleming: Yup

6:51 Well, not yet, only I can right now. But that's the idea.

6:51 clgv: so the most popular libraries can get those annotations like that

6:52 cfleming: Yeah, and people can write support for their internal macros.

6:52 clgv: interesting.

6:53 cfleming: I'll probably have a central repo (like DefinitelyTyped for Javascript)

6:53 But people would be able to use their own extensions.

6:58 ddellacosta: hmm, what is the plugin for emacs which lets you close/hide clojure forms? is it available in clojure-mode by default? Not sure what to call that operation

6:58 clgv: ddellacosta: fold/unfold?

6:58 ddellacosta: clgv: yah, that sounds right...know how to do that w/clojure in emacs?

6:59 clgv: ddellacosta: no idea. I just wanted to suggest what name you could search

6:59 ddellacosta: clgv: ah, okay...will see if that helps find the package

6:59 thanks

7:00 agarman: I've honestly never missed collapsed code in emacs

7:00 but if you want it

7:00 hs-minor-mode

7:00 should be available with emacs by default

7:01 C-c @ C-c

7:01 is the default keybinding

7:01 ddellacosta: clgv, agarman: d'oh, just found that via this stackoverflow question: http://stackoverflow.com/questions/1085170/how-to-achieve-code-folding-effects-in-emacs ...but thanks!

7:01 agarman: yeah, I haven't really ever needed it, but figured I'd play with it and see if it helped at all

7:02 agarman: I wanted to get rid of a require form in particular...

7:02 agarman: IMO, if a require form is so large you don't want to see it, you may have a module that is due to be split apart ;-)

7:02 but enjoy

7:03 mercwithamouth: peep

7:04 ddellacosta: agarman: generally I'd agree, but this is my base wrapper for my web app, and loads up a bunch of other libs to wrap them up into one main handler. The require block is almost as big as the code in the file!

7:09 clgv: o_O

7:10 ddellacosta: (I exaggerate...maybe one-third as big.)

7:17 martinklepsch: Anyone experience getting nothing but "[Opened /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/rt.jar]" when running an uberjar with "java -jar name.jar" ?

7:17 I tried oracle jdk and openjdk, no luck

7:17 (it's all on ubuntu in a docker container)

7:18 oh and the command had a "-verbose" in it too

7:21 beamso: no logs from the application apart from that?

7:22 silasdavis: I'd like a function that truncates the number of children of any node to be less than n, where a child is either a either a key-value pair or an element in a sequence

7:23 so that I can print large structures without killing my terminal

7:23 does anyone know of an existing function that does this, or a nice way of doing it?

7:24 CookedGryphon: bind *print-length*

7:24 (binding [*print-length* 10] (pr-str (range 99999999))

7:24 martinklepsch: beamso, no... same problem as yesterday :/

7:24 beamso: oh.

7:24 it's still today for me :/

7:24 have you tried running something else in the container?

7:27 silasdavis: CookedGryphon, ah! I didn't realise that would act recursively across the breadth

7:28 martinklepsch: beamso, haha, that's fun

7:28 I slept the 8 of the last 10 hrs

7:30 mercwithamouth: hmm any ideas on how to stop my server when (stop-server) gives a null pointer error?

7:30 ps aux i suppose

7:31 good enough...

7:33 xsyn: (pgrep)

7:34 master_op: hello, how can handle global variables for my probram

7:34 mercwithamouth: '(pgrep)

7:34 lol break damn you

7:34 master_op: program

7:34 mercwithamouth: jk

7:35 ddellacosta: master_op: need more context

7:35 master_op: i have a map that change frequently , how can i update it

7:35 ddellacosta: master_op: still need more context

7:35 agarman: master_op: more context, but in general global variables should be minimized

7:35 master_op: i have a map defined when program start

7:35 ddellacosta: master_op: why/when do you need to update it?

7:36 master_op: and i have a function to update this map

7:36 add some keyword/value every time

7:36 agarman: master_op: wrap it in an agent, atom or ref

7:37 master_op: i use ref but when i try to use contains? it tell me that it not supported on refs

7:37 agarman: master_op: but there's likely a better way to do whatever you're trying to do without depending upon a mutable variable

7:37 master_op: how can i do it ?

7:37 agarman: you have to (contains? @v)

7:37 master_op: ok

7:37 agarman: master_op: read http://clojure.org/concurrent_programming

7:38 or rather http://clojure.org/refs

7:43 CookedGryphon: Is there a way to make core.async print line numbers on its exceptions, it's really really annoying having it tell me there's an issue doing a take! from nil but not giving me a clue where that's happening....

7:55 gfredericks: CookedGryphon: haha :(

7:59 CookedGryphon: do you not at least have a stack trace?

7:59 I'd think there'd be line numbers from the core.async code at least

7:59 CookedGryphon: nothing, it just prints the message from the exception and nothing else

7:59 llasram: gfredericks: Unless tbaldridge has cut a new version, IIRC the last release includes some code (I assume accidentally left in debugging code) which just prints the exception

8:00 No trace, etc -- just the exception object

8:00 gfredericks: oh that's wonderful

8:00 CookedGryphon: it's better than failing silently like it used to iirc

8:01 gfredericks: my favorite thing is when an ExceptionInfo gets printed without the data

8:01 llasram: https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/exec/threadpool.clj#L33

8:01 CookedGryphon: could someone change that to a print-stack-trace?

8:01 gfredericks: I bet you could monkey-patch it :P

8:02 llasram: Or locally install a snapshot build, or use Leiningen checkouts

8:02 CookedGryphon: I might actually do that, I'm already monkey patching the executor to tweak the threadpool on android

8:02 but hoped I wouldn't have to for my local unit tests

8:02 gfredericks: does anybody have a core.async utils lib yet?

8:04 cause if not I might have to make core.a-sink

8:04 llasram: ha!

8:05 gfredericks: it'll have a function for finding out how many messages are in a buffer

8:06 and for creating a lazy seq from a channel

8:11 stuart says: "The channel-to-sequence conversion seems like a questionable idea, making seqs that block."

8:12 any kind of IO-based seq is a seq that can block though, no?

8:12 llasram: I would say so

8:13 gfredericks: I wonder if he considers that questionable too

8:15 seque should be easy to write with core.async eh?

8:16 probably just as easy with one of those j.u.c queues though

8:16 although core.async would let you use the go macro without taking up a thread

8:38 mercwithamouth: ahh nice... ac-repl is now working

9:07 crispin: hey peeps

9:07 agarman: crispin: hello

9:07 crispin: what's some other ways of expressing (and (:key1 opts) (:key2 opts) (:key3 opts))

9:08 that is, whether a handful of keys are in a hashmap?

9:09 agarman: (if-let [{:keys [key1 key2 key3} opts] ...)

9:09 nvm

9:10 not equivalent

9:10 crispin: reading up on if-let now. heh

9:10 so many functions

9:14 agarman: (every? #(% opts) keys)

9:14 mpenet: ,((every-pred :a :b) {:a 1 :b 2})

9:14 clojurebot: true

9:14 mpenet: ,((every-pred :a :b) {:a 1 :c 2})

9:14 clojurebot: false

9:14 kaw_: How about (every? opts [:key1 :key2 :key3])?

9:14 mpenet: many ways to do this

9:14 but many fail if entry val is nil :)

9:15 or falsey

9:15 gfredericks: anything wrong with this impl of seque? https://gist.github.com/fredericksgary/2f6d21890bbe82ed5416

9:15 it seems at least better than clojure.core/seque since it doesn't drop exceptions

9:15 agarman: I prefer (every? opts keys) as you're able to use key values that aren't keywords

9:16 crispin: i got (every? opts #{:k1 :k2 :k3})

9:17 agarman: don't need set

9:17 ,(every? {:k1 1 :k2 2} [:k1 :k2 :k3])

9:17 clojurebot: false

9:17 agarman: ,(every? {:k1 1 :k2 2 :k3 3} [:k1 :k2 :k3])

9:17 clojurebot: true

9:21 gfredericks: TimMc: so in my team's chat room we have this chatbot that will do image searches

9:21 somebody just searched for "Gary Fredericks clojure" and up came your photo with the shoulder rodents

9:22 clojurebot: shoulder rodents |would be| an acceptable name for a rock band

9:22 clojurebot: Ik begrijp

9:27 CookedGryphon: Could someone help me write a version of alts which has an even stronger priority

9:28 i.e. I want to always take from the first channel as long as there's something there

9:28 and only when there's nothing to take look at the next channel

9:28 gfredericks: what does "when there's nothing" mean?

9:28 CookedGryphon: when there's no immediately available value

9:28 gfredericks: that sounds like what the :priority option already does

9:29 CookedGryphon: hmm, from my experience it seems to check them in order, but it still cycles through them

9:29 so if i have (alts! [a b] :priority true

9:29 it will check a first, but after it's taken something from a, it won't keep taking from a, it moves on to take something from b

9:29 gfredericks: hm.

9:29 I'll go try that.

9:29 CookedGryphon: I might be wrong and actually I've done something else wrong

9:31 gfredericks: that's my suspicion

9:31 given that alts! only takes one thing I'm not sure what you're even trying to describe

9:31 CookedGryphon: fair point

9:31 now I think about it, it was an utterly ridiculous question...

9:31 tbaldridge: alts! takes options as well gfredericks

9:32 (alts! ports & {:as opts})

9:32 CookedGryphon: what he means is, it's only taking one thing from one channel per alts! call

9:32 so my question is nonsensical

9:32 tbaldridge: ah right

9:32 gfredericks: haha "takes one thing"

9:33 CookedGryphon: I think the issue is my underlying structure needs a rethink

9:34 gfredericks: I tried to test this out and my code is hanging :(

9:34 oh I think it gave me a vector of way too many nils

9:34 because alts is happy to "take" from a closed channel

9:36 CookedGryphon: I'm making a system where events go in the top and there's a mult which broadcasts to various subscribers. These subscribers might themselves generate more events as a result of whatever they're listening for

9:37 I want these internally generated events to get processed first before working on any more externally generated events, so I have an external-input channel and a feedback channel, which I am trying to merge with alts! priority true and then doing mult on the result

9:38 and it seems to work in practice

9:38 but my tests are creating these, then doing onto-chan which closes immediately after the events are copied onto the input channel

9:39 and what's happening is that it's causing everything to close before all the internal events have been generated

9:39 tbaldridge: there's an option to onto-chan that makes it not close

9:39 CookedGryphon: yep, but then how do I know when it's done?

9:39 without just sticking a timeout on my tests

9:40 plus, I want to test that when the channel *is* closed, everything falls out of its go-loops and whatnot and is nicely cleaned up

9:40 and not sat there spinning or anything

9:40 (my tests also listen for the results of all the go blocks that get started to make sure everything has given up control by the end)

9:41 tbaldridge: it's hard to say without seeing the code

9:42 gfredericks: somebody plz write core.async.erlang

9:43 you could rewrite the go macro to support killing "processes"

9:44 tbaldridge: I've thought about it, but it gets pretty hard once you consider that a "go" may or may not be currently running or parked. It's easy to cancel a park, hard to kill a thread

9:44 gfredericks: yeah I was assuming you would only kill while parked

9:45 are rarely-parked gothreads a common pattern?

9:45 CookedGryphon: my issue is that I don't want to kill outright, I want to stop putting new input in the top, allow it to finish processing and then let me know when its finished so I can gather the results for my test

9:47 I sort of want to say "when all these go loops are parked, hand me control"

9:47 TimMc: gfredericks: This is acceptable to me.

9:48 CookedGryphon: is there any way of working out whether a go block is parked?

9:50 gfredericks: clojurebot: TimMc is the Gary Fredericks of Clojure

9:50 clojurebot: Roger.

9:53 clgv: TimMc?

9:53 clojurebot: TimMc is the Gary Fredericks of Clojure

9:53 clgv: :D

9:54 gfredericks: does seque actually suppress errors? I thought so but now I can't reproduce

9:54 ,(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5))

9:54 clojurebot: Execution Timed Out

9:54 gfredericks: &(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5))

9:54 lazybot: ⇒ (3/5 2/3 3/4 6/7 1 6/5 3/2 2 3)

9:55 gfredericks: &(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5) (last))

9:55 lazybot: ⇒ 3

9:55 gfredericks: ,(->> (iterate dec 10) (take 20) (map #(/ 6 %)) (seque 5) (last))

9:55 clojurebot: Execution Timed Out

9:55 gfredericks: in my repl that gives an arithmetic exception

9:55 so...three different behaviors.

9:56 &(->> (iterate dec 2) (take 5) (map #(/ 6 %)) (seque 5))

9:56 lazybot: ⇒ (3)

9:57 gfredericks: ???

9:57 lazybot: gfredericks: Oh, absolutely.

9:59 TimMc: clojurebot: gfredericks?

9:59 clojurebot: gfredericks is a menace to bots everywhere

9:59 ticking: I think the edn spec is missing fractions, any thoughts?

10:01 gfredericks: ticking: I hadn't noticed that, that's interesting

10:02 ticking: easy to do with data readers though

10:20 ticking: gfredericks: yes, but the clojure.edn parser does handle fractions

10:20 ,(clojure.edn/read-string "1/2")

10:20 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn>

10:20 ticking: hrmph

10:20 clgv: ,(require 'clojure.edn)

10:20 clojurebot: nil

10:20 clgv: try again ^^

10:20 ticking: ,(clojure.edn/read-string "1/2")

10:20 clojurebot: 1/2

10:21 hyPiRion: whut

10:21 ticking: clgv: ah thanks I didn't know that the clojurebot had state ^^

10:21 clgv: ticking: yeah, clojurebot even supports "def" now. I think the variables are cleared after some time

10:21 ticking: ,(pr-str 2/4)

10:21 clojurebot: "1/2"

10:21 ticking: clgv: nice ^^

10:22 so yeah either clojure.edn implements to much or the formal syntax is missing something

10:24 gfredericks: ticking: I mean doing e.g. #ratio [3 4]

10:24 ticking: gfredericks: yeah but that's not how the edn toolchain currently implements it

10:24 currently it simply understands ratios (which is the correct behaviour imho) but this is not conform with the spec

10:34 hyPiRion: ticking: yeah, I would file an issue over at the EDN spec, I guess

10:34 ticking: currently on it ^x

10:34 hyPiRion: nice

10:38 master_op: hello, i have a problem at merge-with http://pastebin.com/6DNBSGX3

10:40 llasram: master_op: `merge-with` doesn't have any special handling for nested maps

10:40 master_op: ok

10:41 how can perform this ? any idea ?

10:41 llasram: You want something like (merge-with (partial merge-with +) ...), or define your own recursive version

10:41 master_op: ok

11:14 stuartsierra: master_op, llasram: some old code you can copy here https://github.com/clojure/clojure-contrib/blob/d04a63371ea8d5313ba427259a58e51270d8f7da/modules/map-utils/src/main/clojure/clojure/contrib/map_utils.clj#L41

11:49 gfredericks: ,(clojure.edn/read-string "3/4")

11:49 clojurebot: #<ClassNotFoundException java.lang.ClassNotFoundException: clojure.edn>

11:49 gfredericks: ,(require 'clojure.edn)

11:49 clojurebot: nil

11:49 gfredericks: ,(clojure.edn/read-string "3/4")

11:49 clojurebot: 3/4

11:49 gfredericks: ,(clojure.edn/read-string "3N")

11:49 clojurebot: 3N

11:49 gfredericks: ,(clojure.edn/read-string "3M")

11:49 clojurebot: 3M

11:49 gfredericks: ,(clojure.edn/read-string "3r222")

11:49 clojurebot: 26

12:04 KeithPM: Good day. I am trying to implement fibonacci using a dictionary. I tried memoize but could not figure out a function to memoize - I am seeking to implement without recursion. I created a ref to a map, updated it on each iteration and looked up values. It appears that all the updates that are performed within the for comprehension are lost when I leave the for. https://gist.github.com/kpmaynard/f8b539326bf2e903f402

12:05 TEttinger: KeithPM, for is lazy IIRC

12:06 gfredericks: KeithPM: you want let instead of def

12:06 KeithPM: and you can probably replace for with doseq and have it almost work

12:06 at which point you can remove your do

12:06 CookedGryphon: KeithPM: *why* do you want to do this without recursion?

12:06 KeithPM: gfredericks: OK, I will look up doseq

12:07 CookedGryphon: and memoize isn't a good fit because you have side effects everywhere, memoize works with pure functions

12:07 gfredericks: KeithPM: doseq has the exact same syntax as for

12:07 KeithPM: CookedGryphon: I was looking at a dynamic programming course and that was one of the techniques of handling certain classes of 'intractable' problems

12:07 gfredericks: memoize can only work if the recursion is memoized as well

12:07 KeithPM: gfredericks: Thanks

12:08 TEttinger: IIRC?

12:08 CookedGryphon: KeithPM: when you say without recursion, do you simply mean without blowing the stack by calling back into your function repeatedly? Because there's nicer ways of doing that

12:08 gfredericks: https://github.com/Prismatic/plumbing/blob/master/src/plumbing/core.clj#L305-320

12:09 $google iirc

12:09 lazybot: [The IIRC | INTEGRATED REPORTING] http://www.theiirc.org/

12:09 gfredericks: haha

12:09 CookedGryphon: :P

12:09 KeithPM: CookedGryphon: yes, I know some really neat approaches. I was trying the memo approach for savng subproblems that have already been solved

12:10 TEttinger: if I recall correctly

12:11 KeithPM: TEttinger: OK - cool :) I'll memoize that one LOL

12:11 clgv: KeithPM: for the dp approach you'd just use a loop-recur with a loop variable to fill the dp-vector

12:12 KeithPM: clgv: But in the case of exponential problems like Fib, you still perform fib(n) multiple times right?

12:13 gfredericks: ,(defn fib [n] (get (reduce (fn [m n] (assoc m n (+ (m (dec n)) (m (- n 2))))) {0 1 1 1} (range 2 (inc n))) n))

12:13 clojurebot: #'sandbox/fib

12:13 gfredericks: ,(fib 20)

12:13 clojurebot: 10946

12:13 clgv: KeithPM: I don't undestand that question

12:13 gfredericks: ,(map fib (range 20))

12:13 clojurebot: (1 1 2 3 5 ...)

12:13 gfredericks: ,(defn fib [n] (get (reduce (fn [m n] (assoc m n (+ (m (dec n)) (m (- n 2))))) {0 1N 1 1N} (range 2 (inc n))) n))

12:13 clojurebot: #'sandbox/fib

12:13 gfredericks: ,(fib 100)

12:13 clojurebot: 573147844013817084101N

12:14 gfredericks: ^ dynamic programming, no mutation necessary

12:14 clgv: gfredericks: I'd use a clojure vector though ;)

12:14 gfredericks: ,(defn fib [n] (get (reduce (fn [m n] (assoc m n (+ (m (dec n)) (m (- n 2))))) [1N 1N] (range 2 (inc n))) n))

12:14 clojurebot: #'sandbox/fib

12:14 gfredericks: ,(fib 100)

12:14 clojurebot: 573147844013817084101N

12:15 gfredericks: (inc clgv)

12:15 lazybot: ⇒ 19

12:15 clgv: :D

12:15 gfredericks: ,(fib 1000)

12:15 clojurebot: 70330367711422815821835254877183549770181269836358732742604905087154537118196933579742249494562611733487750449241765991088186363265450223647106012053374121273867339111198139373125598767690091902245245323403501N

12:15 gfredericks: ^ that guy is lonely because other fibonacci numbers are so far away

12:15 KeithPM: gfredericks: I will take a look at that

12:16 gfredericks: KeithPM: it's really common for algorithmic stuff like this to be solvable without any state/side-effects etc

12:16 the lazy seq approach is even more common than building up a vector though

12:16 adsisco: i have a function that f [index i, index j] that generates a float value, how do i use it to populate a matrix in clojure?

12:17 KeithPM: clgv: What I was referring to is that in the recursion tree you find the same problem occurring on two sides. The approach we're looking at is saving a problem the first time you meet it and check each new subproblem to determine whether it has been solved already

12:17 adsisco: [[(f 0 0) (f 1 1)] [(f 1 0) (f 1 1)]]

12:17 i hope i'm making sense...

12:17 jcromartie: yeah

12:17 adsisco: you want for

12:17 KeithPM: gfredericks: Thanks. The power of reduce and map :)

12:17 adsisco: i could do loop in an imperative language

12:17 clgv: KeithPM: yeah that's memoization if you mean top-down, dynamic programming is bottom up

12:17 adsisco: is that the clojure way?

12:18 jcromartie: a for loop?

12:18 jcromartie: ,(for [i (range 1) j (range 1)] [i j])

12:18 clojurebot: ([0 0])

12:18 jcromartie: oops

12:18 KeithPM: Yes I was doing bottom up

12:18 jcromartie: ,(for [i (range 2) j (range 2)] [i j])

12:18 clojurebot: ([0 0] [0 1] [1 0] [1 1])

12:18 KeithPM: clgv: yes I was doing the bottom up approach

12:18 jcromartie: clojurebot: for?

12:18 clojurebot: for is complected

12:18 jcromartie: hm

12:18 adsisco: anyway, for in Clojure is not a for loop, it's a seq comprehension

12:18 clgv: clojurebot: for |is| awesome

12:18 clojurebot: Roger.

12:20 adsisco: jcromartie ok, so i just map the function to the for to get my matrix right?

12:20 jcromartie: something like that

12:21 hm

12:22 let's say your function is str, so

12:22 ,(for [i (range 2) j (range 2)] (str i j))

12:22 clojurebot: ("00" "01" "10" "11")

12:22 jcromartie: that's probably not what you want

12:23 ,(vec (for [i (range 2)] (vec (for [j (range 2)] (str i j)))))

12:23 clojurebot: [["00" "01"] ["10" "11"]]

12:23 jcromartie: that's better

12:23 adsisco: right?

12:23 (is forv a thing yet?)

12:23 ,forv

12:23 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: forv in this context, compiling:(NO_SOURCE_PATH:0:0)>

12:24 jcromartie: it should be

12:24 sdegutis: Okay, I finally settled on having the production code be default, and with-redef'ing them out with test functions during tests.

12:25 Or the inverse, defaulting to the test version and resetting them in web-init.clj

12:25 jcromartie: (defmacro forv [bindings & body] `(vec (for ~bindings ~@body)))

12:26 there should be a macro that defmacros a macro wrapped in something

12:27 compmacro

12:27 gfredericks: so what's the use case for forv?

12:29 clgv: gfredericks: eager aggregation over nested maps

12:29 measurements etc.

12:29 adsisco: jcromartie: yup, thats really helpful, thanks alot!

12:30 clgv: but I'd implement it similarly to mapv with one collection

12:32 gfredericks: eagerness is only useful when your computation is tied to a stateful resource; and vectors are about indexed update/lookup

12:32 and indexed access seems hard to reconcile with list comprehensions

12:32 so my guess is this isn't actually useful very often

12:33 jcromartie: well in the case above, it was for creating a matrix, which is a great case for indexed lookup

12:33 gfredericks: for matrices I'd think something more specialized than for would be more useful

12:33 e.g., you probably don't need filtering with matrices

12:34 and you might not want the matrix impl to be concretized as vectors or lazy seqs

12:34 jcromartie: alright fine, no forv :)

12:35 gfredericks: unless you're doing tensor products you'd probably never need more than one clause in the for anyhow

12:36 KeithPM: Thanks all for your advice. I changed for to doseq and suddenly my ref was available all over. I will take another look at immutable DP approaches suggested here. Brain surgery in progress :)

12:37 adsisco: https://www.irccloud.com/pastebin/JQRXFSZ0

12:38 create a wrapper function?

12:38 jcromartie: (map (partial get-in-distance-by-index json-data) (for …))

12:38 or #(get-in-distance-by-index json-data %)

12:39 clgv: gfredericks: eagerness is also usefull in the cases where you have to be pretty fast ;)

12:40 gfredericks: the above version of "forv" won't help for that though ;)

12:40 adsisco: jcromartie the partial fix works perfectly!?

12:40 jcromartie: great!

12:40 gfredericks: clgv: fo sho

12:49 te: given "12", I want to add a padding digit to the front until the length of the string is = 4. ,(loop [id "12"] (if (< (count id) 4) (recur (str "0" id)) id))

12:49 how would you do that without a loop?

12:50 clgv: ,(format "%04d" 12)

12:50 clojurebot: "0012"

12:50 TEttinger: yep

12:50 jcromartie: ^winner

12:50 storme: ,(format "%08d" 12)

12:50 clojurebot: "00000012"

12:50 arrdem: (inc clgv)

12:50 lazybot: ⇒ 20

12:51 TEttinger: (inc clgv)

12:51 lazybot: ⇒ 21

12:51 clgv: damn. a good day for karma ;)

12:51 arrdem: format is osum :D

12:51 sdegutis: (inc clgv)

12:51 lazybot: ⇒ 22

12:51 hyPiRion: ,(require '[clojure.pprint :refer [cl-format]])

12:51 clojurebot: nil

12:51 cbp: no format in cljs ;(

12:51 te: oh no...

12:51 here comes hyPiRion

12:51 hyPiRion: ,(cl-format true "~4,'0B" 12)

12:51 clojurebot: 1100

12:52 hyPiRion: te: it's not *that* bad this time :p

12:52 cbp: is clojure.pprint available in cljs?

12:54 sc4n: Hi

12:54 te: hmm, clgv -- that works, but there are some issues. for instance, it will not work on strings, which is the input

12:54 there are also situations where it's unlikely, but /possible/ to have a number bigger than a bigint, so it will blow up

12:55 err than an int

12:55 ,(format "%04d" 1243892704832094832904832)

12:55 clojurebot: #<IllegalFormatConversionException java.util.IllegalFormatConversionException: d != clojure.lang.BigInt>

12:55 arrdem: te: there is separate formatting for doing the same padding on strings

12:56 cbp: hyPiRion: I don't think so

12:57 hyPiRion: cbp: a sad day for humanity

12:57 te: arrdem: what is the syntax for that?

12:57 arrdem: te: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax

12:58 hyPiRion: of course, the java formatter cannot do stuff like this though:

12:58 ,(cl-format nil "~14,'0,' ,4:B" 451)

12:58 clojurebot: "0001 1100 0011"

12:58 arrdem: hyPiRion: that's fine, and why we have cl-format :P

12:59 hyPiRion: arrdem: shh you're interrupting my monologue

13:00 arrdem: hyPiRion: it's a dialog as long as you recognize my interrupts :P

13:00 unless it's a platonic dialogue in which case I'll back off to saying "yes" and occasionally heckling

13:01 s/platonic/socratic/

13:02 te: arrdem: yeah, im looking, just not sure where there is something similar

13:02 hyPiRion: hrm, I am wrong yet again

13:02 :p

13:02 arrdem: hyPiRion: it's ok, just write it in swearjure and nobody else will ever know

13:02 te: ,(format "%1$3s" "22")

13:02 clojurebot: " 22"

13:02 te: but where do i specify the character to pad with?

13:03 TEttinger: $google java.util.formatter

13:03 lazybot: [Formatter - Oracle Software Downloads] http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html

13:03 TEttinger: it's a mess

13:04 hyPiRion: arrdem: on my todo-list

13:04 te: TEttinger: is that for me?

13:04 im just saying, i dont think it's possible to pad with a specified char using format

13:05 you can pad left with a space, but then need to replace those spaces with your desired char

13:05 TEttinger: te, yeah, the syntax for format strings is derived from java's syntax for it which comes from C, and so on

13:05 cbp: te: maybe you want apache.commons stringutils

13:05 te: cbp: yeah, sounds that way

13:06 TEttinger: the other way is to just check the length, subtract length from desired padded length, and use that many chars of padding

13:07 hyPiRion: ,(cl-format nil "~4,,'0@A" "12")

13:07 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: cl-format in this context, compiling:(NO_SOURCE_PATH:0:0)>

13:08 hyPiRion: ,(require '[clojure.pprint :refer [cl-format]])

13:08 clojurebot: nil

13:08 hyPiRion: ,(cl-format nil "~4,,'0@A" "12")

13:08 clojurebot: #<RuntimeException java.lang.RuntimeException: Parameter minpad has bad type in directive "A": class java.lang.Character\n~4,,'0@A\n ^\n>

13:08 hyPiRion: ,(cl-format nil "~4,,,'0@A" "12") ; there

13:08 clojurebot: "0012"

13:09 TEttinger: ,(let [start "22" pad-char \: desired-length 10] (str (apply str (repeat (- desired-length (count start)) pad-char)) start)

13:09 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

13:09 TEttinger: ,(let [start "22" pad-char \: desired-length 10] (str (apply str (repeat (- desired-length (count start)) pad-char)) start))

13:09 clojurebot: "::::::::22"

13:10 ampharmex: , (use '[clojure.java.shell :only [sh]]) (sh "free") (sh "top" "-bn1")

13:10 clojurebot: nil

13:10 hyPiRion: oh what

13:11 TEttinger: ,(print (sh "top" "-bn1"))

13:11 clojurebot: #<SecurityException java.lang.SecurityException: denied>

13:11 TEttinger: haha

13:11 hyPiRion: ,(sh "shutdown" "-h" "now")

13:11 clojurebot: #<SecurityException java.lang.SecurityException: denied>

13:11 hyPiRion: =(

13:11 arrdem: sdegutis: no worries we all have bad days

13:12 sdegutis: Well I must have missed them, you're all so nice :)

13:15 ampharmex: has anyone broken out the clojure bot jail?

13:15 arrdem: ampharmex: not for a while, but it's been done before

13:16 hyPiRion: ampharmex: xeqi did it once, see http://nelsonmorris.net/2012/09/06/breaking-lazybot-out-of-clojail.html

13:16 essentially the shell access problem

13:29 sdegutis: Wow, took technomancy's advice and now my third party service proxy is down from 5 files to 2 small ones.

13:29 This is pretty great.

13:29 I should seriously consider other people's ideas more often.

13:32 You know, I find that the more I try to make our code robust, the less I'm relying on fancy language features, but only basic functions and values.

13:33 mdrogalis: sdegutis: Pour extra hot water from tea-making onto the sponge in the sink to kill bacteria.

13:33 ... Other people's ideas that are good :)

13:34 technomancy: sdegutis: I think the "less reliance on fancy stuff" is just something that happens naturally as you get older. =)

13:36 gfredericks: talk to your doctor about using functions and data

13:36 technomancy: side-effects may include side-effects.

13:36 Glenjamin: that sponge trick is a neat one

13:36 hyPiRion: technomancy: I don't think it has anything to do with age, but rather with experience. Perhaps that's what you meant, but I don't want to think I have to be older to be better at something

13:37 technomancy: hyPiRion: I've noticed a correlation with being cranky and jaded but of course no causation implied. =)

13:37 hyPiRion: hehe

13:40 sdegutis: technomancy: LLOL

13:40 (literal lol)

13:41 about side effects

13:45 sorbo_: what's the best way to write a leiningen alias that executes two tasks (i.e. the equivalent of lein cljsbuild clean && lein cljsbuild once)?

13:45 technomancy: sorbo_: `lein help do`

13:46 hyPiRion: sorbo_: :alias {"my-alias" ["do" ["cljsbuild" "clean"] ["cljsbuild" "once"]]}

13:46 sorbo_: @technomancy perfect, thanks—I'd seen the "do" syntax in an example, but didn't realize there was a separate lein invocation

13:46 technomancy: thanks!

13:46 technomancy: np

13:46 sorbo_: hyPiRion: ditto, thanks!

13:47 hyPiRion: yw

13:52 cemerick: tcrawley: True to form :-D

13:55 TimMc: `lein let t clean do t t`

13:56 Looking forward to lein having a full stack-based language for its argument syntax.

13:57 technomancy: TimMc: there is a half-finished "lein-ski" plugin in my ~/src

13:58 hiredman: port line lein's bash script to stack https://github.com/hiredman/stack/blob/master/foo.stack https://github.com/hiredman/stack/blob/master/stack2.sh

13:58 ystael: brb, writing a leiningen driver program for commodore 64

13:59 arrdem: no way you can start a jvm on a c64...

13:59 let alone a Clojure instance

13:59 amalloy: it'll be a virtual java virtual machine

14:00 arrdem: network jvm client? :P

14:00 ystael: arrdem: nah, the driver's just going to be a tiny Forth interpreter that translates the stack based lein command line syntax into a real script and emits it over the serial port

14:00 sdegutis: We are about to have no multi-methods, no protocols or interfaces, nothing but functions (and a few alter-var-roots for initialization).

14:00 arrdem: ystael: hehe

14:00 ystael: writing actual lein command lines in 6502 assembly is an exercise for the reader

14:01 adsisco: how do i turn [1 2 3 4] into [[1 2][3 4]] ?

14:01 amalloy: &(partition 2 (range 1 5))

14:01 lazybot: ⇒ ((1 2) (3 4))

14:01 technomancy: we should rename *read-eval* to *exercise-for-the-reader*

14:01 ystael: technomancy: ha

14:01 * arrdem votes aye

14:03 adsisco: amalloy: thanks!

14:09 arrdem: ew. Okay. so since the root of a var is volatile the JIT can never inline through it, right?

14:10 sdegutis: I wish you could do destructuring in conjunction with def.

14:10 I have some keys of a map that I want to put directly into this namespace.

14:10 arrdem: sdegutis: defn totally allows for param destructuring..

14:11 jcromartie: sdegutis: interesting idea

14:11 sdegutis: I basically have (def name (:name config))

14:11 Using destructuring with let would actually make it harder, since there would be shadowing.

14:11 gfredericks: sdegutis: https://github.com/fredericksgary/lib-4395 (defs-keys)

14:12 sdegutis: Oh boy.

14:12 Yep, macro time.

14:12 gfredericks: I may copy that.

14:12 Verbatim.

14:14 gfredericks: would a def-utils library be useful?

14:14 sdegutis: I think Clojure will be part of our homeschool curricula.

14:14 gfredericks: hard to say

14:14 amalloy: gfredericks: it'd just be a README, saying "dude, you don't need a million special kinds of def"

14:14 jcromartie: :)

14:15 gfredericks: deftwice

14:15 arrdem: lolwut

14:15 better def it again just to be sure...

14:15 gfredericks: "Like defonce, but also works the second time."

14:15 amalloy: anyway, clojure.tools.macro already has the one def-util you need, name-with-attributes

14:15 jcromartie: (inc gfredericks)

14:15 lazybot: ⇒ 61

14:16 gfredericks: I wonder how much of this karma is joke-related

14:16 amalloy: gfredericks: you could use def-utils to create def<nth> for all n up to some reasonable number

14:16 gfredericks: amalloy: and use my library forty-two to make english variants

14:17 amalloy: (def-one-hundred-eighty-eight-times foo 1)

14:18 gfredericks: no more implementing that one in every other project

14:18 amalloy: hah

14:19 gfredericks: ,(defmacro def...? [name & args] (if (zero? (rand-int 2)) `(def ~name ~@args) `(def ~name)))

14:19 clojurebot: #'sandbox/def...?

14:19 gfredericks: ,(def...? foo 42)

14:19 clojurebot: #'sandbox/foo

14:19 gfredericks: ,foo

14:19 clojurebot: 42

14:19 gfredericks: ,(def...? bar 43)

14:19 clojurebot: #'sandbox/bar

14:19 gfredericks: ,bar

14:19 clojurebot: #<Unbound Unbound: #'sandbox/bar>

14:19 gfredericks: w00t

14:20 clojure should have antiprivate vars that can only be used from other namespaces

14:20 hyPiRion: gfredericks: sadly that one only works compile-time, so an AOT uberjared version would return the same result all the time, right?

14:20 tcrawley: cemerick: glad I could help

14:21 amalloy: hyPiRion: easily fixed

14:21 dbasch: I want a macro called deface that works just like defn, except it introduces random bugs you can’t know until you try

14:21 sdegutis: Clojure's got so much indirection with these vars.

14:21 I sometimes wish there were no vars.

14:21 amalloy: (defmacro def...? [name & args] `(when (zero? (rand-int 2)) (def ~name ~@args))) works, i think

14:22 gfredericks: ,(defmacro definitely [name val] `(def ~name (try ~val (catch Throwable t# :no-sweat))))

14:22 clojurebot: gfredericks: Titim gan éirí ort.

14:22 gfredericks: clojurebot: whatever dude

14:22 clojurebot: It's greek to me.

14:23 llasram: clojurebot: Would it be so difficult to jut mumble *something* about exceptions?

14:23 clojurebot: Cool story bro.

14:23 gfredericks: ,(defmacro definitely-not [& args])

14:23 clojurebot: #'sandbox/definitely-not

14:23 llasram: niiiice

14:23 (inc gfredericks)

14:23 lazybot: ⇒ 62

14:24 gfredericks: see this library needs to exist

14:24 we just need a good pun for the name

14:24 amalloy: gfredericks: so misleading! (definitely-not (even? 2)) will make readers of my code think that math is broken

14:25 gfredericks: amalloy: what kind of weirdo gullible people do you get to read your code

14:25 amalloy: compilers are more gullible than any human being

14:25 gfredericks: ,(def three 4)

14:26 clojurebot: #'sandbox/three

14:26 gfredericks: lol he just believed me

14:26 amalloy: (def largest-prime 85) ;; sure, okay

14:26 gfredericks: ,(def _ "underscore")

14:26 clojurebot: #'sandbox/_

14:26 llasram: clojurebot is a he?

14:27 amalloy: gfredericks: were you around when i broke clojurebot by redefining 5 to be 2?

14:27 * llasram would like to see that...

14:28 amalloy: llasram: it's not super-hard. you use reflection to modify the .value field of (Long/valueOf 5)

14:28 technomancy: isn't this something we make fun of ruby for making possible?

14:28 I'll have to update my Tome of Mockery

14:31 llasram: amalloy: Ah. Yeah, ok. IMHO using reflection to stomp on private final (I assume?) fields is basically the same as memcpy()ing

14:31 So I'm somewhat less impressed :-)

14:31 gfredericks: amalloy: no way that's nutso

14:32 TimMc: :-(

14:32 gfredericks: Tim does not like it

14:36 llasram: Well, unless someone re-defined TimMc's smiley face to use ":-("

14:37 At this point we have no real way of knowing

14:39 hyPiRion: It's hard to know anything when everything is relative and changing.

14:41 gfredericks: except the undeniable objective fact that it's hard to know anything when everything is relative and changing

14:42 TimMc: amalloy: How's that?

14:43 amalloy: how's what?

14:43 TimMc: I did (.setAccessible (.getDeclaredField Long "value") true) but then this errors: (.setLong (.getDeclaredField Long "value") 5 2)

14:43 hyPiRion: gfredericks: but then it's not hard to know anything, it's hard to know anything with the exception of that statement

14:43 amalloy: TimMc: setAccessible mutates the Field object you have. you can't re-get the Field object

14:43 TimMc: Oh! Point.

14:44 amalloy: (doto (.getDeclaredField Long "value") (.setAccessible true) (.setLong 5 2)) or something

14:44 ystael: amalloy: does that break just one five or all the fives?

14:44 amalloy: all the (boxed) fives

14:44 llasram: Oh, language

14:44 amalloy: and since clojure boxes everything, that's all of them

14:44 TimMc: ,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject 2) subject)

14:44 clojurebot: 2

14:45 TimMc: D-:

14:45 hyPiRion: amalloy: not all the boxed fives?

14:45 amalloy: TimMc: ugh, don't do it to clojurebot again

14:45 llasram: ,(+ 5 5)

14:45 clojurebot: 4

14:45 hyPiRion: ,(Long. "5")

14:45 clojurebot: 5

14:45 TimMc: oops

14:45 amalloy: hyPiRion: true. all the ones boxed via Long/valueOf

14:45 TimMc: I should have use a bigger 5.

14:45 arrdem: ,(+ 2 2)

14:45 clojurebot: 4

14:45 arrdem: ,(+ 5 5)

14:45 clojurebot: 4

14:45 ystael: is there a numerical threshold above which boxed instances are not cached and shared?

14:45 jcromartie: wow, nice

14:46 TimMc: ,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject 5) subject) ;; fixed?

14:46 clojurebot: 2

14:46 hyPiRion: ystael: 128 or 256 I think

14:46 llasram: ,(+ 5 5)

14:46 clojurebot: 4

14:46 amalloy: ystael: +/- 128

14:46 TimMc: hahaha

14:46 amalloy: well, -128 to 127

14:46 llasram: ,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject (Long. "5") subject))

14:46 clojurebot: #<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: setLong for class java.lang.reflect.Field>

14:46 arrdem: http://i0.kym-cdn.com/photos/images/newsfeed/000/613/012/2fa.gif

14:47 hyPiRion: TimMc: You have seen nothing yet

14:47 llasram: ,(let [f (.getDeclaredField Long "value"), subject 5] (.setAccessible f true) (.setLong f subject (Long. "5")) subject)

14:47 clojurebot: 5

14:47 TimMc: It restarts every 12 minutes, right?

14:47 llasram: ,(+ 5 5)

14:47 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

14:47 TimMc: And by 12, I mean 12.

14:47 llasram: Hmm

14:47 amalloy: llasram: that's the way i tried to fix it the first time

14:47 but you made the same mistake i did

14:47 instead of defining 5 back to 5, you defined 2 to 5

14:48 llasram: Oh, right

14:48 hah!

14:48 hyPiRion: hahah

14:48 amalloy: so now like every array access breaks

14:48 TimMc: I <3 FORTRAN.

14:48 amalloy: we never did find out if clojurebot's auto-restart actually fixes this problem

14:48 llasram: *amazing*

14:48 amalloy: hiredman gave it a manual hard-reset before waiting for that

14:48 arrdem: amalloy: one way to find out...

14:50 TimMc: ,(let [f (.getDeclaredField Long "value"), subject 0] (.setAccessible f true) (.setLong f subject 42) subject) ;; if it will even run...

14:50 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

14:50 TimMc: ,(.getDeclaredField Long "value")

14:50 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

14:51 TimMc: Amazing.

14:51 amalloy: TimMc: right, it's too late i think. you can no longer eval anything

14:51 dans: do most people really work with plain SQL migrations for big projects? nothing that generates SQL from some models defined in some clojure data structure?

14:51 amalloy: because eval uses the number 2 in an array somewhere

14:51 ,1

14:51 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

14:51 TimMc: Got it.

14:51 arrdem: hahaha

14:51 hyPiRion: ,'1

14:51 clojurebot: #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>

14:51 arrdem: (inc TimMc)

14:51 lazybot: ⇒ 58

14:51 TimMc: Only 28 points!

14:52 I thought I had more.

14:52 hyPiRion: TimMc: well, since 2 is 5 and 5 is 2

14:53 gfredericks: wait we can prove a contradiction with this right? and then derive anything?

14:53 let's derive bugfixes

14:53 arrdem: gfredericks: quick prove P!=NP then we can keep our jobs forever

14:53 TimMc: amalloy: Do you know any way to get ahold of that interned 5?

14:53 ystael: TimMc: it's no longer a number ... it's a free man now

14:54 amalloy: TimMc: what do you mean?

14:54 gfredericks: arrdem: or P = NP but only for galactic algorithms

14:54 TimMc: Well, I'm trying to restore my REPL's notion of small numbers.

14:54 arrdem: gfredericks: this is also an acceptable outcome.

14:55 amalloy: i don't think you can do it if you've gone to the second level of broken like llasram did

14:55 but if you've only broken it one level, it is reversible

14:55 TimMc: Just one level of fail.

14:56 amalloy: iirc this works: (let [five (long (int (+ (int 1) (int 4)))), field (nth (.getDeclaredFields Long) 3)] (.setAccessible field true) (.set field five (int (+ (int 1) (int 4)))))

14:56 TimMc: I'm having trouble figuring out what's going on here: https://www.refheap.com/85696

14:57 amalloy: fiddling with (Long. "5") doesn't help, because that's not the interned version

14:57 TimMc: Oh! Right-o.

14:57 llasram: Wouldn't (Long/valueOf "5") work? Or does the compiler do funny things?

14:58 amalloy: &(identical? (Long/valueOf "5") 5)

14:58 lazybot: ⇒ false

14:58 llasram: Oh, interesting

14:58 amalloy: &(identical? (Long/valueOf 5) 5)

14:58 lazybot: ⇒ true

14:58 llasram: That makes sense of course

14:58 amalloy: i don't know *why*, but apparently the string version bypasses interning

14:59 llasram: does it? it should parse it as a long, then use the intern cache to get a Long

14:59 TimMc: valueOf probably just shortcuts, right?

15:00 amalloy: incidentally, three cheers for repl history: i just searched it for setAccessible to find this fix; i probably wouldn't have remembered it on my own

15:01 llasram: amalloy: Eh. It's not really clear to me why it should use the cache for the result of string parsing. Not saying it shouldn't -- it just doesn't seem unreasonable for it to not

15:01 hyPiRion: TimMc: Oh hey, if you find this sort of stuff funny, you should see this one: https://www.refheap.com/85697

15:01 That one segfaults or makes your JVM spin up an infinite loop

15:02 amalloy: hyPiRion: do you really have to remove its FINAL modifier? once you make it accessible i think you can already write to it

15:02 just like for Long

15:03 maybe you're doing something weird i don't see there

15:04 hyPiRion: amalloy: it's static, which makes it a bit different IIRC

15:05 at least I just checked, and it doesn't work with just .setAccessible

15:05 TimMc: ,(+(*)(*)(*)(*)(*))

15:05 clojurebot: 5

15:05 TimMc: It's back!

15:06 llasram: ,(+ 5 5)

15:06 clojurebot: 10

15:06 llasram: Yay!

15:12 TimMc: amalloy: I was able to fix it in my REPL by using "subject (+ 2 3)", but when I tried again with "subject 5" nREPL quit with an NPE. :-P

15:12 ystael: When building a custom coercion matcher in Prismatic/schema, if I'm trying to coerce into a multi-level record structure, it's supposed to recurse into coercing into the sub-schemas automatically, right?

15:12 amalloy: TimMc: my suggested fix didn't work?

15:13 TimMc: I didn't try it, since I was able to fix it a different way.

15:14 "Bye for now!" https://www.refheap.com/85699

15:15 sdegutis: Related: https://medium.com/message/81e5f33a24e1

15:15 amalloy: TimMc: yeah, that's setting 2 to 5 again

15:16 which really is a lot more disruptive than setting 5 to 2

15:17 KeithPM: gfredericks: I just finished digesting the DP code you shared this morning. Surgery over now :) Thanks

15:18 TravisD: I'm curious about the DP code now.

15:18 KeithPM: LOL… (defn fib [n] (get (reduce (fn [memo n] (assoc memo n (+ (memo (dec n)) (memo (- n 2))))) {0 1N 1 1N} (range 2 (inc n))) n))

15:19 I changed his m to memo… the 'm' was confusing me :)

15:19 I was seeking a way to use a map to store computed values

15:19 amalloy: KeithPM: and having n and m doesn't confuse you?

15:20 TravisD: Ah, so it stores the solutions in a dictionary and then if you ever need to recompute it, you can just look it up in the dictionary

15:20 ?

15:20 TimMc: amalloy: Ah, OK. Makes sense.

15:20 sdegutis: Good quotes in there.

15:20 KeithPM: No… Actually I think of m and n as integer types… I was struggling OK? :)

15:21 TravisD: Yes that is the idea.

15:21 TravisD: cool :)

15:27 sdegutis: I'm reminded of that article that says the Clojure software ecosystem has no security baked in.

15:28 dbasch: sdegutis: in what context?

15:29 security is not really something you can have “baked in"

15:30 jcromartie: sdegutis: what does that even mean?

15:31 benmoss: https://hackworth.be/2014/03/26/clojure-web-security-is-worse-than-you-think/

15:31 jcromartie: Clojure web security is exactly what I think.

15:31 benmoss: maybe you should ask the author to update his blog post

15:32 dbasch: agree with jcromartie

15:32 jcromartie: it's only "worse than you think" if what you think is "well I just wrote a networked service, I hope it's secure"

15:33 dbasch: and that’s the same in any language / platform really

15:33 jcromartie: like the Ruby secureheaders gem example… a library introduced in Jan 2013

15:34 dbasch: what would be useful is a reference with best practices for writing relatively secure clojure apps

15:34 jcromartie: or just hit up OWASP and educate yourself

15:35 then you'll be prepared to reason about potential security problems of any web app

15:35 dbasch: what I mean is, here are a few libraries that are relatively battle-tested in clojure, and here’s how to use them

15:36 of course you should reason about the problems of apps first, the question is when you get to the point of

15:36 sdegutis: No computer is secure. Some are far worse.

15:36 technomancy: relevant https://medium.com/message/81e5f33a24e1

15:36 dbasch: “I need to build a password db, should I roll my own or is there a library that works reasonably well?”

15:37 nullptr: and remember, if you do an absolutely perfect job of web security in your application, someone can still sniff your server memory if your ssl vendor has a bug...

15:41 jcromartie: "perfect security" is basically the halting problem

15:42 if you're talking about depending on some other code to make your app secure at least

15:43 dbasch: in most contexts security is relative, e.g. nobody wants to be the app that got hacked and had to tell everyone to change their passwords everywhere because they were crappily hashed

15:43 lemonodor: i used to work with guys who did DRM for movie studios, they only browsed the web via BSD VMs they generated fresh every day. “it would cost someone $50K to buy a zero-day and target us, and we know it’s worth a lot more than that to them.”

15:44 jcromartie: lol DRM

15:46 llasram: jcromartie: Did you see this when it was making the rounds? https://plus.google.com/+IanHickson/posts/iPmatxBYuj2

15:47 jcromartie: yes

15:47 dbasch: llasram: that came to mind too

15:47 llasram: I'd actually wondered for a while what was up with the total non-response on breakage in e-book DRM. That article seems spot on, at least for that instance, and stopped my lols :-(

15:48 mdrogalis: cemerick: ping

15:48 storme: ,(for [x (range 0 3) y (range 0 2)] { :x x :y y })

15:48 cemerick: mdrogalis: pong

15:48 clojurebot: ({:x 0, :y 0} {:x 0, :y 1} {:x 1, :y 0} {:x 1, :y 1} {:x 2, :y 0} ...)

15:48 jcromartie: yeah, nobody cares about DRM

15:49 mdrogalis: cemerick: Is there a trick for using Austin in applications where browser-connected-repl-js can't come from the server?

15:49 jcromartie: like I don't believe for one second that anybody would even care to pay for a solution to movie studio DRM

15:49 they get it every other way you can think of

15:49 mdrogalis: Reading old IRC logs. Looks like setting up an endpoint just for that is what people are doing.

15:49 jcromartie: anyway </off-topic>

15:49 lemonodor: that post is somewhat correct. the incentives are definitely misaligned between, say, studios & player manufacturers. but the studios do care about their DRM getting cracked—though they only care that it holds up for about 30 days pas the street date.

15:51 jcromartie: there are offshore businesses making lots of money from subscription blu-ray pirating software.

15:51 jcromartie: interesting

15:51 storme: My big-o notation isn't the best, and I'm still new to Clojure... what would be the best way to turn ,(for [x (range 0 3) y (range 0 2)] { :x x :y y }) from O(n^2) to O(1)?

15:52 cemerick: mdrogalis: Nothing in Austin. People have hacked various ways to inject the necessary JS when they want. I think someone was working on a chrome extension to do roughly that.

15:52 llasram: storme: mu

15:52 storme: llasram, mu?

15:52 cbp: mooo

15:53 mdrogalis: cemerick: Interesting. Okay, thanks.

15:54 llasram: storme: Un-ask the question :-) Enumerating all those maps is necessarily linear w/ the number of maps you wish to emit

15:55 bgilbert: Hey guys, quick question.....does anyone know how to use apply with javascript interop in cljs?

15:55 storme: llasram, Ah, so there isn't anything that can be done about it?

15:55 bgilbert: I'm looking for something like: (apply (.foo bar) [1 2 3])

15:56 would be rewrite to: foo.bar(1,2,3)

15:56 llasram: storme: Not unless I've misunderstood what you're trying to achieve

15:56 bgilbert: I guess this question would extend to java interop as well

15:56 turbofail: well in java interop you basically can't do it

15:57 jcromartie: I've done it in cljs

15:57 turbofail: with CLJS you should be able to arrange to call the .apply method

15:57 llasram: bgilbert: well, there's slightly different solutions depending on whether the .bar method is a Java varargs method

15:57 oh, javascript

15:57 la la la

15:57 bgilbert: ah, well I'm primarily looking for the answer in js

15:57 ya

15:58 ghadishayban: what turbofail said, make the seq a js array and call js's .apply

15:58 bgilbert: turbofail: ah duh, thanks :)

16:07 Rockdtben: Hey all

16:08 Is there a way to output the code I wrote in the repl to a text file?

16:12 llasram: Rockdtben: Not as a built-in general solution, no. If you're using a REPL which saves history, you can find the history file

16:14 amalloy: storme: i mean, you want to create n^2 maps. assuming that creating a map takes constant (non-zero) time, you can't help having an n^2 solution

16:15 and if it takes more than constant time, then you can only get worse

16:16 storme: amalloy: I was under the same impression but wanted to be sure given I don't come from a CS background. Thank you!

16:19 stw: Rockdtben: if you use cider in emacs you can write the history to a file

16:19 Rockdtben: (setq cider-repl-history-file "path/to/file")

16:23 Rockdtben: llasram: Thanks

16:25 stw: Alright

16:25 Fare: hi. Is there a python parser in clojure?

16:26 tuft: Fare: don't think so, but there is jython

16:27 Fare: you could probably use their parser

16:27 Fare: tuft: that's an interesting thought

16:27 thanks

16:32 michaelr525: hi

16:32 should I build checkouts the first time before running 'lein repl' or 'lein run' in the parent project?

16:33 lein doesn't currently find the checkouts artifacts

16:33 technomancy: michaelr525: sounds like you're a bit confused about what checkouts are for

16:34 they don't replace regular dependencies

16:34 michaelr525: i've added them under :dependencies in project.clj

16:35 linked as instructed under /checkouts

16:35 and ran 'lein run'

16:36 technomancy: sounds like the lib isn't declaring its deps correctly then

16:36 llasram: Well, michaelr525 -- what specific issue are you seeing?

16:37 technomancy's psychic powers are pretty good especially about Leiningen, but you never know :-)

16:37 michaelr525: Could not find artifact..

16:37 hmm.. i think the last thing technomancy said maybe

16:37 technomancy: michaelr525: yeah, that is unrelated to checkouts

16:38 noncom|2: i'm trying emacs live, but when i jack-in into the simplest project created by lein, there is no "core" ns seen from the repl, what's wrong?

16:38 llasram: michaelr525: Has the checkout-dependency project never been deployed anyway, and exists only as a checkout dependency?

16:38 michaelr525: llasram: yes

16:39 llasram: I believe that is unsupported, and you need to at least `lein install` the dependency so that *some* artifact is present to keep the aether bits happy

16:40 michaelr525: llasram: ah, that's just what I suspected is happening

16:40 let me try that out

16:41 yes, that solved the problem..

16:41 thanks :)

16:41 llasram: np

16:42 tolstoy: noncom|2: No idea if this is helpful, but if you've got one of the project files loaded in the buffer and have that buffer in focus, then call jack-in, it should work.

16:42 noncom|2: tolstoy: yeah, that's what it should be, but..

16:43 michaelr525: llasram: btw, which plugin would you recommend for building checkouts?

16:43 amalloy: michaelr525: fwiw, the reason you need to do this is that checkout dependencies only "replace" source files. the pom files, dependencies, all that stuff, needs to exist for real

16:43 tolstoy: noncom|2: Not that I use Emacs Live, so I don't know.

16:43 llasram: michaelr525: I have no such recommendation :-)

16:43 michaelr525: heh

16:43 oh btw guys, are you using smartparens or paredit?

16:44 llasram: <3 paredit

16:44 amalloy: paredit

16:45 Fare: if I wanted to write a parser for python syntax, which clojure tools would be best suited?

16:45 amalloy: i read smartparen's readme a while ago, and i recall it being kinda like a version of paredit that has one or two of the best features disabled by default

16:45 jcromartie: instaparse

16:45 Fare: jcromartie, thanks!

16:45 michaelr525: oh really?

16:46 whomp: is there a literal for a sequence, or do i have to use something like (seq [1 2])?

16:46 to get (1 2)

16:46 seancorfield: why not just [1 2]?

16:46 tolstoy: '(1 2)

16:47 seancorfield: (i.e., why do you specifically need it to not be a vector? or '(1 2) for a list?)

16:47 whomp: just wondering

16:47 amalloy: michaelr525: https://github.com/Fuco1/smartparens/wiki/Paredit-and-smartparens#random-differences reads to me as like...a radioactive disaster. why would you turn all this important stuff off?

16:48 technomancy: amalloy: yeah I don't get that at all

16:50 whomp: ah thx i get it now :)

16:51 michaelr525: I'm still getting myself fluent on paredit

16:51 I wonder if I can detach this ERC buffer to a separate window?

16:52 nullptr: michaelr525: M-x make-frame

16:53 michaelr525: haha it worked! thanks nullptr :)

16:53 now I know that it's the same buffer in both frames ;)

16:54 nullptr: heh, figured :)

16:54 fortunately these are lessons you only need to learn once and they apply to other buffers equally

16:54 (inc emacs)

16:54 lazybot: ⇒ 3

17:09 noncom|2: so why could cider fail to determine that the current buffer is a part of a lein project?

17:10 gtrak: how does cider know if a buffer is part of a lein project?

17:10 (I'm pretty sure it just recurses up dir parents until it finds a project.clj)

17:11 when you do cider-jack-in, but I'm not sure if it uses that technique for anything else.

17:11 noncom|2: right, that's what lein is supposed to do i think

17:11 but from the emacs live doc: "Project discovery is made possible because each buffer has a buffer-local variable named default-directory which stores the directory the file associated with the buffer is located within."

17:11 so maybe the buffers "buffer-local" variable is damaged?

17:11 how can i check for it?

17:11 gtrak: what's emacs live got to do with it?

17:12 noncom|2: emacs live uses cider

17:12 gtrak: what relies on this?

17:13 noncom|2: well, emacs live fully relies on cider for clojure repling, and that is what the documentation emphasizes

17:13 gtrak: err, I mean the variable specifically

17:13 noncom|2: idk, i am a emacs newb

17:14 arrdem: Bronsa`: question about locals metadata if you've got a minute

17:14 Bronsa`: sure

17:14 noncom|2: i guess that the variable "buffer-local" is common for emacs buffers to specify filesystem location of buffer contents if the buffer contains an open file

17:15 arrdem: Bronsa: (->> (clojure.tools.analyzer.jvm.core-test/ast (defn alter-var-root [^clojure.lang.Var v f & args] (.alterRoot v f args))) :init :methods first :body :ret :target :form meta) => nil. wat.

17:15 noncom|2: and that cider relies on it to know where from the repl start was issued

17:15 and passes the dir to lein and then you know what should happen

17:15 gtrak: let me say it another way, how do you know it's broken?

17:15 noncom|2: but apparently something is broken

17:15 bbloom: Bronsa: have you started on the js analyzer? or are you just about to?

17:16 noncom|2: i am not sure that the variable is broken since idk how to verify this assumption. so it is just an assumption. the main symptome that i suffer from is that the launched repl is fully unaware of the project namespaces

17:16 and when i go (ns my-project.core) it creates a new one, empty one

17:16 Bronsa: arrdem: well, "v" in "(.alterRoot v f args)" has no meta, :form just contains the original symbol

17:17 gtrak: noncom|2: sounds like just the parent-search thing is what's broken.

17:17 ie lein is starting up the default project.

17:17 which is not a project

17:17 noncom|2: yeah, with just the user virtual ns.. so likely.. but this emacs setup is out-of-the-box, how can it be broken?

17:18 emacs live is pretty popular

17:18 arrdem: Bronsa: sure, but it was my understanding (which apparently is wrong) that the same symbol object was used for "v" as an arg and here as a lvalue. So really the type hint exists only on the arg instance?

17:18 Bronsa: bbloom: I started working on it today, Alex created the repo a few hours ago https://github.com/clojure/tools.analyzer.js

17:18 bbloom: Bronsa: saw that, that's why i asked

17:18 Bronsa: cool stuff. i know the cljs analyzer pretty well, so let me know if you find yourself head scratching. happy to help :-)

17:18 Bronsa: bbloom: yeah I'm going to start pushing working code in a day or two

17:19 bbloom: oh, thanks!

17:19 gtrak: Bronsa: when can I start relying on it in cider ;-)

17:20 Bronsa: arrdem: right, internally in tools.analyzer I use an atom to share that info between the :binding node and the :local nodes

17:20 gtrak: I'll let you know :)

17:20 noncom|2: gtrak: so don't you have soe ideas on where to look to fix the problem?

17:21 gtrak: noncom|2: yea, not sure, I'd try running lein and narrowing down stuff.

17:21 noncom|2: you mean lein from the OS?

17:21 gtrak: doesn't sound like anything that's cider's fault.

17:21 yea

17:21 noncom|2: but emacs is an os!

17:21 hah :)

17:21 joke

17:21 gtrak: it just needs an editor!

17:21 noncom|2: yeah :)

17:22 Bronsa: arrdem: you'll see that (-> ast :init :methods first :body :ret :target :tag) will be clojure.lang.Var as you'd expect

17:23 arrdem: using ast1 at least. ast doesn't run any of the passes

17:23 technomancy: noncom|2: creating a new empty ns when you run (ns myproject.core) is totally normal behaviour

17:23 noncom|2: gtrak: you're right, running from the host OS gives the same result

17:23 gtrak: welp

17:23 arrdem: Bronsa: something's fishy... that's nil for me.

17:24 Frozenlock: Is there any plan to add -?> to clojure?

17:24 noncom|2: technomancy: but not when it is claimed that the repl session is guaranteed to start within the project...? or am i mistaken...?

17:24 technomancy: noncom|2: starting a repl session in the project just means you can require project code and dependencies

17:24 gtrak: Frozenlock: I think that's what some-> does

17:24 technomancy: it doesn't mean that it will require them for you

17:25 Frozenlock: gtrak: It is! Thanks!

17:25 noncom|2: technomancy: oh, i see..... so i have to (require) them..

17:26 Bronsa: arrdem: oh, it's :instance, not :target

17:26 arrdem: (->> (clojure.tools.analyzer.jvm.core-test/ast1 (defn alter-var-root [^clojure.lang.Var v f & args] (.alterRoot v f args))) :init :methods first :body :ret :instance :tag)

17:27 Frozenlock: ,(:added (meta #'some->))

17:27 clojurebot: "1.5"

17:27 noncom|2: just got too used to counterclockwise i guess.. strange... why does then ccw preloads all namespaces so they are already registered within the runtime.. ?

17:27 Frozenlock: Dang, how did I miss that.

17:27 Bronsa: arrdem: don't use the bare tools.analyzer `analyze`, always use tools.analyzer.jvm's `analyze` since you'll need all the passes.

17:27 arrdem: Bronsa: yeah that one bit me yesterday.

17:27 mmitchell: is there a fn to create a record from a map, but without knowing the record type until runtime?

17:28 michaelr525: tools.analyzer, how do you use it?

17:28 gtrak: mmitchell: what?

17:28 you can dynamically pass constructors as functions..

17:28 there's a ->MyRecord function generated.

17:28 mmitchell: ha, did that not make sense? :)

17:28 arrdem: woah where'd ast1 come from..

17:28 Bronsa: arrdem: also in this case :target becomes :instance a pass in taj transforms the host-agnostic :host-call node in the jvm specific :instance-call

17:29 arrdem: https://github.com/clojure/tools.analyzer.jvm/blob/master/src/test/clojure/clojure/tools/analyzer/jvm/core_test.clj#L18

17:29 mmitchell: gtrak: ahh ok right

17:29 gtrak: and map->MyRecord as well, that's probably more appropriate here.

17:29 arrdem: Bronsa: herp a derp. thanks.

17:30 Bronsa: arrdem: np. I know at first some differences between calling ta/analyze vs taj/analyze might be confusing, but they actually make sense :)

17:30 arrdem: Bronsa: sure. suggestions for pattern matching AST subtrees? I'm currently playing with var taint detection through blacklisting a few symbols and Var.set/Var.alter

17:32 Bronsa: arrdem: well, there's the datomic datalog interface that's pretty neat.. https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer/ast/query.clj

17:32 arrdem: I gotta write a link rewriter so that just opens my emacs buffer :P

17:33 Bronsa: arrdem: though unfortunately I don't think you could make datomic a dependency for contrib libs :/

17:34 arrdem: Bronsa: I'd agree with that, which is unfortunate because I think my "whole program AST" thing is gonna wind up looking freakishly like a Datomic db with symbol -> ast mappings .-.

17:34 hum. excuse for me to learn datalog.... taken.

17:36 Bronsa: awesome. thanks for the help.

18:07 ToxicFrog: Say I'm using core.typed. Can I do runtime type checking with it, and if so, can I use that type checking to impose certain constraints on values?

18:08 E.g. I have a type defined that is a map with exactly a certain set of keys; can I add the additional constraint that some of the values fall within a given set, and check that, e.g., structures read from EDN satisfy that constraint?

18:09 arrdem: ToxicFrog: ambrosebs would appear to be offline, but I think the answer is no. core.typed does static checking, you want schema to do complex dynamic checks.

18:09 $google prismatic schema

18:09 lazybot: [Prismatic/schema · GitHub] https://github.com/Prismatic/schema

18:10 arrdem: ToxicFrog: you can use static checks to prove the consistency of your own code wrt those data constraints, but to impose them on read or sourced values you need to do schema equivalent checking.

18:10 ToxicFrog: Alright, thanks.

18:11 The c.t docs talk about "tags" (runtime types) vs "types" (static types) and it's unclear whether it also supports runtime "tag checking"

18:11 ...huh. I think I've broken core.typed, or possibly lein-typed.

18:12 'lein typed check' vomits out lots of duplicate 'start collecting <namespace>' messages interspersed with nils and then says 'found errors' without reporting any errors.

18:12 'lein typed coverage' straight up crashes.

18:14 numberten: is there a way to filter a collection by 'typeclass'?

18:15 amalloy: numberten: that probably depends on what typeclass means

18:15 numberten: so for example: (filter can-be-added collection)

18:15 returning a collection of things that can be used with the '+' function

18:16 amalloy: those typeclasses don't exist

18:16 you can filter number?, which happens to be the set of things that is addable

18:16 numberten: so (filter can-be-added [1 2 3 :c \a]) giving you [1 2 3]

18:16 amalloy: but in general, for some function f, there's no way to check "is f callable on x"

18:17 numberten: i had a feeling, but I wanted to make sure I wasn't missing out on something

18:17 thank you, that answers my question

18:31 seangrove: Does it make sense to store a tree-structure in datomic, with each node being a datomic 'fact'?

18:32 arrdem: ,(number? \1)

18:32 clojurebot: false

18:33 arrdem: ,(char? \λ)

18:33 clojurebot: true

18:37 whomp: why is (fn [x] [x x]) valid but #([% %]) not?

18:37 hiredman: ,(macroexpand '#([% %]))

18:37 clojurebot: (fn* [p1__73#] ([p1__73# p1__73#]))

18:37 hiredman: ,(macroexpand '(fn [x] [x x]))

18:37 clojurebot: (fn* ([x] [x x]))

18:39 dbasch: seangrove: what is the tree for?

18:39 whomp: hiredman, now my head hurts

18:40 amalloy: hiredman: you don't need to call macroexpand there

18:40 ,'#([% %]) demonstrates the issue as well

18:40 clojurebot: (fn* [p1__122#] ([p1__122# p1__122#]))

18:40 hiredman: oh, right, the reader does the expanding

18:41 whomp: still don't understand

18:41 aperiodic: whomp: the second form expands into (fn [x] ([x x]))

18:41 nullptr: whomp: it's because it's trying to call [x x] as a function

18:41 aperiodic: whomp: can you see the difference?

18:41 nullptr: ,([1 1])

18:41 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: PersistentVector>

18:41 nullptr: ,(vec [1 1])

18:41 clojurebot: [1 1]

18:42 whomp: ah i see, thx :)

18:42 dbasch: this one should be in a faq, I’ve seen it asked several times recently

18:42 nullptr: everybody tries that at least once :)

18:43 dbasch: whomp: #(do [% %]) or #(-> [% %]) will do what you want

18:44 storme: This might be the wrong place to ask, but does anyone know of any companies in the bay area working with Clojure looking to hire?

18:44 nullptr: (map inc [hiredman dbasch])

18:44 arrdem: nullptr: sadly that isn't supported

18:44 nullptr: bah, it's lazy anyways ;)

18:44 dbasch: storme: prismatic for sure

18:45 storme: there’s clojure at Twitter

18:45 arrdem: yelp...

18:45 storme: dbasch: Thanks, I'll check out Prismatic :)

18:54 martinklepsch: beamso, figured out the issue. docker problem

18:54 beamso: okay

18:59 Fare: looks like instaparse has trouble specifically with contextful lexing: either implementing it, or using an external lexer that produces non-characters, is painful.

19:01 arrdem: Fare: yeah instaparse wasn't designed for parsing arbitrary token streams

19:45 seangrove: dbasch: Sorry, what do you mean?

19:45 l1x: storme: yes, i think prismatic is big on clojure and they are hiring

19:46 dbasch: seangrove: what’s your use for a tree in a db

19:47 storme: l1x, Thanks!

19:47 seangrove: dbasch: Storying UI components n children, and being able to walk the tree up or down from a given node

19:47 dbasch: seangrove: how fast do you need that to be?

19:48 i.e. is it for real-time rendering?

19:52 seangrove: dbasch: No, not especially fast - it's for debugging the state of the application. I'm not sold on doing it yet, I was just wondering about the difficulty (and performance) of doing something tree-like in datomic/querying with datalog

19:52 whomp: how do i install incanter? i ran the .dmg for my mac but my repl still can't find it for (require 'incanter.core)

19:53 is cljr the standard?

19:55 l1x: whomp: https://github.com/incanter/incanter/wiki#building-incanter

19:55 i would go with this

19:56 dbasch: l1x, whomp just add the incanter dependencies to your project.clj

20:19 whomp: trying to install cljr by running the jar, and i'm getting this issue: https://gist.github.com/michaeleisel/2bd83c8dc95f188b1262. any ideas?

20:20 amalloy: don't use cljr. just install lein

20:20 whomp: lein is a package manager as well?

20:20 what i was trying to do was install the incanter package so that i could use it in the repl, because running incanter's dmg doesn't seem to have done that

20:20 arrdem: whomp: nope. it's a maven wrapper, and maven is a dependency management system.

20:21 whomp: ok so my main goal here is to install incanter. any ideas on that?

20:21 amalloy: you want to create a lein project, and add incanter to its dependencies

20:21 whomp: (require 'incanter.core) gives an error still after installing the .dmg

20:21 amalloy: don't touch any dmgs, or install anything but lein

20:22 get lein 2.x, not the 1.1.0 that cljr apparently comes with

20:22 whomp: amalloy, i have to always do that? there's no global package management? that seems kind of crazy, considering that there are lots of repls i might use it in - lighttable's, emacs's, the basic one in bash, etc.

20:22 blr: lein is clojure's dependancy management tool whomp

20:23 amalloy: there are other things you can do, but not any you should do. lein encourages repeatable builds, not system-specific installations. and creating a project is not some big difficult task that you should shrink from doing; it takes ten seconds

20:23 blr: you'll be pleasantly surprised how nice to use it is compared to other similar tools you might have used

20:27 whomp: i'll look into it, thx :)

20:33 blr: how I feel every time I go back to my typical work tools http://i.imgur.com/uV2LyXC.png

20:35 beamso: lucky you, in a way.

20:35 blr: beamso: right, it could be worse

20:36 beamso: you could be in visual studio all day every day

20:36 i found it tremendously difficult to try and get a rails job

20:36 blr: beamso: yeah, most jobs in my little city are .Net, which I've done a fair bit of and have no desire to return to

20:36 dbasch: blr: at least it’s not this: http://allenrecruitmentjobs.ie/wp-content/uploads/2013/07/worst-jobs4.jpg

20:37 blr: oh yeah, it's all relative.

20:38 beamso: any chance of covertly rewriting stuff in F#? :)

20:38 amalloy: dbasch: i don't get it. that renders an "Account Suspended" page for me

20:38 beamso: amalloy: it was an image of a very bad plumbing situation

20:38 dbasch: amalloy: it’s an image of a plumber in a flooded bathroom

20:39 pdk`: i like this site

20:39 one link and im already banned

20:39 that's a new record for me

20:42 beamso: i've never seen anyone using f#.

20:43 S11001001: beamso: like, watched them program in it? Or knew someone who uses it?

20:44 beamso: uses it.

20:44 hiredman: I did some euler project problems in f#, and my last laptop had an ugly as sin f# sticker on it I spent a lot of time asking people if they had f# stickers to get

20:44 S11001001: beamso: Hi there.

20:44 beamso: hello!

20:44 S11001001: I use https://github.com/joshcough/f0/tree/master/fsharp/f0/f0 in production.

20:45 beamso: so now you can't say :)

20:46 blr: pity MS has never made asp.net VS project templates for their alternative languages.. always though the uptake of ironruby/python and possibly f# would be higher if they simply did that

20:46 err asp.net mvc rather

20:55 l1x: woo uglier than haskel?

21:16 whomp: why is this so? (= '() [])

21:17 joegallo: seqs have equality semantics

21:17 such that that will work

21:17 it's a feature!

21:17 :)

21:17 ,(= [2 3 4] (map inc [1 2 3]))

21:17 clojurebot: true

21:18 joegallo: which is nice, it would be sortof lame if it were like, OH HO HO, BUT NO, those aren't equal, because you see, the latter thing returns a lazy seq and not a vector

21:18 Frozenlock: ,(= '(#".") [#"."])

21:18 clojurebot: false

21:18 joegallo: now that's different, because regexes do not have equality semantics that make comparing regexes ever be = unless they are identical

21:18 but you knew that ;)

21:19 Frozenlock: they are never equal

21:19 joegallo: (let [a #"."] (= a a))

21:19 ,(let [a #"."] (= a a))

21:19 clojurebot: true

21:19 Frozenlock: They are the same object

21:20 joegallo: did i not just say this?

21:20 Frozenlock: ah, yes, identical -_-

21:20 joegallo: no worries, brother

21:21 mdedetrich: hey guys, im coming to clojure from scala/java land, was wondering if there is a very good book/resource in regards to getting started

21:21 Frozenlock: It's still making me mad that you can't test for equality with regexes. Exactly for stuff like that.

21:21 ,(= [1 2 3 #"."] [1 2 3 #"."])

21:21 clojurebot: false

21:21 amalloy: Frozenlock: you can't test for equality with functions either

21:21 joegallo: heh, yeah

21:22 mdedetrich: i hear good things about "The Joy of Clojure"

21:22 amalloy: it's really pretty similar; regex is conceptually a lot like a function

21:22 mdedetrich: joegallo: thanks, will have a look

21:22 Frozenlock: amalloy: Ah? never tried. Perhaps I should fill a bug :-p

21:22 amalloy: Frozenlock: no way. never going to change

21:22 joegallo: i believe there's a second edition that's like, right about to hit the presses, so make sure you get that, if you can stand the wait

21:23 amalloy: (= inc #(+ 1 %))? testing functions for equality based on anything but reference identity is impossible

21:23 arrdem: amalloy: it may not change in the core compiler :P

21:24 Frozenlock: ,(= #(+ 1 %) #(+ 1 %))

21:24 clojurebot: false

21:25 Frozenlock: That's somehow conterintuitive considering that you can clearly see that they are the same thing. I mean, you could check the symbols and say 'oh, look, it's the same thing'.

21:25 gfredericks: ,(assoc {} #"foo" 12 #"foo" 13)

21:25 clojurebot: {#"foo" 13, #"foo" 12}

21:25 arrdem: Frozenlock: sorta.. the compiler would have to know that + is commutative.

21:25 gfredericks: ololololol

21:25 amalloy: Frozenlock: but you don't even *have* the symbols

21:26 you just have two function objects. they're not even instances of the same class

21:26 gfredericks: Frozenlock: if something can't be done properly almost all of the time, why bother to do it at all?

21:26 Fare: what's the difference between "foo" and #"foo" ? How do I introspect the type of a value?

21:26 gfredericks: Fare: ##(type #"foo")

21:26 lazybot: ⇒ java.util.regex.Pattern

21:26 amalloy: ,(doc type)

21:26 clojurebot: "([x]); Returns the :type metadata of x, or its Class if none"

21:26 Fare: gfredericks, thanks

21:27 Frozenlock: amalloy: But I'm entering something into my repl! This is evaluated somewhere into the functions. Couldn't the equal function look at it before and see that it's the same thing?

21:27 I suppose it would need to be a macro...

21:28 gfredericks: Frozenlock: where do you draw the line before giving up?

21:28 is inc the same as (fn [n] (+ n 17 -16))?

21:29 Frozenlock: I'd say the effect are the same, but the input isn't

21:29 gfredericks: you can put arbitrarily much computational effort into analyzing these things and you still won't cover everything

21:29 arrdem: Frozenlock: you cannot generally prove that two functions compute the same value. Example, solve the halting problem paired with itself or any other universal problem. If this is possible then you can compute infinite results in finite time, congratulations you broke the universe.

21:29 Frozenlock: yeah, that's shame :-p

21:29 gfredericks: you want equality only if the functions look identical in the source code?

21:29 Frozenlock: gfredericks: That would solve the regex, wouldn't it? ;-)

21:29 gfredericks: so (fn [x] x) != (fn [y] y)?

21:30 I think this would confuse the crap out of users

21:30 arrdem: gfredericks: hey you could prove that statically just by doing var renaming.

21:30 gfredericks: yep

21:30 Fare: gfredericks, why did you prefix that with ## ?

21:30 gfredericks: Fare: that's how lazybot knows to evaluate it

21:31 Fare: how do I get a list of methods for that class?

21:32 gfredericks: that is a tricksy question

21:32 at least if you meant what I think you did

21:32 if you meant what you said then the answer is http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html

21:32 Fare: trying to introspect things to discover them

21:33 programmatically, if possible

21:33 gfredericks: but my guess is you want to know what clojure functions you can use it with

21:35 Fare: (use 'clojure.repl) and then check out apropos and find-doc

21:35 you're not going to able to search by class though, since that's not how clojure code is organized

21:36 Fare: I knew about apropos — thanks for find-doc

21:37 Frozenlock: about clojure.repl, is there a way to use it in every namespace?

21:37 (not just in 'user' with lein profile)

21:39 gfredericks: Frozenlock: depends on how you're starting your repl

21:39 oh wait

21:39 we were just discussing this kind of thing a couple days ago

21:40 arrdem: Frozenlock: in _every_ namespace? no there shouldn't be unless you want to create clojure.core/doc and bind it to clojure.repl/doc or whatever.

21:40 gfredericks: the only way to get that kind of magic is to monkey-patch things in to clojure.core, but then you get into sticky situations depending on whether any of your code gets loaded first

21:40 leiningen didn't seem to have much to offer in that department, but a user.clj file should let you do whatever you need to sufficiently early

21:40 just don't tell anybody else that you did it

21:41 Fare: so if I have a server application in java, and I want some request to open a clojure repl for interactive debugging, how do I do that?

21:41 Frozenlock: Interesting

21:41 gfredericks: Fare: a request? like HTTP?

21:41 Frozenlock: living dangerously :)

21:41 arrdem: Fare: you use the nrepl library, drop an nrepl instance on an arbitrary port on an address behind your vpn ideally and pray.

21:41 Fare: what should my request handler do (after proper validation) to start a server that my emacs can connect to?

21:42 yes, it's all properly firewalled, of course

21:42 hopefully, my server should only listen on 127.x.x.x addresses

21:42 gfredericks: yep look at nrepl's start-server function

21:42 blr: Frozenlock: I have :repl {:repl-options {:init (use 'clojure.repl)}} in my lein user profile, but that will only load clojure.repl in the user namespace

21:43 Frozenlock: blr: Yeah, I tend to not stay in that namespace for long.

21:43 blr: agree that it would be nice to have clojure.repl available from any ns though

21:44 arrdem: eh if it's for debugging just monkey patch what you want into core

21:44 * arrdem hates himself

21:44 Frozenlock: getting to use the 'doc' function takes so much time that I just M-. and check the source.

21:45 gfredericks: Frozenlock: if you reload code in emacs frequently you don't have to worry about the load order as much

21:45 that's basically my approach

21:45 Fare: and from the emacs side, how do I initiate connection with localhost 12345 ?

21:46 arrdem: M-x cider-connect

21:46 Frozenlock: M-x nrepl <enter> the addresse

21:46 arrdem: or that

21:46 Fare: can I have several cider connections in the same emacs?

21:47 Frozenlock: Yes, but I find it confusing

21:47 --> switch to the nearest nrepl buffer and .... Noooooo what have I done?!?!

21:48 Fare: Frozenlock, fair point. I can start a separate emacs with a different background color

21:48 but still... how do I tell cider which host and port to connect to?

21:48 Frozenlock: That'd be wise, especially if you connect to your production server's repl

21:48 M-x nrepl <enter> localhost <enter> port (or something like that with cider)

21:49 arrdem: Fare: nrepl/cider will ask you for a port

21:50 Fare: the cider web page suggests M-x cider-connect but that command doesn't look like it exists in my loaded cider

21:50 gfredericks: M-x cider asks for a port

21:50 arrdem: anyone know of codebases which use inline, bare load, use or require?

21:50 * arrdem expects he cannot count on the ns macro

21:51 Fare: oh, so it's M-x cider not M-x cider-connect --- thanks

21:51 maybe the README.md should be updated.

21:51 gfredericks: arrdem: clojure.core?

21:51 Jaood: how do you access the 'doc' commando when you cider repl switches from the user ns?

21:51 gfredericks: Jaood: (use 'clojure.repl)

21:51 arrdem: gfredericks: well yeah they do use raw load...

21:51 Fare: how different is the second edition of the Joy of Clojure ?

21:51 Jaood: gfredericks: thanks

21:53 blr: Fare: more on clojurescript and logic programming from what I understand

21:53 arrdem: blr: no core.typed plug?

21:54 blr: just going by what's here http://www.joyofclojure.com/2nd

21:55 Fare: blr: thanks!

21:55 I just bought the first edition :-/ Now wondering about the second...

21:56 blr: pity books don't have upgrade pricing :)

21:56 arrdem: the first was good, I read it from $UNIVERSITY library. I may get the 2nd.

21:56 blr: you went to php university?

21:56 arrdem: and burned it down after I graduated.

21:56 * blr nods

21:56 * Jaood is still reading Clojure Programming

21:57 Jaood: JoC is a good second book I guess

21:58 Fare: thanks a lot for your support.

22:00 arrdem: ,(macroexpand '(do (ns com.foo) (def bar 3) (ns com.oh-god-why) (def com.foo/bar 5)))

22:00 clojurebot: (do (ns com.foo) (def bar 3) (ns com.oh-god-why) (def com.foo/bar 5))

22:01 arrdem: ,(do (ns com.foo) (def bar 3) (ns com.oh-god-why) (def com.foo/bar 5))

22:01 clojurebot: #<CompilerException java.lang.RuntimeException: Can't create defs outside of current ns, compiling:(NO_SOURCE_PATH:0:0)>

22:09 quizdr: anyone know what the "mies" stands for with some line templates?

22:09 *Lein templates

22:10 beamso: a minimal clojurescript template, apparently

22:10 https://github.com/swannodette/mies

22:10 i can't retrospectively add a template to a project, can i

22:11 quizdr: interesting, how the letters "mies" come from that as an acronym, i don't know

22:12 fortruce: beamso: no, there is no way to merge a template into a project, but you can look at the template and use it to setup your project.clj

22:13 beamso: okay

22:29 zeroem: ,(name (keyword "foo/bar"))

22:29 clojurebot: "bar"

22:29 zeroem: is that expected behavior for keywords?

22:29 gfredericks: yep

22:29 ,(namespace (keyword "foo/bar"))

22:29 clojurebot: "foo"

22:30 zeroem: oh, so keywords are namespaced too

22:30 ok, learned something new

22:30 thanks :)

22:36 blr: the mies templates are named after the architect Ludwig Mies van der Rohe, because "less is more"

22:47 whatever you do, don't lein new gaudí

22:49 andreh: Is there any tutuorial on PrimeFaces with Clojure for someone who already knows Java or Common Lisp?

22:50 blr: andreh: things like JSF are kind of anathema to clj web developers for the most part

22:51 andreh: blr: They normally prefer a Clojure equivalent?

22:52 fortruce: will with-redefs get shadowed by a local let?

22:52 blr: andreh: right, most clojure web apps are composed of discrete libraries, rather than built on frameworks. It's a nice approach, but it does require you to hunt around and take a while to figure out which tools you like

22:53 andreh: blr: nice, thanks

22:53 blr: andreh: Pedestal is the closest thing to a framework, but it doesn't provide much in the way of UI components like JSF https://github.com/pedestal/pedestal

22:54 Luminus is a good way to get a taste for the first approach http://www.luminusweb.net/

22:54 kind of a currated collection of libraries that work well together

22:58 bodie_: does anyone know of a good functional database besides datomic? I can't afford the licensing for the version that doesn't suck

22:59 beamso: functional?

22:59 bodie_: as in datomic

22:59 fortruce: bodie_: pretty sure datomic is the one and only

22:59 bodie_: http://www.infoq.com/presentations/datomic-functional-database beamso

23:00 hrm

23:00 fortruce: bodie_: i haven't tried it yet, you enjoying it?

23:00 bodie_: no, because I can't afford the version that doesn't suck ;)

23:00 so I haven't checked it out any further

23:00 beamso: you could simulate the immutability of that but i think it would take a lot of work

23:01 fortruce: it would basically take recreating datomic ;P

23:01 bodie_: well, it's an implementation of datalog, right

23:02 fortruce: but datalog isn't just for databases

23:02 beamso: actually, i was thinking of the immutable part, not the functional part.

23:03 arrdem: I SOMMON THE MIGHTY INTERTUBEZ. Please help me find Clojure/Java/Haskell/Scala benchmarks :P

23:03 TEttinger: getting an up-to-date one might be challenging, arrdem

23:03 beamso: http://benchmarksgame.alioth.debian.org/

23:03 fortruce: meh, benchmarks

23:03 TEttinger: reducers sped up clojure quite a bit, no?

23:03 bodie_: benchmeh

23:03 arrdem: beamso: that's where I'm looking right now.

23:04 bodie_: maybe I could learn haskell and work from this :P https://github.com/travitch/datalog

23:05 fortruce: anyone know how to use with-redefs to redefine a java ctor?

23:05 dissipate: isn't haskell a heavy syntax language?

23:05 after perl i told myself i would never pursue a heavy syntax language again

23:06 TEttinger: arrdem, no scala here but https://github.com/jafingerhut/clojure-benchmarks

23:06 it has the other 3

23:06 bodie_: dissipate, pretty sure haskell makes perl look like clojure

23:07 but everyone who likes it swears it's easy

23:08 dissipate: bodie_, no haskell for me then. haskell will end up as the new perl.

23:09 amalloy: "haskell will end up as the new perl". literally the first time that sentence has ever been said in the history of english

23:09 TEttinger: haha

23:09 arrdem: glad I'm not the only one chuckling at that

23:09 TEttinger: $google swearjure

23:09 lazybot: [polymatheia - Swearjure - hyPiRion] http://hypirion.com/musings/swearjure

23:10 TEttinger: clojure can be quite perlish

23:10 dissipate: arrdem, you are chuckling because you don't think it is true?

23:11 arrdem: dissipate: the absurdit/irony of the statement more

23:11 bodie_: amalloy, LOL

23:11 TEttinger: ,(#(`[{~% ~@%&}] (+)) \: \[ \? \])

23:11 clojurebot: {\: \[, \? \]}

23:11 bodie_: it's kind of like saying zebras are the new abrams tank

23:12 or potatoes are the new Mt. Everest

23:12 arrdem: ^ this

23:12 bodie_: just... neurons sparking all over the place right now

23:12 just left a job that was 120,000+ lines of perl spaghetti code...

23:12 fortruce: anyone know how to mock a java object?

23:12 bodie_: what has been seen cannot be unseen

23:13 arrdem: (inc bodie_) ;; karma cannot heal this pain but it may help

23:13 lazybot: ⇒ 1

23:26 Kitty-: Hello, I am using Clojure to connect to a database and need to utilize . in my string. I've tried escaping it with \, so for example \. however it does not work. Any suggestions to try? The help would be much appreciated.

23:26 fortruce: Kitty-: can you show me what you mean?

23:27 Kitty-: fortruce: sure, let me come up with a pastie link

23:29 fortruce: so here is what I used before... http://pastie.org/9194703 however since "," is a special character I tried to escape it with ,\ in http://pastie.org/9194705 on line 12 however when I compile, it complains about "\" with a stack trace.

23:30 justin_smith: Kitty-: clojure complains about unneeded \ in string literals (and has differing rules for string vs regex literals

23:31 mange: Kitty-: Use \\. That'll put a literal \ in the string for the database to see.

23:31 ddellacosta: Kitty-: what are you using to run the SQL? Which clojure lib?

23:31 justin_smith: ,"this\."

23:31 clojurebot: #<RuntimeException java.lang.RuntimeException: Unsupported escape character: \.>

23:31 justin_smith: ,"vs. This\\."

23:31 clojurebot: "vs. This\\."

23:31 justin_smith: ,(println "vs. This\\.")

23:31 clojurebot: vs. This\.\n

23:32 Kitty-: \\,

23:32 * Kitty- tries

23:40 Kitty-: hmm, here is what I get http://pastie.org/9194732

23:41 It's not liking "(\"OID\"... should I use \\ with ", so \\" maybe?

23:42 justin_smith: I think your string escaping is not properly balanced there - are you missing a " after TEMPT_SPINSTER\" ?

23:42 *TEMP lol freudian slip

23:43 Kitty-: Lol

23:43 justin_smith: thanks...let me try adding the "

23:45 justin_smith: also if you have a repl available, it is much faster to test things like this in a repl

23:47 Kitty-: justin_smith: it compiled yaay. so when I execute the .jar against the server, i get an error http://pastie.org/9194741

23:47 justin_smith: Kitty-: what editor are you using?

23:47 Kitty-: I'm thinking it must have a ; however I'm not sure how to 'escape' those

23:47 justin_smith: notepad++

23:48 justin_smith: in some editors (mine for example being emacs) there is an "escaped string composer" mode that automatically escapes a region after you are done editing it

23:48 Frozenlock: really? What's the command?

23:48 justin_smith: in leiu of that in a simpler editor, maybe try interactively using that str invocation in the repl, and take a look at what it generates

23:48 beamso: ORA-00933 is more to do with the query or queries that you are executing rather than clojure.

23:49 justin_smith: Frozenlock: string-edit-at-point

23:49 Frozenlock: the awesome part is it even works recursively for recursively embedded strings

23:49 blr: silly emacs question, is there a better indentation strategy than that provided by clojure-mode? The way the body of the anonymous function is indented bugs me: http://i.imgur.com/RmgUpo5.png

23:50 Frozenlock: justin_smith: I don't appear to have this function... o_O

23:50 justin_smith: oh, it may be a package I have

23:50 Frozenlock: string-edit.el

23:50 Frozenlock: Unless it came later than 24.3.1, I would say so :-p

23:51 justin_smith: Frozenlock: package require string-edit

23:51 I forgot it was not a vanilla thing

23:52 Kitty-: justin_smith: any hints on what could escape a ";" perhaps? fwiw, I don't think a repl would work because the code has about 213 lines and then on top of that, it relies on compiled code originally written in java which I don't think clojure could do in realtime? So for example, it has to run off of a .jar which I don't think the repl 'does'

23:52 justin_smith: Kitty-: I'm just talking about the generation of that one string

23:52 Frozenlock: 213 is nothing :-p

23:52 Push that repl, cmon, push it!

23:52 Kitty-: Frozenlock: perhaps, but do you copy and paste 213+ lines in repl?

23:53 justin_smith: perhaps you have an example so I can understand further?

23:53 justin_smith: Kitty-: also, if you connect to your app by running an nrepl server from it, you can access data from the running process - you can make an atom and shove strings into it so you can experiment with them

23:53 Frozenlock: Kitty-: That's not the ideal, but I've pasted entire source code many times.

23:53 justin_smith: https://github.com/clojure/tools.nrepl it is really easy to host nrepl inside your app

23:54 make an atom, one of my favorites is a vector of a map, keys are args, vals are results

23:54 or you can throw timestamps in there if you have multiple things to look at ...

23:54 quizdr: does anyone know the emacs equivalent to the Light Table "add connection" command that you can use in Om to connect a script to a browser? I'm following the Om tutorial but using Emacs

23:54 Kitty-: justin_smith: hmm

23:55 Frozenlock: quizdr: Emacs doesn't have the magic LT connection. You'll have to configure a brepl

23:55 justin_smith: Kitty-: another option is to break your code down into smaller parts that can be tested for their output

23:55 this is good design anyway

23:55 beamso: for the om tutes i just saved then reloaded the browser

23:55 Kitty-: justin_smith: hmm yea

23:55 quizdr: but there is something the Om tutorial says to do about adding a script to the index.html, but it is not clear what it actually is, as it is done via this "connection" command

23:55 justin_smith: then you just (require ... :reload) on the ns as you update, and see what things do in a repl

23:56 Kitty-: justin_smith: I'm pretty sure it's just not liking ";" however I don't know how to escape that

23:56 justin_smith: ,(print "\\;")

23:56 clojurebot: \;

23:57 beamso: quizdr: the script is so that when you save in lighttable it forces the browser to reload or reevaluate the javascript it's referencing. simply saving the clojurescript file, waiting for the recompile and reloading the html page should let you see the changes you want.

23:57 Frozenlock: justin_smith: string-edit is amazing

23:57 Kitty-: woohooo http://pastie.org/9194755 compiles

23:57 Frozenlock: How could I live without it?

23:57 clojurebot: Gabh mo leithscéal?

23:57 justin_smith: Frozenlock: yeah, I know, I wish I had it years ago when I was fucking with shell scripts more often :)

23:58 quizdr: beamso ah ,thanks

23:58 Kitty-: thanks for the tips... I'm gonna keep at it

Logging service provided by n01se.net