#clojure log - Feb 13 2016

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

0:06 gratimax: quick question about the REPL -- does it compile statements and expressions into bytecode before running them? and if so, how?

0:09 rhg135: yes, and it has an emitter built in

0:12 gratimax: ok, hmm. looking at clojure.core/eval right now, and it seems like it delegates to an eval java method that looks like an interpreter

0:16 ah, nevermind, ObjectExpr generates bytecode in a new class's init method for its eval method, quite cool

0:21 amalloy: gratimax: the eval method is rarely used; only in very simple repl expressions. most of the time, the relevant method is emit

0:37 gratimax: amalloy: ah, thanks

0:49 amalloy: I couldn't find any usages for emit apart from static compilation, are you talking about clojure.core/repl?

0:51 amalloy: well, maybe i don't understand your context well enough and answered with something irrelevant

0:51 what are you trying to learn about?

0:52 gratimax: mostly how the repl and runtime work

0:54 I was wondering if you were talking about something different like nrepl

0:59 oh, I think I see what you mean. for IFn, eval() delegates to emit() of the function calls within it

1:00 err not IFn, FnExpr

4:20 benjyz1: anyone know what to put as connection URI here for a H2 database? https://github.com/weavejester/ragtime/wiki/Getting-Started

6:13 kwladyka: How do you share between backend and frontend code like for example rules for validation https://github.com/leonardoborges/bouncer ? In separate module which you include to project.clj or another method? For example i have rules for register-step-1, register-step-2 etc. I want share this rules between all separated parts of the system.

6:34 eli: hello people

6:34 Guest7427: so is anyone here

6:45 TEttinger: Redguy43: yes, a few hundred

6:45 it's the middle of the night for many of them

6:46 if you have a question, just ask and stick around until people wake up and get answering

6:47 Redguy43: oh haha i live in belguim and i forget the timezone's sometimes

9:26 faxm0dem: Hi

9:26 is there a simple way to replace a key's value in a map?

9:31 justin_smith: faxm0dem: depends what you mean - maps are immutable, but it's simple to make a new map with a replaced value for a specific key

9:32 ,(assoc {:a 0 :b 1} :b 2)

9:32 clojurebot: {:a 0, :b 2}

9:32 justin_smith: ,(update {:a 0 :b 1} :b inc)

9:32 clojurebot: {:a 0, :b 2}

9:32 justin_smith: ,(update-in {:a 0 :b [2]} [:b 0] inc)

9:32 clojurebot: {:a 0, :b [3]}

9:32 justin_smith: etc.

9:33 faxm0dem: assoc, of course

9:33 justin_smith: thanks

9:33 sorry, clojure.noob/here

9:34 justin_smith: np

9:34 just remember you have to use the return values of those functions

9:34 the original is unchanged

9:34 faxm0dem: sure thing

9:34 immutable is beautiful

9:34 * faxm0dem shall make a t-shirt of that

9:57 Malnormalulo: What exactly is the distinction between Sequential and ISeq? Why are those two different things?

10:00 kwladyka: i stack with jdbc error... https://www.refheap.com/114761 somebody see something what i dont see?

10:01 and of course id is uuid: id uuid PRIMARY KEY DEFAULT gen_random_uuid(), <- table construction is ok for sure

10:02 justin_smith: kwladyka: did you cat .getNextException on the BatchUpdateException object?

10:02 *call

10:04 kwladyka: oh i incidentaly find the problem... it is not about it.... it is about :status... it is enum field in DB

10:06 why can't use {:status "foo"} on enum field?

10:23 Are you using solution like that https://gist.github.com/rkneufeld/e5d1acbb007f47655508 or :stringtype "unspecified" to use JDBC with ENUM in PostgreSQL? Any disadventage of using :stringtype "unspecified" ?

10:57 timvisher: is there a db agnostic jdbc timeout that i can set?

10:59 i'd like to set it for a specific `jdbc/query`

11:04 kwladyka: timvisher not sure if you can do it for one query, but you can always make second connection

11:05 timvisher: kwladyka: ah i should say that i have full control over the connection

11:05 what i mean is is there something i can pass in the db spec that will cause statements executed on it to time out after, say, 100ms?

11:06 kwladyka: timvisher but i am not sure if db has option to set timeout only for one query, but there is an option to set timout for connection

11:06 timvisher: kwladyka: docs?

11:07 kwladyka: timvisher it depend on which DB you use

11:08 not from JDBC

11:12 timvisher: kwladyka: ah. that's not what i need then. i need it be entirely db agnostic

11:13 kwladyka: timvisher to work with every DB? I don't think so there is any ready solution

11:13 you should find out how to set it in every DB what you need and put all this solution in your code

11:15 I mean if you use Postgres you should do it in another way then you use MySQL

11:15 timvisher: kwladyka: sure. in reality i currently only need one. but that's far from ideal :P

11:16 kwladyka: timvisher for example in postgresql i see you can use that http://www.postgresql.org/message-id/BANLkTi=BKcBKAwqyqpDh2xWP9h3irQsVGg@mail.gmail.com <- maybe it is what you need

11:16 anyway i think you are doing something wrong if you need this for one query

11:16 i have to go... bye!

12:08 macrolicious: I'm wrestling with the following that's part of a tutorial: (defn even-numbers ([] (even-numbers 0)) ([N] (cons n (lazy-seq (even-numbers (+ n 2))))))

12:09 calling (take 10 (even-numbers)) produces ; => (0 2 4 6 8 10 12 14 16 18)

12:09 is it fair to say that the recursive function takes a 'first pass' then a 'second pass'? If so, what is the state at each pass?

12:10 I'm confused by first expression of the defn.

13:01 spuz_: hi i'm getting an error in my function saying "Don't know how to create ISeq from: java.lang.Long" what is the best way to debug this?

13:02 how can i find out the input to the function that is throwing the error/

13:02 justin_smith: spuz_: it means you are calling a collection operation on a number

13:02 spuz_: justin_smith, yeah i guessed that

13:02 i just don't know where that number is coming from

13:02 justin_smith: do you know which function is doing it?

13:03 spuz_: well I typed *e at the repl and got the stack trace

13:03 from there i can see that it's a call to 'rest'

13:03 wondering what other tools i can use to figure out what is going on

13:03 i could println everywhere but that doesn't see correct

13:04 justin_smith: spuz_: if you want an actual debugger you'll probably have to use cursive

13:04 it's an editor plugin for idea

13:05 spuz_: ok i'm using cursive

13:05 i'll lookup their docs

13:05 justin_smith: yeah, "degugging shoulnd't be hard to find", probably similar to any other degugging you would do in intellij idea

13:05 sorry for the random ""

13:09 spuz_: justin_smith, ok it's pretty much what i'm used to

13:10 thanks

13:31 fantazo: what is the best practice of loading a file from resources?

13:32 amalloy: clojure.java.io/resource is usually involved

13:34 fantazo: amalloy, yep. but how? (load-string (slurp (clojure.java.io/resource "resource.clj"))) is not pretty.

13:34 justin_smith: fantazo: oh, so you want to load source code from a file?

13:35 amalloy: you want to eval a clojure source file? why is it in resources if it's source code?

13:35 justin_smith: in that case, just use require

13:35 file/resource/whatever

13:35 fantazo: justin_smith, well basically I want to load a edn but this is actually a clojure s-expression.

13:36 I want to load a list of hashes I put into a file so that I can render that in a mustache file.

13:36 justin_smith: slurp and edn/read-string, or make a reader and use edn/read for successive entries

13:36 but really slurp and read string is easier and usually sufficient unless you have multiple top level forms

13:37 and all you need is a couple [] to turn multiple top level forms into one

13:47 fantazo: how do generally organize their compojure projects?

13:49 csd_: amalloy: would you be able to speak to part of the 4clojure code? i have a question about a function in it, split-hosts

13:50 amalloy: sure

13:51 csd_: so was the intent of that function to facilitate running the app on multiple servers, e.g. one for static content and another for dynamic content?

13:51 i'm not clear on what exactly it is actually doing

13:55 amalloy: i never really planned to run it from multiple actual servers

13:55 csd_: check out https://github.com/4clojure/4clojure/commit/4ef7b4e8, where it was added

13:56 csd_: so its just an organization thing?

13:57 amalloy: i'm not sure really. it was five years ago and i rolled some of it back

13:57 csd_: :)

13:57 amalloy: it might have been one of those "good practice" things

13:57 to have your static resources on a different domain so you can use cloudflare or whatever

13:57 csd_: ok thanks

15:15 rhg135: do new threads inherit the Var bindings of the parent?

15:23 ashnur: why are there no datomic talk videos on youtube from the past year? one would think that there were many talks given on it..

15:25 ridcully: there are at least to from end of 2015 from the conj(?)

15:25 unless they got pulled

15:26 ashnur: maybe my search query was way too specific, will search again

15:26 but still, strange, i searched for generate datomic queries

16:02 amalloy: rhg135: no, but if you use future to create the thread then it will

16:03 ie, Thread. doesn't know about vars, but future does

16:03 rhg135: ah that makes sense

17:04 macrolicious: I'm still a bit confused by (defn even-numbers ([] (even-numbers 0)) ([n] (cons n (lazy-seq (even-numbers (+ n 2))))))… is this an alternate syntax for aguments (i.e. if an argument is supplied, use those as [] but if not, call (even-numbers 0) ?

17:06 ridcully: yes

17:07 imagine default params you might know from other languages

17:07 justin_smith: macrolicious: yes, that is the variable argument count syntax

17:07 (though of course it could do more than just provide default)

17:18 macrolicious: ok, understand now… found http://theburningmonk.com/2013/09/clojure-multi-arity-and-variadic-functions which discusses multi arity function definitions

18:48 amalloy: justin_smith: details re http://stackoverflow.com/a/35385598/625403 - creating a subvector is constant time, but each time you create a subvector or conj onto one, you add another "wrapper" over the underlying vector you started with, and your vector degrades into a linked list

18:48 justin_smith: amalloy: aha - I was talking about the constant time pop

18:48 but OK yeah

18:48 amalloy: but it's not even constant time to pop!

18:48 is it? maybe it is

18:49 i mean, it is, but you're just adding another wrapper

18:49 justin_smith: err sorry, not the pop, missspoke

18:49 * justin_smith is out of it

18:50 justin_smith: aha, I should change my answer to persistentqueue

18:50 amalloy: conj and pop on a subvector are both constant time, but doing a lot of them makes peek *very* expensive

18:50 justin_smith: fascinating

18:51 amalloy: i bet it's not that hard to demonstrate, even. let's see

18:52 ,((fn [v] (time (dotimes [_ 1e4] (peek v)))) (vec (range 1e3)))

18:52 clojurebot: "Elapsed time: 24.130148 msecs"\n

18:54 amalloy: ,((fn [v] (time (dotimes [_ 1e4] (peek v)))) (nth (iterate #(conj (subvec % 1 1e3) (first %)) (vec (range 1e3))) 1e3))

18:54 clojurebot: "Elapsed time: 1.081422 msecs"\n

18:54 amalloy: ha. it said 100-odd ms when i /msg'd clojurebot with it first

18:54 jvm warmup strikes again

18:58 arrdem: clearly we need a benchmarkbot

18:58 justin_smith: amalloy: edited that SO answer, thank you

18:58 critbot

18:58 arrdem: lazybot still dead

18:59 justin_smith: it amazes me we have a readable Exception literal now, but still no readable PersistentQueue literal

18:59 * justin_smith should get off his ass and implement that and submit to core

18:59 justin_smith: err, strike literal above, brain scrambled, shutting up now

19:00 arrdem: justin_smith: there are already patches for that lying around untouched since ~2013 iirc

19:00 justin_smith: arrdem: my laziness is vindicated!

19:01 arrdem: The tricky bit if I recall was implementing compilation for queue literals...

19:01 amalloy: good luck with that, justin_smith. it's been in the clojure-dev black hole for four years already

19:01 https://groups.google.com/forum/#!topic/clojure-dev/GQqus5Wycno

19:01 arrdem: I'll merge one into clojarr :P

19:01 amalloy: is that your pirated version of clojure?

19:02 arrdem: hard fork yes, logo is forthcomming currently sketched as a pirate hook around a lambda

19:02 https://github.com/arrdem/clojarr

19:02 ridcully: arrr!

19:02 arrdem: I need to write a changelog at some point...

19:02 justin_smith: arrdem: not a gnarly pirate with metal lambda for hand?

19:03 arr, keel-haul the prisoners under the hash-map matey

19:03 arrdem: I think Bronsa was proposing #[] for queue a while back..

19:03 justin_smith: that totally makes sense

19:04 amalloy: so allow me to ask a couple leading questions about a queue literal. i do think it's a good idea, but it's probably trickier than you think

19:04 arrdem: I think that the merged pull request tab is pretty comprehensive, mod a bunch of noise around getting the repo set up and running.

19:05 amalloy: presuming that #[] is the queue literal: what does (peek #[(+ 1 1)]) return?

19:05 justin_smith: #[]

19:05 amalloy: peek, not pop

19:06 justin_smith: 2

19:06 arrdem: IMO the reason to do #[] is that it puts queues syntactically on par with [], #{}, which evaluate their textual arguments.

19:06 amalloy: okay, so it evaluates its arguments. how about (peek #[(+ 1 1) (+ 2 2)])?

19:06 arrdem: eager same as the others

19:07 justin_smith: amalloy: 4

19:07 amalloy: really? i would expect the one on the left to be the one in the pop position

19:07 arrdem: yeah pop is leftmost

19:08 sorry peek/pop

19:08 same as vector

19:08 amalloy: so already there's some confusion, that's exciting

19:08 vectors pop on the right

19:08 arrdem: I rememberd that right after hitting enter point amalloy

19:08 justin_smith: amalloy: there's some artificial confusion on my end

19:08 amalloy: haha

19:08 clojurebot: alcohol is artificial confusion

19:08 clojurebot: In Ordnung

19:09 ridcully: artificial?

19:09 justin_smith: ridcully: weed (it's legal here)

19:09 arrdem: amalloy: I believe that the existing printers for lists eg as provided in CIDER, fipp show head on the left, tail right.

19:09 ridcully: ye lucky sob

19:09 arrdem: Eg. print in seq order

19:09 read/print being nominally an isomorphism...

19:09 amalloy: sure, and i agree that's the order that makes the most sense. but that's one point that's not totally obvious

19:10 arrdem: I mean.. it is obvious you just have to declare vector Silly

19:10 amalloy: next up: what does this print? #[(println "Hello, ") (println "world!")]

19:11 actually i guess that's not as confusing as i thought. i was thinking this would naturally lead to evaluating things in backwards order, but it doesn't

19:11 arrdem: yeah if you push on the end, you evaluate left to right with no problems

19:12 justin_smith: amalloy: hell you could even use natural eval order matching conj order as your first criteria in determining print order

19:12 arrdem: gives you the same result as [(println "foo") (println "bar")] already does

19:12 amalloy: yeah, i guess i'm out of leading questions

19:12 arrdem: That Wasn't Hard (tm)

19:12 amalloy: the question of whether it evals its arguments or not is the main one, since #queue [(+ 1 1)] shouldn't

19:13 but #[(+ 1 1)] should

19:13 arrdem: right, which is why I said #[]

19:13 I agree it's Hard otherwise

19:14 justin_smith: wait, am I missing something abvious? why shouldn't #queue [] eval its args?

19:14 arrdem: justin_smith: because it "looks the same" as a user defined reader literal which by convention shouldn't eval

19:15 amalloy: reader literals all don't eval

19:15 arrdem: not that I haven't written reader literals that eval...

19:15 justin_smith: arrdem: shows how much I know about user defined literals, thanks

19:16 amalloy: likewise #foo.MyRec[...] doens't eval

19:17 hiredman: I wonder if rich doesn't add a literal because pqueue has it is currently implemented has issues with complexity analysis and amortization

19:17 arrdem: https://github.com/arrdem/meajure I think this does reader literal eval

19:17 justin_smith: I guess I'd know that if I ever used them other than as a side effect of dumping to edn

19:17 hiredman: as

19:17 the cost of the flip isn't properly amortized because of the lack of laziness

19:18 oh, of course the first comment

19:18 " so no reversing or suspensions required for persistent use"

19:19 amalloy: that's a reason i hadn't considered before

19:21 but right, vectors mean you don't need to amortize

19:23 ridcully: alcohol?

19:23 clojurebot: alcohol is artificial confusion

19:24 ridcully: well done

19:24 j-pb: balmer peak?

19:24 ridcully: thats how it works

19:24 or the bot is confused

19:46 csd_: is slamhound / its emacs plugin still maintained

19:46 or rather, does it still work with the latest versions of cider et al

19:47 amalloy: i would be astonished if it did

19:47 csd_: is there an alternative

19:47 arrdem: refactor-nrepl

19:50 ridcully: vim ^_^

19:51 csd_: arrdem: unless i'm mistaken though, that won't add things for you automatically, right? it still requires a degree of user manipulation. i've never really used it but that's what it appears like to me

19:52 eg i still have to navigate to a symbol and tell it to add to the ns

19:56 amalloy: slamhound never really worked great anyway

19:56 the reason we have ns declarations at all is that you can't just take a symbol and unambiguously guess what namespace it's from

20:00 rhg135: technically speaking on some you can. fully qualified symbols

20:00 justin_smith: rhg135: what if I intended to do (require [clojure.string :as clojure.core.async]

20:00 I mean that would be daft, but it's legal

20:01 rhg135: that.. is just.. nice

20:01 ridcully: legal in your county

20:01 csd_: ha

20:01 justin_smith: ,(require '[clojure.string :as clojure.core.async])

20:01 ridcully: lol

20:01 clojurebot: nil

20:02 justin_smith: ,(clojure.core.async/join ">" ["a" "b" "c" "d"])

20:02 clojurebot: "a>b>c>d"

20:02 * rhg135 adds (require '[app.foo :as clojure.set]) to all his public code

20:02 futuro: good lord

20:03 justin_smith: I'm not saying it's a good idea, just saying it's possible

20:03 amalloy: reasons not to make weed legal: justin_smith's weird pedantry

20:03 clojurebot: No entiendo

20:04 justin_smith: amalloy: I had a free pass there, the point I was correcting was already pedantic

20:04 amalloy: true fact

20:43 kenrestivo: i found slamhound very useful for cleaning up ns forms that had accumulated cruft

20:44 i.e. import and require a ton of stuff in ns A, then refactor it out into ns B C and D, then ns A has tons of crap it doesn't need anymore

20:45 only problem is slamhoud choked on #'foo.bar/baz and some other things

20:45 as i recall

20:46 also if you're fetishistic and you want your ns alphabetized but don't want to waste time doing it by hand, it does that

20:46 aand, confirmed, it works with clojure 1.8, just used it a month ago

20:48 ridcully: you are a vim user

20:49 justin_smith: "yer a vimmer harry"

20:50 is there a spoof of harry potter where the sorting hat gives you an editor?

20:50 calling it now, vim=slytherin

20:56 timvisher: what am i missing about clojure.java.jdbc/with-db-connection? it appears that `prepare-statement` is a way to set a timeout on a query via the `:timeout` option. _but_ it also appears to need a Connection object, which I thought `with-db-connection` would have given it, but printing the class of the bound var in the body of `with-db-connection` yields a map, not a connection object

20:56 but reading the source of with-db-connection _really_ leads me to believe it should be a Connection

20:56 justin_smith: timvisher it's an object that it knows how to turn into an actual connection

20:57 timvisher: it can contain an actual connection, a connection pool with a method to get a connection, or credentials with which to connect

20:57 all should work

20:57 being a clojure wrapper, it likes to get a hash map with various magic keys

20:58 timvisher: for example when I upgraded a project to use a pool, I didn't change the connection object I was already using, I used the credentials and connection info it already contained to generate a pool, and put that into the same map with the credentials

20:58 none of the other code was changed at all and it just worked

20:58 clojurebot: Pardon?

21:00 timvisher: justin_smith: are we talking about the same thing? i.e. i think you're talking about the db-spec in `(with-db-connection [conn db-spec] …)` when i'm talking about the `conn` in `(with-db-connection [conn db-spec] (println (class conn)))`

21:00 justin_smith: timvisher: one moment, double checking

21:00 timvisher: at least the source of with-db-connection _looks_ like it takes the dbspec and turns it into a real connection with `get-connection` and `add-connection`

21:02 justin_smith: timvisher: it is a binding form, OK, I was confusing with-connection and with-db-connection

21:02 timvisher: or maybe it's that i don't understand what add-connection does

21:02 right. with-connection is deprecated

21:02 justin_smith: timvisher: so it takes (with-db-connection [conn-db db-spec] and in that scope conn-db will be a connection created using that spec

21:03 timvisher: so conn-db is the explicit connection used (replacing the implicit connection with-connection imposed)

21:04 timvisher: so if i understand what you're saying correctly i'm not sre why `(with-db-connection [conn {:blah :blah}] (println (class conn)))` prints `clojure.lang.PersistentArrayMap`

21:04 s/sre/sure/

21:04 justin_smith: it's in impl detail of clojure.java.jdbc I'd bet

21:04 and it has a key describing the open transaction, that will be used when it's passed as an arg

21:05 timvisher: yeah. which means i'm going to have to go through all sorts of faffery to get a real connection :(

21:05 justin_smith: timvisher: ahh, you need the conn object directly? for interop calls to java.jdbc or what?

21:06 timvisher: well it seems that `prepare-statement` needs an _actual_ java.sql.Connection

21:06 not just a db-spec

21:06 which sucks because it appears to be the only way to `setQueryTimeout`

21:07 justin_smith: that's a hell of a yak you got there, nice

21:07 timvisher: and just more generally i'm confused at what with-db-connection is actually doing

21:07 perhaps if the 'db-spec' is a java.sql.Connection (maybe in the context of a pool?) then it will pass that through

21:08 but with the db-spec map it seems to just be doing nothing

21:08 ah… maybe it's adding metadata

21:08 nope

21:09 * timvisher always forgets metadata

21:09 timvisher: sheesh you'd think this would be an option on `query`

21:09 that'd be too obvious though

21:19 ok so the solution is to just use `(with-open [conn (jdbc/get-connection db-spec)] …)` it would seem

21:19 ¯\_(ツ)_/¯

21:19 justin_smith: congrats!

21:20 rhg135: ,((comp meta meta) (with-meta 'a {:suchmeta true} {}))

21:20 clojurebot: #error {\n :cause "Wrong number of args (3) passed to: core/with-meta--4375"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (3) passed to: core/with-meta--4375"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 40]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]...

21:21 * timvisher has no idea what purpose with-db-connection is meant to serve

21:21 rhg135: ,((comp meta meta) (with-meta 'a ^{:metameta true} {}))

21:21 clojurebot: {:metameta true}

21:21 rhg135: Cool

21:22 ridcully: it could be a db connectiomn

21:22 justin_smith: rhg135: you could do a meta / with-meta version of the weird thing I showed sdegutis the other day with assoc / get

21:23 rhg135: What thing, justin_smith

21:23 justin_smith: rhg135: one minute, recreating

21:24 timvisher: ridcully: was that for me?

21:24 justin_smith: ,(take 10 (reductions :rocks (iterate (fn [x] {:rocks x}) :rocks))

21:24 clojurebot: #<RuntimeException java.lang.RuntimeException: EOF while reading>

21:25 justin_smith: ,(take 10 (reductions :rocks (iterate (fn [x] {:rocks x}) :rocks)))

21:25 clojurebot: (:rocks {:rocks :rocks} :rocks {:rocks {:rocks {:rocks :rocks}}} {:rocks {:rocks :rocks}} ...)

21:25 rhg135: I like that you can put data about data about data

21:25 justin_smith: rhg135: the pattern of the result is that every power of 2 item is :rocks

21:25 ridcully: timvisher: no

21:26 rhg135: justin_smith, wow

21:26 justin_smith: the one after it has next power of 2 instances of :rocks in its tree, nextp2-1, nextp2-2 etc. until next power of two is :rocks again

21:26 rhg135: I am thinking this pattern/phenomenon must have a known name, it's cool

21:27 this is probably an oddly specific version of a much more general and elegant phenomenon

21:28 * rhg135 is still attempting to comprehend

21:29 justin_smith: rhg135: pprinting in your own repl and taking like 32 items helps

21:30 rhg135: I'll remember to do that when I'm at a computer

21:30 justin_smith: w(n) is 1 if n is a power of 2, otherwise it is (h - (n-l)) where h is the next highest power of 2, and l is the next lowest

21:31 rhg135: I don't think my car can run clojure...

21:35 justin_smith: I solved it! :rocks will remove an outer layer of the hash map at each step, until :rocks is not found

21:36 malwarez: =]

21:36 justin_smith: then it will take the nth deep nesting (n incrementing for each layer it had removed)

21:37 so it jumps to 1 for every power of 2, then goes to the next pow of 2, then counts down to 1 again

21:42 rhg135: I made it a gist https://gist.github.com/noisesmith/9b331f0f7a87b644ce10

21:43 that gist also exposes the "breakpoints" in the pprint algorithm in an interesting way

21:44 rhg135: That last line...

21:45 justin_smith: rhg135: anyway, I thought maybe you could do something similar with attaching and removing meta, until I realized it was exploiting the behavior of three-arg get

21:47 rhg135: Yeah I see that now. At first I thought the function you passed to reductions was unary

21:47 justin_smith: right, that would not have worked at all

21:49 rhg135: Yeah, hence my confusion

21:53 amalloy: justin_smith: the most unnecessarily complicated way i've ever seen to draw ascii hockey sticks

21:54 justin_smith: amalloy: haha, thanks

21:54 amalloy: the pattern is fascinating, and was an amusing 30 minutes or so of mental effort to puzzle out and solve

21:56 rhg135: What fun is there in being straightforward

22:11 csd_: clojuredocs.org is down

22:12 rhg135: Works for me

22:12 csd_: must be dns issues on my end

22:15 nope, google's dns has no record...

22:28 matthavener: csd_: doesnt resolve for me

22:48 irctc922: if i have an "env" vector. how can i add another key/val to it? (assoc) doesn't seem to persist

22:51 csd_: an env vector?

22:51 irctc922: a vector named env that stores various environment variables

22:51 sorry new to this

22:52 csd_: is it a map? maps store key value pairs, a vector is more like an array

22:52 irctc922: a map then

22:52 ah, sorry used the wrong temr

22:52 csd_: assoc would add to a map but it returns a new map rather than mutating the old one

22:52 irctc922: ah, so what can i do in this case

22:52 how would i mutate the map

22:53 csd_: well in most cases you wouldnt as immutability is one of the paradigms of clojure

22:54 if you really need to there are mutable types available, such as atoms which might be what you are looking for

22:54 but clojure does require rethinking how you're used to programming if you're new to that sort of paradigm

23:06 rhg135: ,(assoc [] 0 1)

23:06 clojurebot: [1]

23:07 TEttinger: ,(assoc [] 1 2)

23:07 clojurebot: #error {\n :cause nil\n :via\n [{:type java.lang.IndexOutOfBoundsException\n :message nil\n :at [clojure.lang.PersistentVector assocN "PersistentVector.java" 188]}]\n :trace\n [[clojure.lang.PersistentVector assocN "PersistentVector.java" 188]\n [clojure.lang.PersistentVector assocN "PersistentVector.java" 22]\n [clojure.lang.APersistentVector assoc "APersistentVector.java" 343]\n [clojure....

23:07 TEttinger: aw

23:07 rhg135: Interesting. I didn't think it did non existing indices

23:07 csd_: is it possible to rename the function i'm :refer'ing

23:08 TEttinger: well, it does _a_ non-existing index

23:08 csd_: [foo :refer [bar :as baz]]

23:08 TEttinger: the one equal to length

23:08 rhg135: On vectors, but it does match the map behavior

23:08 ,(doc refer)

23:08 clojurebot: "([ns-sym & filters]); refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to somethin...

23:09 csd_: im guessing its not possible

23:09 rhg135: Eh, but yes csd_

23:10 :renames iirc

23:10 csd_: ahh

23:10 sorta annoying the inconsistent syntax

23:10 rhg135: But it might make people hate you

23:10 csd_: :as was giving me an error

23:11 :rename isnt working either :/

23:11 justin_smith: TEttinger: did you see the fun generator / output I posted above?

23:12 csd_: oh nm

23:12 amalloy: csd_: (require my.ns :rename {bar baz} :refer [baz]) ;; or maybe refer bar, i forget

23:14 csd_: eh, in any event it won't let me do what i was trying to do, which is take import function foo, rename it foo* and then create wrapper function foo which calls foo*

23:14 TEttinger: justin_smith: nope

23:14 just got here

23:15 justin_smith: OK, check out this function/result before scrolling up to my explanation https://gist.github.com/noisesmith/9b331f0f7a87b644ce10

23:16 it generates a series of larger/smaller hash maps in cycles

23:25 hodwik: Does anyone have any idea why, while going through the Clojrue Brave chap 1 tutorials, I'm getting a Java error

23:25 At the Emacs section

23:26 "CompilerException java.land.RuntimeException: unable to resolve symbol: -main in this context, compiling [...]"

23:28 justin_smith: hodwik: what are you trying to run when you get that error?

23:30 hodwik: (ns clojure-test.core (:gen-class)) (defn -man "Test" [& args] (println "testing!"))

23:31 http://www.braveclojure.com/basic-emacs/#A_Cornucopia_of_Useful_Key_Bindings

23:31 justin_smith: hodwik: I think you want that -man to be -main

23:32 hodwik: Yeah, it's a main, I didn't copy pasta

23:33 justin_smith: was your cursor right on -main when you ran C-xC-e ?

23:33 because it is supposed to be at the end of the file for that demo

23:34 "eval last defun" is very sensitive to where your cursor is at

23:35 hodwik: Shoot, it works now. My cursor is in the same place.

23:36 Chance for edification wasted

23:36 Thanks for your help though justin_smith

23:36 justin_smith: C-M-x on the other hand loads the whole expression the cursor is in

23:36 hodwik: I was doing C-c M-n

23:36 and then

23:37 (-main)

23:37 from a repl

23:37 justin_smith: and well you didn't mention you ran (-main), and that would indicate a completely different source of your problem, yes

23:37 clearly you hadn't loaded that definition into the right scope yet

23:38 hodwik: That's the weird thing

23:38 the repl showed my app

23:38 as the thing>

23:38 justin_smith: if there is an error in your function definition, the ns is still loaded

23:39 but that function (and the ones after it) are simply unavailable

23:40 hodwik: The function definition stayed static

23:41 does it matter if started the repl with M-x cider-jack-in

23:41 vs

23:41 M-x clojure-main M-x cider-main C-c M-j

23:41 er **mode, not main

23:42 justin_smith: you can use M-x describe-key to find out what C-c M-j does

23:42 hodwik: Yeah, C-c M-j runs cider-jack-in

23:43 hmm

23:52 @justin_smith now it's doing something else weird

23:52 http://i.imgur.com/ssndSUP.png

23:52 Haven't changed anything as far as I can tell, just restarted emacs and went to same point

23:52 Any idea what this is?

23:52 "Namespace not found."

23:55 Anyone have any idea what I'm doing wrong?

Logging service provided by n01se.net