#clojure logs

2016-02-13

00:06gratimaxquick question about the REPL -- does it compile statements and expressions into bytecode before running them? and if so, how?
00:09rhg135yes, and it has an emitter built in
00:12gratimaxok, hmm. looking at clojure.core/eval right now, and it seems like it delegates to an eval java method that looks like an interpreter
00:16gratimaxah, nevermind, ObjectExpr generates bytecode in a new class's init method for its eval method, quite cool
00:21amalloygratimax: the eval method is rarely used; only in very simple repl expressions. most of the time, the relevant method is emit
00:37gratimaxamalloy: ah, thanks
00:49gratimaxamalloy: I couldn't find any usages for emit apart from static compilation, are you talking about clojure.core/repl?
00:51amalloywell, maybe i don't understand your context well enough and answered with something irrelevant
00:51amalloywhat are you trying to learn about?
00:52gratimaxmostly how the repl and runtime work
00:54gratimaxI was wondering if you were talking about something different like nrepl
00:59gratimaxoh, I think I see what you mean. for IFn, eval() delegates to emit() of the function calls within it
01:00gratimaxerr not IFn, FnExpr
04:20benjyz1anyone know what to put as connection URI here for a H2 database? https://github.com/weavejester/ragtime/wiki/Getting-Started
06:13kwladykaHow 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.
06:34elihello people
06:34Guest7427so is anyone here
06:45TEttingerRedguy43: yes, a few hundred
06:45TEttingerit's the middle of the night for many of them
06:46TEttingerif you have a question, just ask and stick around until people wake up and get answering
06:47Redguy43oh haha i live in belguim and i forget the timezone's sometimes
09:26faxm0demHi
09:26faxm0demis there a simple way to replace a key's value in a map?
09:31justin_smithfaxm0dem: depends what you mean - maps are immutable, but it's simple to make a new map with a replaced value for a specific key
09:32justin_smith,(assoc {:a 0 :b 1} :b 2)
09:32clojurebot{:a 0, :b 2}
09:32justin_smith,(update {:a 0 :b 1} :b inc)
09:32clojurebot{:a 0, :b 2}
09:32justin_smith,(update-in {:a 0 :b [2]} [:b 0] inc)
09:32clojurebot{:a 0, :b [3]}
09:32justin_smithetc.
09:33faxm0demassoc, of course
09:33faxm0demjustin_smith: thanks
09:33faxm0demsorry, clojure.noob/here
09:34justin_smithnp
09:34justin_smithjust remember you have to use the return values of those functions
09:34justin_smiththe original is unchanged
09:34faxm0demsure thing
09:34faxm0demimmutable is beautiful
09:57MalnormaluloWhat exactly is the distinction between Sequential and ISeq? Why are those two different things?
10:00kwladykai stack with jdbc error... https://www.refheap.com/114761 somebody see something what i dont see?
10:01kwladykaand of course id is uuid: id uuid PRIMARY KEY DEFAULT gen_random_uuid(), <- table construction is ok for sure
10:02justin_smithkwladyka: did you cat .getNextException on the BatchUpdateException object?
10:02justin_smith*call
10:04kwladykaoh i incidentaly find the problem... it is not about it.... it is about :status... it is enum field in DB
10:06kwladykawhy can't use {:status "foo"} on enum field?
10:23kwladykaAre 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:57timvisheris there a db agnostic jdbc timeout that i can set?
10:59timvisheri'd like to set it for a specific `jdbc/query`
11:04kwladykatimvisher not sure if you can do it for one query, but you can always make second connection
11:05timvisherkwladyka: ah i should say that i have full control over the connection
11:05timvisherwhat 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:06kwladykatimvisher 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:06timvisherkwladyka: docs?
11:07kwladykatimvisher it depend on which DB you use
11:08kwladykanot from JDBC
11:12timvisherkwladyka: ah. that's not what i need then. i need it be entirely db agnostic
11:13kwladykatimvisher to work with every DB? I don't think so there is any ready solution
11:13kwladykayou should find out how to set it in every DB what you need and put all this solution in your code
11:15kwladykaI mean if you use Postgres you should do it in another way then you use MySQL
11:15timvisherkwladyka: sure. in reality i currently only need one. but that's far from ideal :P
11:16kwladykatimvisher 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:16kwladykaanyway i think you are doing something wrong if you need this for one query
11:16kwladykai have to go... bye!
12:08macroliciousI'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:09macroliciouscalling (take 10 (even-numbers)) produces ; => (0 2 4 6 8 10 12 14 16 18)
12:09macroliciousis 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:10macroliciousI'm confused by first expression of the defn.
13:01spuz_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:02spuz_how can i find out the input to the function that is throwing the error/
13:02justin_smithspuz_: it means you are calling a collection operation on a number
13:02spuz_justin_smith, yeah i guessed that
13:02spuz_i just don't know where that number is coming from
13:02justin_smithdo you know which function is doing it?
13:03spuz_well I typed *e at the repl and got the stack trace
13:03spuz_from there i can see that it's a call to 'rest'
13:03spuz_wondering what other tools i can use to figure out what is going on
13:03spuz_i could println everywhere but that doesn't see correct
13:04justin_smithspuz_: if you want an actual debugger you'll probably have to use cursive
13:04justin_smithit's an editor plugin for idea
13:05spuz_ok i'm using cursive
13:05spuz_i'll lookup their docs
13:05justin_smithyeah, "degugging shoulnd't be hard to find", probably similar to any other degugging you would do in intellij idea
13:05justin_smithsorry for the random ""
13:09spuz_justin_smith, ok it's pretty much what i'm used to
13:10spuz_thanks
13:31fantazowhat is the best practice of loading a file from resources?
13:32amalloyclojure.java.io/resource is usually involved
13:34fantazoamalloy, yep. but how? (load-string (slurp (clojure.java.io/resource "resource.clj"))) is not pretty.
13:34justin_smithfantazo: oh, so you want to load source code from a file?
13:35amalloyyou want to eval a clojure source file? why is it in resources if it's source code?
13:35justin_smithin that case, just use require
13:35justin_smithfile/resource/whatever
13:35fantazojustin_smith, well basically I want to load a edn but this is actually a clojure s-expression.
13:36fantazoI want to load a list of hashes I put into a file so that I can render that in a mustache file.
13:36justin_smithslurp and edn/read-string, or make a reader and use edn/read for successive entries
13:36justin_smithbut really slurp and read string is easier and usually sufficient unless you have multiple top level forms
13:37justin_smithand all you need is a couple [] to turn multiple top level forms into one
13:47fantazohow do generally organize their compojure projects?
13:49csd_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:50amalloysure
13:51csd_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:51csd_i'm not clear on what exactly it is actually doing
13:55amalloyi never really planned to run it from multiple actual servers
13:55amalloycsd_: check out https://github.com/4clojure/4clojure/commit/4ef7b4e8, where it was added
13:56csd_so its just an organization thing?
13:57amalloyi'm not sure really. it was five years ago and i rolled some of it back
13:57csd_:)
13:57amalloyit might have been one of those "good practice" things
13:57amalloyto have your static resources on a different domain so you can use cloudflare or whatever
13:57csd_ok thanks
15:15rhg135do new threads inherit the Var bindings of the parent?
15:23ashnurwhy are there no datomic talk videos on youtube from the past year? one would think that there were many talks given on it..
15:25ridcullythere are at least to from end of 2015 from the conj(?)
15:25ridcullyunless they got pulled
15:26ashnurmaybe my search query was way too specific, will search again
15:26ashnurbut still, strange, i searched for generate datomic queries
16:02amalloyrhg135: no, but if you use future to create the thread then it will
16:03amalloyie, Thread. doesn't know about vars, but future does
16:03rhg135ah that makes sense
17:04macroliciousI'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:06ridcullyyes
17:07ridcullyimagine default params you might know from other languages
17:07justin_smithmacrolicious: yes, that is the variable argument count syntax
17:07justin_smith(though of course it could do more than just provide default)
17:18macroliciousok, understand now… found http://theburningmonk.com/2013/09/clojure-multi-arity-and-variadic-functions which discusses multi arity function definitions
18:48amalloyjustin_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:48justin_smithamalloy: aha - I was talking about the constant time pop
18:48justin_smithbut OK yeah
18:48amalloybut it's not even constant time to pop!
18:48amalloyis it? maybe it is
18:49amalloyi mean, it is, but you're just adding another wrapper
18:49justin_smitherr sorry, not the pop, missspoke
18:50justin_smithaha, I should change my answer to persistentqueue
18:50amalloyconj and pop on a subvector are both constant time, but doing a lot of them makes peek *very* expensive
18:50justin_smithfascinating
18:51amalloyi bet it's not that hard to demonstrate, even. let's see
18:52amalloy,((fn [v] (time (dotimes [_ 1e4] (peek v)))) (vec (range 1e3)))
18:52clojurebot"Elapsed time: 24.130148 msecs"\n
18:54amalloy,((fn [v] (time (dotimes [_ 1e4] (peek v)))) (nth (iterate #(conj (subvec % 1 1e3) (first %)) (vec (range 1e3))) 1e3))
18:54clojurebot"Elapsed time: 1.081422 msecs"\n
18:54amalloyha. it said 100-odd ms when i /msg'd clojurebot with it first
18:54amalloyjvm warmup strikes again
18:58arrdemclearly we need a benchmarkbot
18:58justin_smithamalloy: edited that SO answer, thank you
18:58justin_smithcritbot
18:58arrdemlazybot still dead
18:59justin_smithit amazes me we have a readable Exception literal now, but still no readable PersistentQueue literal
18:59justin_smitherr, strike literal above, brain scrambled, shutting up now
19:00arrdemjustin_smith: there are already patches for that lying around untouched since ~2013 iirc
19:00justin_smitharrdem: my laziness is vindicated!
19:01arrdemThe tricky bit if I recall was implementing compilation for queue literals...
19:01amalloygood luck with that, justin_smith. it's been in the clojure-dev black hole for four years already
19:01amalloyhttps://groups.google.com/forum/#!topic/clojure-dev/GQqus5Wycno
19:01arrdemI'll merge one into clojarr :P
19:01amalloyis that your pirated version of clojure?
19:02arrdemhard fork yes, logo is forthcomming currently sketched as a pirate hook around a lambda
19:02arrdemhttps://github.com/arrdem/clojarr
19:02ridcullyarrr!
19:02arrdemI need to write a changelog at some point...
19:02justin_smitharrdem: not a gnarly pirate with metal lambda for hand?
19:03justin_smitharr, keel-haul the prisoners under the hash-map matey
19:03arrdemI think Bronsa was proposing #[] for queue a while back..
19:03justin_smiththat totally makes sense
19:04amalloyso 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:04arrdemI think that the merged pull request tab is pretty comprehensive, mod a bunch of noise around getting the repo set up and running.
19:05amalloypresuming that #[] is the queue literal: what does (peek #[(+ 1 1)]) return?
19:05justin_smith#[]
19:05amalloypeek, not pop
19:06justin_smith2
19:06arrdemIMO the reason to do #[] is that it puts queues syntactically on par with [], #{}, which evaluate their textual arguments.
19:06amalloyokay, so it evaluates its arguments. how about (peek #[(+ 1 1) (+ 2 2)])?
19:06arrdemeager same as the others
19:07justin_smithamalloy: 4
19:07amalloyreally? i would expect the one on the left to be the one in the pop position
19:07arrdemyeah pop is leftmost
19:08arrdemsorry peek/pop
19:08arrdemsame as vector
19:08amalloyso already there's some confusion, that's exciting
19:08amalloyvectors pop on the right
19:08arrdemI rememberd that right after hitting enter point amalloy
19:08justin_smithamalloy: there's some artificial confusion on my end
19:08amalloyhaha
19:08amalloyclojurebot: alcohol is artificial confusion
19:08clojurebotIn Ordnung
19:09ridcullyartificial?
19:09justin_smithridcully: weed (it's legal here)
19:09arrdemamalloy: I believe that the existing printers for lists eg as provided in CIDER, fipp show head on the left, tail right.
19:09ridcullyye lucky sob
19:09arrdemEg. print in seq order
19:09arrdemread/print being nominally an isomorphism...
19:09amalloysure, and i agree that's the order that makes the most sense. but that's one point that's not totally obvious
19:10arrdemI mean.. it is obvious you just have to declare vector Silly
19:10amalloynext up: what does this print? #[(println "Hello, ") (println "world!")]
19:11amalloyactually 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:11arrdemyeah if you push on the end, you evaluate left to right with no problems
19:12justin_smithamalloy: hell you could even use natural eval order matching conj order as your first criteria in determining print order
19:12arrdemgives you the same result as [(println "foo") (println "bar")] already does
19:12amalloyyeah, i guess i'm out of leading questions
19:12arrdemThat Wasn't Hard (tm)
19:12amalloythe question of whether it evals its arguments or not is the main one, since #queue [(+ 1 1)] shouldn't
19:13amalloybut #[(+ 1 1)] should
19:13arrdemright, which is why I said #[]
19:13arrdemI agree it's Hard otherwise
19:14justin_smithwait, am I missing something abvious? why shouldn't #queue [] eval its args?
19:14arrdemjustin_smith: because it "looks the same" as a user defined reader literal which by convention shouldn't eval
19:15amalloyreader literals all don't eval
19:15arrdemnot that I haven't written reader literals that eval...
19:15justin_smitharrdem: shows how much I know about user defined literals, thanks
19:16amalloylikewise #foo.MyRec[...] doens't eval
19:17hiredmanI wonder if rich doesn't add a literal because pqueue has it is currently implemented has issues with complexity analysis and amortization
19:17arrdemhttps://github.com/arrdem/meajure I think this does reader literal eval
19:17justin_smithI guess I'd know that if I ever used them other than as a side effect of dumping to edn
19:17hiredmanas
19:17hiredmanthe cost of the flip isn't properly amortized because of the lack of laziness
19:18hiredmanoh, of course the first comment
19:18hiredman" so no reversing or suspensions required for persistent use"
19:19amalloythat's a reason i hadn't considered before
19:21amalloybut right, vectors mean you don't need to amortize
19:23ridcullyalcohol?
19:23clojurebotalcohol is artificial confusion
19:24ridcullywell done
19:24j-pbbalmer peak?
19:24ridcullythats how it works
19:24ridcullyor the bot is confused
19:46csd_is slamhound / its emacs plugin still maintained
19:46csd_or rather, does it still work with the latest versions of cider et al
19:47amalloyi would be astonished if it did
19:47csd_is there an alternative
19:47arrdemrefactor-nrepl
19:50ridcullyvim ^_^
19:51csd_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:52csd_eg i still have to navigate to a symbol and tell it to add to the ns
19:56amalloyslamhound never really worked great anyway
19:56amalloythe 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:00rhg135technically speaking on some you can. fully qualified symbols
20:00justin_smithrhg135: what if I intended to do (require [clojure.string :as clojure.core.async]
20:00justin_smithI mean that would be daft, but it's legal
20:01rhg135that.. is just.. nice
20:01ridcullylegal in your county
20:01csd_ha
20:01justin_smith,(require '[clojure.string :as clojure.core.async])
20:01justin_smithridcully: lol
20:01clojurebotnil
20:02justin_smith,(clojure.core.async/join ">" ["a" "b" "c" "d"])
20:02clojurebot"a>b>c>d"
20:02futurogood lord
20:03justin_smithI'm not saying it's a good idea, just saying it's possible
20:03amalloyreasons not to make weed legal: justin_smith's weird pedantry
20:03clojurebotNo entiendo
20:04justin_smithamalloy: I had a free pass there, the point I was correcting was already pedantic
20:04amalloytrue fact
20:43kenrestivoi found slamhound very useful for cleaning up ns forms that had accumulated cruft
20:44kenrestivoi.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:45kenrestivoonly problem is slamhoud choked on #'foo.bar/baz and some other things
20:45kenrestivoas i recall
20:46kenrestivoalso 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:46kenrestivoaand, confirmed, it works with clojure 1.8, just used it a month ago
20:48ridcullyyou are a vim user
20:49justin_smith"yer a vimmer harry"
20:50justin_smithis there a spoof of harry potter where the sorting hat gives you an editor?
20:50justin_smithcalling it now, vim=slytherin
20:56timvisherwhat 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:56timvisherbut reading the source of with-db-connection _really_ leads me to believe it should be a Connection
20:56justin_smithtimvisher it's an object that it knows how to turn into an actual connection
20:57justin_smithtimvisher: it can contain an actual connection, a connection pool with a method to get a connection, or credentials with which to connect
20:57justin_smithall should work
20:57justin_smithbeing a clojure wrapper, it likes to get a hash map with various magic keys
20:58justin_smithtimvisher: 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:58justin_smithnone of the other code was changed at all and it just worked
20:58clojurebotPardon?
21:00timvisherjustin_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:00justin_smithtimvisher: one moment, double checking
21:00timvisherat 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:02justin_smithtimvisher: it is a binding form, OK, I was confusing with-connection and with-db-connection
21:02timvisheror maybe it's that i don't understand what add-connection does
21:02timvisherright. with-connection is deprecated
21:02justin_smithtimvisher: 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:03justin_smithtimvisher: so conn-db is the explicit connection used (replacing the implicit connection with-connection imposed)
21:04timvisherso 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:04timvishers/sre/sure/
21:04justin_smithit's in impl detail of clojure.java.jdbc I'd bet
21:04justin_smithand it has a key describing the open transaction, that will be used when it's passed as an arg
21:05timvisheryeah. which means i'm going to have to go through all sorts of faffery to get a real connection :(
21:05justin_smithtimvisher: ahh, you need the conn object directly? for interop calls to java.jdbc or what?
21:06timvisherwell it seems that `prepare-statement` needs an _actual_ java.sql.Connection
21:06timvishernot just a db-spec
21:06timvisherwhich sucks because it appears to be the only way to `setQueryTimeout`
21:07justin_smiththat's a hell of a yak you got there, nice
21:07timvisherand just more generally i'm confused at what with-db-connection is actually doing
21:07timvisherperhaps if the 'db-spec' is a java.sql.Connection (maybe in the context of a pool?) then it will pass that through
21:08timvisherbut with the db-spec map it seems to just be doing nothing
21:08timvisherah… maybe it's adding metadata
21:08timvishernope
21:09timvishersheesh you'd think this would be an option on `query`
21:09timvisherthat'd be too obvious though
21:19timvisherok so the solution is to just use `(with-open [conn (jdbc/get-connection db-spec)] …)` it would seem
21:19timvisher¯\_(ツ)_/¯
21:19justin_smithcongrats!
21:20rhg135,((comp meta meta) (with-meta 'a {:suchmeta true} {}))
21:20clojurebot#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:21rhg135,((comp meta meta) (with-meta 'a ^{:metameta true} {}))
21:21clojurebot{:metameta true}
21:21rhg135Cool
21:22ridcullyit could be a db connectiomn
21:22justin_smithrhg135: you could do a meta / with-meta version of the weird thing I showed sdegutis the other day with assoc / get
21:23rhg135What thing, justin_smith
21:23justin_smithrhg135: one minute, recreating
21:24timvisherridcully: was that for me?
21:24justin_smith,(take 10 (reductions :rocks (iterate (fn [x] {:rocks x}) :rocks))
21:24clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:25justin_smith,(take 10 (reductions :rocks (iterate (fn [x] {:rocks x}) :rocks)))
21:25clojurebot(:rocks {:rocks :rocks} :rocks {:rocks {:rocks {:rocks :rocks}}} {:rocks {:rocks :rocks}} ...)
21:25rhg135I like that you can put data about data about data
21:25justin_smithrhg135: the pattern of the result is that every power of 2 item is :rocks
21:25ridcullytimvisher: no
21:26rhg135justin_smith, wow
21:26justin_smiththe 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:26justin_smithrhg135: I am thinking this pattern/phenomenon must have a known name, it's cool
21:27justin_smiththis is probably an oddly specific version of a much more general and elegant phenomenon
21:29justin_smithrhg135: pprinting in your own repl and taking like 32 items helps
21:30rhg135I'll remember to do that when I'm at a computer
21:30justin_smithw(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:31rhg135I don't think my car can run clojure...
21:35justin_smithI solved it! :rocks will remove an outer layer of the hash map at each step, until :rocks is not found
21:36malwarez=]
21:36justin_smiththen it will take the nth deep nesting (n incrementing for each layer it had removed)
21:37justin_smithso it jumps to 1 for every power of 2, then goes to the next pow of 2, then counts down to 1 again
21:42justin_smithrhg135: I made it a gist https://gist.github.com/noisesmith/9b331f0f7a87b644ce10
21:43justin_smiththat gist also exposes the "breakpoints" in the pprint algorithm in an interesting way
21:44rhg135That last line...
21:45justin_smithrhg135: 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:47rhg135Yeah I see that now. At first I thought the function you passed to reductions was unary
21:47justin_smithright, that would not have worked at all
21:49rhg135Yeah, hence my confusion
21:53amalloyjustin_smith: the most unnecessarily complicated way i've ever seen to draw ascii hockey sticks
21:54justin_smithamalloy: haha, thanks
21:54justin_smithamalloy: the pattern is fascinating, and was an amusing 30 minutes or so of mental effort to puzzle out and solve
21:56rhg135What fun is there in being straightforward
22:11csd_clojuredocs.org is down
22:12rhg135Works for me
22:12csd_must be dns issues on my end
22:15csd_nope, google's dns has no record...
22:28matthavenercsd_: doesnt resolve for me
22:48irctc922if i have an "env" vector. how can i add another key/val to it? (assoc) doesn't seem to persist
22:51csd_an env vector?
22:51irctc922a vector named env that stores various environment variables
22:51irctc922sorry new to this
22:52csd_is it a map? maps store key value pairs, a vector is more like an array
22:52irctc922a map then
22:52irctc922ah, sorry used the wrong temr
22:52csd_assoc would add to a map but it returns a new map rather than mutating the old one
22:52irctc922ah, so what can i do in this case
22:52irctc922how would i mutate the map
22:53csd_well in most cases you wouldnt as immutability is one of the paradigms of clojure
22:54csd_if you really need to there are mutable types available, such as atoms which might be what you are looking for
22:54csd_but clojure does require rethinking how you're used to programming if you're new to that sort of paradigm
23:06rhg135,(assoc [] 0 1)
23:06clojurebot[1]
23:07TEttinger,(assoc [] 1 2)
23:07clojurebot#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:07TEttingeraw
23:07rhg135Interesting. I didn't think it did non existing indices
23:07csd_is it possible to rename the function i'm :refer'ing
23:08TEttingerwell, it does _a_ non-existing index
23:08csd_[foo :refer [bar :as baz]]
23:08TEttingerthe one equal to length
23:08rhg135On vectors, but it does match the map behavior
23:08rhg135,(doc refer)
23:08clojurebot"([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:09csd_im guessing its not possible
23:09rhg135Eh, but yes csd_
23:10rhg135:renames iirc
23:10csd_ahh
23:10csd_sorta annoying the inconsistent syntax
23:10rhg135But it might make people hate you
23:10csd_:as was giving me an error
23:11csd_:rename isnt working either :/
23:11justin_smithTEttinger: did you see the fun generator / output I posted above?
23:12csd_oh nm
23:12amalloycsd_: (require my.ns :rename {bar baz} :refer [baz]) ;; or maybe refer bar, i forget
23:14csd_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:14TEttingerjustin_smith: nope
23:14TEttingerjust got here
23:15justin_smithOK, check out this function/result before scrolling up to my explanation https://gist.github.com/noisesmith/9b331f0f7a87b644ce10
23:16justin_smithit generates a series of larger/smaller hash maps in cycles
23:25hodwikDoes anyone have any idea why, while going through the Clojrue Brave chap 1 tutorials, I'm getting a Java error
23:25hodwikAt the Emacs section
23:26hodwik"CompilerException java.land.RuntimeException: unable to resolve symbol: -main in this context, compiling [...]"
23:28justin_smithhodwik: what are you trying to run when you get that error?
23:30hodwik(ns clojure-test.core (:gen-class)) (defn -man "Test" [& args] (println "testing!"))
23:31hodwikhttp://www.braveclojure.com/basic-emacs/#A_Cornucopia_of_Useful_Key_Bindings
23:31justin_smithhodwik: I think you want that -man to be -main
23:32hodwikYeah, it's a main, I didn't copy pasta
23:33justin_smithwas your cursor right on -main when you ran C-xC-e ?
23:33justin_smithbecause it is supposed to be at the end of the file for that demo
23:34justin_smith"eval last defun" is very sensitive to where your cursor is at
23:35hodwikShoot, it works now. My cursor is in the same place.
23:36hodwikChance for edification wasted
23:36hodwikThanks for your help though justin_smith
23:36justin_smithC-M-x on the other hand loads the whole expression the cursor is in
23:36hodwikI was doing C-c M-n
23:36hodwikand then
23:37hodwik(-main)
23:37hodwikfrom a repl
23:37justin_smithand well you didn't mention you ran (-main), and that would indicate a completely different source of your problem, yes
23:37justin_smithclearly you hadn't loaded that definition into the right scope yet
23:38hodwikThat's the weird thing
23:38hodwikthe repl showed my app
23:38hodwikas the thing>
23:38justin_smithif there is an error in your function definition, the ns is still loaded
23:39justin_smithbut that function (and the ones after it) are simply unavailable
23:40hodwikThe function definition stayed static
23:41hodwikdoes it matter if started the repl with M-x cider-jack-in
23:41hodwikvs
23:41hodwikM-x clojure-main M-x cider-main C-c M-j
23:41hodwiker **mode, not main
23:42justin_smithyou can use M-x describe-key to find out what C-c M-j does
23:42hodwikYeah, C-c M-j runs cider-jack-in
23:43hodwikhmm
23:52hodwik@justin_smith now it's doing something else weird
23:52hodwikhttp://i.imgur.com/ssndSUP.png
23:52hodwikHaven't changed anything as far as I can tell, just restarted emacs and went to same point
23:52hodwikAny idea what this is?
23:52hodwik"Namespace not found."
23:55hodwikAnyone have any idea what I'm doing wrong?