#clojure logs

2013-01-19

00:39TimMc&((partial apply map vector) [[1 2] [3 4]])
00:39lazybot⇒ ([1 3] [2 4])
00:39TimMc&((partial apply map vector) [[1 2]])
00:39lazybot⇒ ([1] [2])
00:39TimMc&((partial apply map vector) [])
00:39lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: core$map
00:39TimMc:-(
00:47mikera&((partial apply map vector) [[]])
00:47lazybot⇒ ()
01:40TimMchyPiRion: It begins... https://github.com/timmc/swearjure/blob/master/src/org/timmc/swearjure.clj
01:43callenRaynes: nice work.
01:43Raynescallen: What did I do?
01:43callenRaynes: Imagine Dragons
01:44Raynescallen: Trying to determine how that constitutes nice work.
01:44brainproxyanyone can serve that up on a plate?
01:44callenRaynes: caught me in a good mood.
01:45callenRaynes: trolling people in #startups, hacking on a side project after pizza and beer with my coworkers. It's a good Friday.
01:45Raynescallen: So you're not going to stab me in the face because you hated it, or you're thanking me because you liked it, or...?
01:46callenall of the above.
02:05carkhow would you guys go about mesuring time (say in milliseconds) but in a way that would be consistent even when the user fiddles with the system time ?
02:05carkI know there is the performance counter... but it seems maybe too precise for my use
02:08TimMccark: By the performance counter, you mean ##(System/nanoTime) ?
02:08lazybot⇒ 33290774680106530
02:08carkyes
02:09TimMcWell, it's what you've got, right?
02:09carkright
02:10carkI wonder how precise it is over long durations
02:10carklike hours
02:10carka couple hours
02:11TimMcThis worries me: "No guarantees are made about how frequently values change."
02:11carkyes I don't like it =P
02:12TimMcI *hope* that means changes in offset between JVM runs.
02:12TimMccark: Is this for measuring durations within a single JVM run?
02:12carkmy use case is this : I need to measure time of phone calls, user might be a crook and change the system time in order to pocket the money
02:12carkyes
02:13carkusually i rely on telephony hardware to provide the duration data, but in this case it's all software
02:14TimMcAs long as it's all within one JVM run, you should be fine.
02:15TimMcThe user would probably have to go to quite some effort to affect the nano timer.
02:16carkI'm also a bit warry that it might overflow while i'm measuring a duration
02:16carkwary*
02:21carkanyways thanks for your input !
02:21TimMccark: http://stackoverflow.com/a/4588037/20772 :-/
02:22carkmhh maybe he was at the overflow point
02:23carkthough it would still be positive with java, as the substraction would ...Err underflow
02:23carkmhh
02:23carkneed to do some testing =)
02:24TimMcSubtraction is always safe, you just might get a negative number.
02:25TimMcRelatedly, that's a trick you can use to average two numbers without overflowing on the addition.
02:25carkright, i mean if you substract Long.MIN_VALUE - Long-MAX_VALUE
02:25TimMcOh, I see. Right, you could overflow that way.
02:26TimMcs/safe/safe with two numbers of the same signum/ :-P
02:26TimMcI suppose that's not as helpful.
02:26carkthey say nanoTime might be negative
02:27carkhum btw how can I do overflowing math with clojure ?
02:27andrewdeandradequestion: when entering a multiline expression into the repl, how do i go up one line to change it (because of a typo for example) if I know it is incorrect?
02:28TimMccark: unchecked math?
02:28carkahyes
02:28andrewdeandradesomething like rlwrap looks like it might be able to do the job but I couldn't figure out how
02:28TimMc&(unchecked-add Long/MAX_VALUE Long/MAX_VALUE) ;; cark
02:28lazybot⇒ -2
02:30cark,(unchecked-subtract Long/MIN_VALUE Long/MAX_VALUE)
02:30clojurebot1
02:30carksounds about right
02:31carkandrewdeandrade: I would recommand using a real repl, like emacs+nrepl or any other like it
02:33carkanyways i'll go for breakfast now, thanks for your input TimMc !
02:34TimMcBreakfast... It's 2:22 AM here. >_<
02:35TimMcandrewdeandrade: I don't know of a way to go back and edit previous lines -- I think you're locked in.
02:38andrewdeandradecark: yeah, i'm probably going to end up using emacs... i just wanted to be able to do it with `lein repl` since it's easy to fire up
02:38andrewdeandradeTimMc: thx
02:38andrewdeandradevery unfortunate, but I guess it's just supposed to be uber bare bones
02:38TimMcIt happens in nREPL as well.
02:39andrewdeandradeemacs can't go back and modify the previous line?
02:39TimMcMmm... nREPL may behave differently under Emacs, yes.
02:46ChongLihmmm evil is pretty cool
04:03muhooi have to deal with a java class that DEMANDS only a [Ljava.net.InetSocketAddress]
04:04muhooit won't accept an ArrayList of them. it must be a [Ljava.net.InetSocketAddress . any way in clojure to generate one?
04:06cark,doc make-array
04:06clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>
04:06carkhum
04:13muhoointo-array seems to do it
04:19mikeraanyone here doing matrix / numerics work with clojure?
04:22kevin234Are there alternatives using Java exceptions for error handling?
04:23mikerawhy would you want to avoid Java exceptions?
04:23kevin234The dependence on a class-based filtering mechanism is not very flexible
04:23mikerayou can wrap in a macro if you don't like the syntax :-)
04:24mikerajust catch Throwable, then you can filer however you like
04:25kevin234Not a bad idea, but maybe there is a framework out there that already does that and wraps it all in some macros?
04:25mikerahmm not sure. I have a few macros lying around but nothing like a framework
04:26kevin234guess I need to do some googling
04:26mikeraIf you wrote your own Java exception class that held an arbitrary object
04:26mikerayou could have a pretty flexible error handling framework in whatever style you like
04:27mikeracould make a nice little library. though never really felt the need for it myself
04:30kevin234mikera: looks like I found basically what we are talking about: https://github.com/scgilardi/slingshot
04:31mikeranice! I should have guessed someone has thought of this already
04:43hyPiRionTimMc: Oh, I see. Are we able to find eval and friends?
04:45mmarczykkevin234: see also ex-info & ex-data
05:10kevin234mmarczyk: thanks, looks good
07:25borkdudeSince I keep hearing more about Markdown for writing articles lately, is there a nice example of a Markdown source file including Clojure source highlighting?
07:28xumingmingvI am interested in this topic too.
07:31augustlthere are some syntax highlighting engines that parses HTML, so that's a possible route
07:31augustland of course the in-browser ones
07:33antares_borkdude: clojure-doc.org source
07:33borkdudeantares_ great, tnx
07:33antares_borkdude: github's ``` clojure Markdown extension has been implemented at least in C and Ruby (via bindings)
07:52borkdudeI tried out Markdown for 5 minutes, ran into this issue quit soon: http://meta.stackoverflow.com/questions/23822/markdown-code-block-problem
07:52borkdudequite
08:03antares_borkdude: indentation for code was superceded by the ``` extension (which you can use e.g. if you are writing docs)
08:07borkdudeantares_ ok
08:24nz-technomancy: i missed that one
08:25nz-ops, cut&paste error
09:35bizarrefishLo, all
09:37hyPiRionhello
09:46pure_loulouhello :))
09:47pure_louloui want to get values form a list so i can use theme as values, example '(1 2 3) ----> 1 2 3
09:47pure_loulou i want to get values form a list so i can use theme as arguments, example '(1 2 3) ----> 1 2 3
09:47pure_louloucan i?
09:47Chousuke(apply function list)
09:48Chousuke,(apply + 1 2 3 '(4 5 6))
09:48clojurebot21
09:48Chousukethe arguments before the final sequence are optional
09:48pure_loulou... wait for me to think :)
09:50bizarrefish,(apply print ["this" "is" "an" "argument" "list"])
09:50clojurebotthis is an argument list
09:51pure_louloui want to make '(1 2 3) ---> 1 2 3
09:51pure_louloulike @ in macros
09:51bizarrefishIs there some kind of high performance code generation lib for clojure? I know there are assemblers(well, at least one - lithium), and there's clojurescript, I'm talking about more the C kind of level
09:52bizarrefishExample: (defspeedyprogram [speedyargs] #_(some numbercrunching written in a subset of clojure))
09:53bizarrefishpure_loulou: '(1 2 3 4 5) that's just a sequence, what do you want to get? one of the elements from it?
09:54bizarrefishIf you just want an element, use nth
09:54bizarrefish,(nth '(1 2 3 4 5 6) 2)
09:54clojurebot3
09:55bizarrefishFor random access, though, you normally want to be using a vector [] rather than a list () . If you use a vector, you've got a neat syntax you can use to get at the elements: ([1 2 3 4 5] 2)
09:55bizarrefish,(let [my-vector [1 2 3 4 5]] (my-vector 2))
09:55clojurebot3
09:59pure_louloui want to get all the elements
09:59pure_loulouand use them to call a function
10:00bizarrefishpure_loulou: That's what 'apply' is for. ,(doc apply)
10:00bizarrefish,(doc apply)
10:00clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
10:00AimHere,(apply inc '(1 2 3 4 5))
10:00clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (5) passed to: core$inc>
10:00AimHereOops
10:00AimHere,(apply * '(1 2 3 4 5))
10:00clojurebot120
10:00pure_loulouok guys i will try ,thx :) i am newbie
10:00bizarrefish,(apply print '(1 2 3 4 5))
10:00clojurebot1 2 3 4 5
10:01hyPiRion"(apply + [1 2 3 4])" is the same as "(+ 1 2 3 4)"
10:01bizarrefishpure_loulou: righto, good luck dude
10:01hyPiRionpure_loulou: Don't be afraid of asking :)
10:01AimHereSadly, to confuse things, there are clojure function-like objects (like macros and Java methods) that can't be applied like that
10:02hyPiRionAimHere: Let's not talk about that now :p
10:02AimHereI figured pure_loulou might have to be aware that there might be things later on that bite him. If it happens he can ask
10:02TimMchyPiRion: No, I can't get eval.
10:02pure_loulou(fun '(1 2 3)) ----> 1 2 3 ; as arguments
10:03bizarrefishAimHere: I'm sure he'll find out one way or another :P
10:03bizarrefishpure_loulou: (apply fun '(1 2 3))
10:03bizarrefishThat does the same as: (fun 1 2 3)
10:04hyPiRionTimMc: Ahh. The compiler idea is neat though. With what we have, we should be able to generate working scripts for stuff
10:04pure_loulouyou right i think
10:04pure_loulouthx
10:05hyPiRione.g. "(defn foo [a b c] (+ a b c)) (println (foo 1 2 3))" could be swearjurized
10:05Sgeo_swearjurized?
10:10TimMc~rest
10:10clojurebotrest never returns a unicorn
10:10TimMc~rest
10:10clojurebotrest is easy to write without alphanumerics: https://www.refheap.com/paste/5980
10:10TimMcSgeo_: ^
10:11hyPiRion~swearjure
10:11clojurebotCool story bro.
10:11hyPiRion~swearjure
10:11clojurebotHuh?
10:11hyPiRionhumm
10:11hyPiRion~Swearjure
10:11clojurebotGabh mo leithscéal?
10:11hyPiRionclojurebot: Swearjure is http://hypirion.com/swearjure
10:11clojurebotc'est bon!
10:15Sgeo_ah
10:15clojure-newbhey guys.. this is an emacs question really but I'm trying to learn the favourite productivity editor for clojure debs… in nrepl (via nrepl-jack-in) I get started typing and then just get kicked out with a message 'Buffer is read-only:#<buffer *nrepl-error*>… this was when I started typing (println) just now, any ideas ?
10:16clojure-newbI'm using emacs-live
10:17TimMchyPiRion: Hmm, can we do (boolean ...) in swearjure?
10:17hyPiRionTimMc: Hmm
10:18TimMcboolean takes nil and false to one value and everything else to another -- should be doable with a map.
10:18ziltiIs there some kind of successor to ibdknox' fetch lib?
10:19hyPiRionTimMc: Can we do nil?
10:19hyPiRionas in "nil"
10:19TimMcI'm sure...
10:19hyPiRion,({} (+))
10:19clojurebotnil
10:19hyPiRionOh, sweet.
10:19Sgeo_clojure-newb, there should be another buffer for the REPL itself, I think
10:20Sgeo_*nrepl-error* is a buffer that errors go on
10:20TimMchyPiRion: I've implemented if=, and this will let me generalize to if + =
10:20clojure-newbSgeo_:I was in the *nrepl* buffer, I had already evaluated an in-ms command successfully
10:20clojure-newbbut then as I continued typing (prin… I just got kicked out
10:20clojure-newbstrange… figure there may be some shortcut key getting picked up ?
10:22hyPiRion,(#{1 2} 3 4)
10:22clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (2) passed to: PersistentHashSet>
10:22hyPiRionboo.
10:22TimMcInteresting.
10:22TimMcOh, makes sense.
10:23clojure-newbSgeo_: maybe my workflow is wrong… I start emacs, load a file, split vertically, nrepl-jack-in and then use in-ms to get to where I want to go
10:24Sgeo_Are you sure nothing's throwing an error?
10:24Sgeo_I don't think in-ms exists
10:24clojure-newbsorry… typo.. in-ns
10:25Sgeo_Check what buffer you're in once you jack in, then check what buffer you're in once you in-ns
10:25hyPiRion,(let [ts #(= %& %&), fs #(= `%& %&), nils #({} %&) boolean #((`{~(= + -) ~fs, ~({} +) ~nils} % ts))] (map boolean [nil false true 1 [1 2 3]]))
10:25clojurebot(nil false true true true)
10:25hyPiRionTimMc: ^
10:25clojure-newbSgeo_: will try, thanks
10:25Sgeo_yw
10:31TimMc&({(= :+ :-) (= :+ :-), ({} :+) ({} :+)} false (= :*))
10:31lazybot⇒ false
10:31TimMc&({(= :+ :-) (= :+ :-), ({} :+) ({} :+)} 17 (= :*))
10:31lazybot⇒ true
10:31TimMc&({(= :+ :-) (= :+ :-), ({} :+) ({} :+)} nil (= :*))
10:31lazybot⇒ nil
10:31TimMcHmm, not quite.
10:31TimMc&({(= :+ :-) (= :+ :-), ({} :+) (= :+ :-)} nil (= :*))
10:31lazybot⇒ false
10:32TimMcI don't really need a boolean function.
10:33AimHereCan you do map in your daft swearjure?
10:34AimHereAs in the function map, because then and should be easy
10:34TimMcI think hyPiRion got that working, yes.
10:34AimHereWell map and reduce
10:34AimHereBecause you can just map over {(= * *) (*) (= * +) (+)} or something and then add it all up
10:35TimMcHeh, nice!
10:35AimHereThat only works for true and false, rather than truthy and falsy
10:35TimMcIt doesn't do short-circuiting, of course.
10:45TimMchyPiRion: Roadmap for the compiler: https://github.com/timmc/swearjure/blob/master/src/org/timmc/swearjure.clj#L4
10:49TimMcHmm, I need to walk a tree of code and replace certain forms. Is there a tree-walking thing for that?
10:51hyPiRionAimHere: I got mapv
10:54hyPiRionAnd yeah TimMc, boolean wasn't working. It was just mapping truthy values to true.
10:54hyPiRion* my boolean attempty
10:55AnderkentTimMc: do you need to understand the code or are you just treating it as nested lists?
10:55TimMcNested lists, maps, vectors, maybe even records.
10:56TimMcHmm... I do need to understand it a little bit.
10:56AnderkentRight. You can take a look at how cloverage does code instrumentation - i don't think there's anything out of the box that can walk code sanely
10:56Anderkenthttps://github.com/lshift/cloverage/blob/master/cloverage/src/cloverage/instrument.clj
10:56TimMcI want to find certain (very simple) patterns in the code and replace them.
10:56TimMcThanks! I'll take a look.
10:58TimMcIdeally I'd say (walk form dispatch-fn), where dispatch-fn is handed a node and asked for a replacer-fn, which could be nil.
10:58clojurebotRoger.
10:58TimMcclojurebot: You suck.
10:58clojurebotIt's greek to me.
10:58TimMcThis would be a neat lib, but it feels like it should exist...
11:00TimMcFor now I'm just using with-redefs on gensym to make my tests easier, but later I'll need something production-capable and more complicated.
11:00TimMc(I'll need to find and replace function calls.)
11:02AnderkentTimMc: right. That's on our todo list for cloverage - but I mostly work on it in my free time nowadays (since it fulfills the primary purpose decently already). instrument/wrap knows how to recurse into forms, extracting it out to something more generic shouldn't be too hard
11:02TimMcAnderkent: I'd be happy to drop work on this swearjure silliness and build a lib for that.
11:04TimMcHaha, whoops -- gensym isn't a great thing to redef.
11:04hyPiRionTimMc: Grats on breaking Clojure :p
11:04AnderkentTimMc: feel free, cloverage is epl :) Unfortunately there's a bit of code-coverage logic mixed with code-walking logic in instrument. Feel free to ask any questions here or via github
11:05qzwhat is preferred way to call a function for every item in a seq? i do not care about results, so maybe there's something better than map..
11:05Anderkentqz: doseq
11:05Anderkentah wait not quite I suppose
11:05hyPiRion(alter-var-root #'gensym memoize)
11:05hyPiRionSmartest thing ever.
11:05TimMchyPiRion: Glorious.
11:06TimMcAnderkent: doseq sounds good.
11:06Anderkent,(doc dorun)
11:06clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
11:06TimMc&(doseq [x (range 3)] (println x))
11:06lazybot⇒ 0 1 2 nil
11:06Anderkentyeah I think doseq is the way to go
11:06qzAnderkent: aha, thanks
11:06AnderkentI was looking for something with the map syntax
11:07qzAnderkent: i thought there's something like map but that doesnt care about result, like .each vs .map in ruby
11:08Anderkentqz: yeah doseq does that in the general case.
11:11TimMcqz: Another difference is that doseq is eager and map is lazy.
11:12TimMc&(map println (range))
11:12lazybotjava.lang.OutOfMemoryError: Java heap space
11:12qzTimMc: yeah, i need eager evaluation
11:12TimMcHmm... that depends on how lazybot builds a response, I guess.
11:12Raynes&(let [foo (map println (range))])
11:13lazybot⇒ nil
11:13qzalso, what's preferred way to create locals in a function? def or let?
11:13Rayneslet.
11:13Anderkentqz: let. def declares global vars
11:13RaynesNot only is def not the preferred way, it is never used for that purpose ever at all.
11:13rkzwhat are people using for oauth2? clj-oauth2? looks like it's not merged pull reqs for 5 months
11:13qzi see, thanks. i'm total newb to clojure..
11:15TimMcqz: In scheme, define can be used to create locals, which trips a lot of people up who are used to that. :-)
11:16qzTimMc: wish i knew scheme, this is my first lisp-like language.. :)
11:16carkqz : the parenthesis are a give away : (let [a 12] (func a)) .. it clearly shows that a is used in the scope of the let form
11:18Anderkentrkz: which clj-oauth2 are you looking at? The canonical one seems lively
11:19qzcark: yeah, i see..
11:19rkzAnderkent: looking at https://github.com/DerGuteMoritz/clj-oauth2 but i see that's not the one on clojars?
11:20Anderkenthttps://github.com/clj-oauth2/clj-oauth2 seems to be the one to use
11:54TimMcAnderkent: I'd like this tree-walking function to accept a single dispatch fn, which can either instruct the walker to A) replace the node using a returned fn, B) stop descending into this node, or C) keep descending.
11:55TimMcAnderkent: I was going to use nil to indicate "keep descending, I'm not interested in this node", but I don't have a way to ask it to stop -- and keywords can be valid fns.
11:56AnderkentTimMc: isn't just returning the form unchanged sufficient to stop?
11:57TimMcAh... right. :-)
11:57Anderkentor do you want to recurse into the returned node?
11:57TimMcReturn identity.
11:57Anderkentyep :)
11:57TimMcNope, any replacer fn will have to recurse to the walker again if it wants to process children.
11:57Anderkentyeah, that makes sense
11:58TimMcThat gives it a choice of whether to pre-process or post-process, for instance.
11:58Anderkentyou run into stack depth issues though if it would be a common case
11:59Anderkentactually nvm
11:59Anderkent:P
11:59TimMcI guess we don't know how deep this data structure might be.
12:01Anderkentunlikely to be an issue, and since the walker would probably be recursing as well you're not losing anything by having it done in the replacer
12:01TimMcWell, the walker could use trampolining or maintain its own stack (I think...).
12:01TimMcExplicit recursions back to the walker would be unavoidable stack allocations.
12:02Anderkentwell, the need for that depends on your input type... If you're working on human produced code, don't bother
12:02Anderkentgenerated code might be more problematic since it can be arbitrary deep
12:05Anderkentwell, I'll be off now. If you work on this based on cloverage, do contact when you have any questions - my github's https://github.com/JacekLach
12:05TimMcCool, thanks.
12:05djwonkis it considered good/bad/otherwise to define a function in a custom namespace that shadows a core function?
12:06TimMcdjwonk: It can be confusing, although the :refer-clojure in the ns will alert callers to be on the lookout.
12:06TimMcIt's only really a problem if someone :uses the ns, such as from the REPL.
12:07djwonkTimMc: all and all, probably safer to avoid the name collisions, then? unless there is some compelling reason
12:07TimMcYeah.
12:08djwonkok, thanks
12:08TimMcYou can also get some really entertaining bugs if you shadow a core fn with a local, but that doesn't mess up other people's namespaces.
12:09TimMcI keep catching myself using 'name as a local...
12:09djwonkTimMc: that sounds like a great way to make life interesting
12:10Anderkentdjwonk: you may also get some AOT compilation issues if the shadowed function is used in something like gen-class
12:10TimMcORLY?
12:11djwonkI was hoping to keep function names short. So instead of policy/policy-name I was hoping for policy/name
12:11AnderkentTimMc: it's only when you dont refer-clojure :exclude [whatever-clashes]
12:11TimMcAnderkent: So it only happens when you ignore compiler warnings? I'm fine with that.
12:12djwonk~(doc refer-clojure)
12:12clojurebotdefmulti doc is ugly
12:13AnderkentI think I had that issue with drift-db I believe : https://github.com/macourtney/drift-db/pull/2
12:13Anderkentdjwonk: it's a key on the ns macro
12:13djwonkAnderkent: I'll check it out
12:14djwonk,(doc refer-clojure)
12:14clojurebot"([& filters]); Same as (refer 'clojure.core <filters>)"
12:14TimMc,(refer-clojure :exclude '[name])
12:14clojurebotnil
12:14TimMc,name
12:14clojurebot#<core$name clojure.core$name@6e56103e>
12:15TimMcThe :exclude thing only works on clojure.core when used in the ns block.
12:16AnderkentTimMc: that's assuming you have a ns block. If you don't it will work (i.e. it will work the first time clojure.core is referred into the ns)
12:16TimMcHmmm.
12:16djwonkAnderkent TimMc thanks that saves me some warnings
12:24TimMc&(map #(when-let [[f & r] %] [f r]) [nil () [1]])
12:24lazybot⇒ (nil [nil nil] [1 nil])
12:37tomoj(ns foo (:import-clojure))
12:37tomojthat's basically the default in clojurescript, right?
12:39jamiei_amalloy_ bbloom: Thanks for both of your help a couple of days ago with my ns clause problem. Whichever of you suggested the mis-declared defn was absolutely correct. :)
12:40pure_loulouhello :)
12:40TimMc&(empty (range))
12:40lazybot⇒ ()
12:40pure_louloudo you know how to make '(1 2 3) to (1 2 3)
12:41djwonkpure_loulou: not sure what you mean. `(1 2 3) evaluates to (1 2 3)
12:41djwonki meant single tick, not `
12:42TimMcpure_loulou: What's this for?
12:42pure_louloui know wait to ask better thx :)
12:42pure_louloumacros is confusing... at first
12:43djwonkpure_loulou: you are making a macro?
12:43mike_17hi room, have a clarification in enlive. Is (h/select nodes [:a.link-rss]) and (h/select nodes [:a (h/attr= :class "link-rss")]) the same thing?
12:43pure_loulouyes
12:47mike_17I have a class with a name containing space, how can I select it using enlive - I tried some thing like (h/select nodes [:a (h/attr= :class "link rss")]) , but it doesn't work, do you guys know of any way to do it
12:48djwonkmike_17: I haven't used enlive
12:48TimMcmike_17: Classnames don't contain spaces. Try .link.rss
12:49tomojif you had a data structure that implemented both IPersistentVector and IPersistentMap.. that would be bad?
12:49djwonkmike_17: right, you defined two classes, separated by a space
12:50mike_17any enlive experts here?
12:50mike_17sorry didn't saw the response
12:51djwonkmike_17: just to clarify, in your HTML source, if you do class="link rss" you are really applying two CSS classes
12:51tomojI guess it's just that people don't consider the case that (and (map? x) (vector? x)) when using map? and vector?
12:51TimMctomoj: I think they're incompatible.
12:52TimMcWhat happens if I (assoc ... 0 :whoops)?
12:52djwonktomoj: do you want an ordered map?
12:52tomojI have that, from flatland
12:52djwonkthat preserves insertion order? some other kind of order?
12:52tomojinsertion order, yes
12:52tomojthose can implement IPersistentStack
12:52tomojbut they can't implement ITransientStack cus there isn't such a thing
12:53tomojpop! is in ITransientVector
12:53tomojbut really, they _could_ implement IPersistentVector too, yes?
12:53mike_17TimMc: let me try that , djwonk: yes you are right - let me also see if there are ways to match two :class values
12:53djwonkmike_17: keep it simple if you can. match one unless you have to match two
12:54tomojTimMc: assoc just calls .assoc, IPersistentVector also has .assocN
12:54tomojso the .assoc would expect keys, .assocN indices
12:54tomojdunno what would break
12:55djwonktomoj: oh! you are using flatland. ok, well you are way ahead of me
12:55tomojI just implemented IPersistentStack and then noticed the transients
12:56tomojadmittedly I don't have any use case for pop! or IPersistentVector :)
12:58tomojTimMc: oh, right, someone might see (vector? x) and then assume they can sensibly (assoc x 0 :whoops)
12:58tomojsince there's an informal correspondence between the assoc and assocN of a vector
12:58tomojand its ILookup and Indexed
12:59tomojat least there is nth there
12:59tomojwhy not assoc-nth?
13:00tomojbecause there were no data structures that could do both differently?
13:01hyPiRiontomoj: assoc-nth? How does that make sense?
13:01mike_17djwonk: I could select them by just using .rss class, however it selects all rss tags, I wanted to filter only the .rss class tags which contains "info" in their url , I am doing this - (h/select mcnodes [:a.rss (h/attr-contains :href "info")])
13:02hyPiRionWouldn't assoc be enough? I mean, I can't think of any data structure where both assoc and assoc-nth would make sense.
13:02mike_17but it does it work, I could list all the :a.rss tags and see that some contains the string "info" in their url
13:03mike_17is this the right way to use (h/attr-contains) ?
13:04TimMcDoubtful. Space-separated attributes like classes need special handling.
13:04TimMcHave you tried :a.link.rss ?
13:06mkwhat does Compiler.load() do that Compiler.eval() does not?
13:07djwonkmike_17: I haven't used enlive but … what TimMc sounds worth trying
13:08djwonki see that [] in enlive means 'and' / intersection, so I'm sure you'll get it with some expermentation
13:09djwonkthe battery is low, so I'll see y'all later
13:09tomojhyPiRion: uh. an ordered map. see above :)
13:09mike_17TimMc: : nope, I could just select all the :a tags with "rss" class as [:a.rss], now I have to filter only the links having "info" in the :href attribute ie < a href="../../info/xyz.asp" class="link rss"/>, I tried [:a.rss (h/attr-contains :href "info")] but it doesn't work
13:10TimMcmike_17: Did you try :a.link.rss as I suggested?
13:10mike_17let me try that as well
13:11hyPiRiontomoj: When is that practical? I can't currently see any semantics where it would be useful, but I'm open to suggestions
13:12TimMcAnderkent|away: OK, I think this is all I need for my own project -- does it work for your as well? https://github.com/timmc/arborist/blob/master/test/org/timmc/arborist_test.clj
13:15mike_17TimMc: man, it works, thx a lot... now I am filtering the nodes that only contain "info" in :href, I am doing this outside (h/select) at present using (filter #(re-find #"info"(:href (:attrs a)), is there a better way by including it as a part of selector itself?
13:15TimMcNot sure, I haven't played with Enlive in a bit.
13:17mike_17ok np
13:19mkwhat must I do to read and eval clojure from java?
13:21mkI used Compiler.load(StringReader...), but this does not give me the form. Now I'm using LispReader.read(...), but this is giving me "Can't change/establish root binding of: *ns* with set"
13:22mkSorry, it's not load that throws that, but Compiler.eval(). I don't think I understand how and why thread-local is being used here
13:23TimMcmk: The goal is to read serialized Clojure data off of disk?
13:25mkI want a toy repl that can read a clojure file (or string) as if clojure was reading it itself
13:26TimMcWhy aren't you using clojure's own REPL libs then?
13:26mkso for example, I don't want to be put into a user namespace, and I'd like it to handle (ns) properly
13:27hyPiRionmk: Reading the clojure repl implementation should help immensely
13:27mkTimMc: have not discovered them via google, I suppose
13:29TimMcmk: https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L186
13:29mkhyPiRion: I think I have it (Repl.java?), however it puts me in the user namespace and initializes the 123* variables
13:29TimMcAnd there's nREPL as well.
13:30hyPiRionmk: https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj
13:31mkI mean, what I want to try messing with in the end is loading a line form by form and inspecting what the objects look like in eclipse debug
13:32mkI've been looking at http://code.google.com/p/clojure/source/browse/trunk/src/jvm/clojure/lang/Repl.java?r=1160
13:46tomojwhen do you ever actually need to put nil in a map?
13:47bbloomtomoj: when nil means something :-P
13:47Raynes&(contains? {:foo nil} :foo)
13:47lazybot⇒ true
13:47Raynes&(contains? {} :foo)
13:47lazybot⇒ false
13:48bbloomi have a tree of maps that represents an index and sometimes an intermediate value in the index can be nil
13:52mkwhat is an unbound function?
13:53TimMcunbound var, you mean?
13:53TimMc(declare foo) should do it.
14:23tomojbbloom: ah, right, of course
14:24tomojit's great that you can't have a nil attribute value in datomic
14:34TimMcI want to map over the contents of a collection and give back something of the same type -- in the same order.
14:34TimMc(Obviously sets and maps are exempt from that last bit.)
14:36TimMc&(map #(into (empty %) (map inc %)) '[[0 1 2] (0 1 2)])
14:36lazybot⇒ ([1 2 3] (3 2 1))
14:39mkTimMc: this is conj at work. You might look at the source at http://clojuredocs.org/clojure_core/clojure.core/into and see if you can get rid of conj
14:43tomoj&(map (partial clojure.walk/walk inc identity) [[1 2 3] '(1 2 3)])
14:43lazybot⇒ ([2 3 4] (2 3 4))
14:43mkhttp://pastebin.com/TrxZpc9k "Attempting to call unbound fn". Why? This is java, but I'm just trying to replicate Compiler.load https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L7031
14:47mkwhat would it mean for the fn to be unbound in that case? It's defined after an (ns).
14:47yogthostomoj: I think this would be better no? (clojure.walk/prewalk #(if (number? %) (inc %) %) [[1 2 3] '(1 2 3)])
14:48mkyogthos: no because you don't want it to be silent if you accidentally try to use it to increment strings, you want it to blow
14:48yogthosmk: ah
14:55TimMcI think I'll just bail on any sequential? that isn't a list? or a seq? -- client code can handle this itself.
14:55TimMc(or a vector?)
14:55Bronsacoll?
14:55clojurebotseqs and colls is http://www.brainonfire.net/files/seqs-and-colls/main.html
15:02mkmy issue was that LispReader reads forms one at a time: it read and evaluated the (ns) form, but did not read the (defn) form, so of course the function had not been bound when I tried invoke
15:11amalloyTimMc: clojure.walk/walk?
15:11amalloyor use fmap
15:12amalloywhich is in old-contrib somewhere, and maybe ported to new?
15:12TimMcamalloy: clojure.walk didn't do what I wanted.
15:12TimMcAnyway, I got it working.
15:13ferdI cannot make wrap-json-response (from ring-json) work with my compojure routes... A quick look tells me they might not be compatible, given that a Compojure route handler does a "render" at the end, and that happens before wrap-json-response. Am I missing something obvious?
15:14amalloyyes
15:14amalloyrender happens inside the heart of ring, long after all your handler code has happened - wrap-json has had plenty of time to work
15:17ferdyou meant "render happens inside the heart of *compojure*" right?
15:21amalloyit might. i think it's ring, though
15:21ferdmind that I'm talking about the json *response*... wrap-json-body works find 'cause it handles the request before compojure
15:23ferdon the way back though, my compojure handler "renders" the response... so it messes with my clojure map before wrap-json-response gets a chance
15:24weavejesterferd: You need to do something like (response {:foo "bar"}) for it to work
15:24weavejesterOr {:body {:foo "bar"}}
15:25ferdweavejester: thanks will try
15:25ferdwas thinking of a way to: (unextend-protocol Renderable APersistentMap) ;-)
15:27ferdweavejester: working, thanks agian
15:27ferd*again
15:28weavejesterNo problem
15:28weavejesterIt's a little annoying to have to do (response {:foo "bar"}) instead of {:foo "bar"}
15:28weavejesterBut without that you wouldn't be able to do redirects or any other kind of response.
15:29weavejesterAnd rather than guess what map is a response and what map isn't, it's better to just make sure the JSON map is in the response body
15:30ferdgot it
15:33ferdactually... it's not working yet :-\
15:37TimMcAnderkent|away: I released [org.timmc/arborist "1.0.0"]. Let me know if you end up using it.
15:43ferdweavejester: found the problem... in some cases I'm returning a Seq... and wrap-json-response explicitly checks for vec? or map?. Why is that check in there?
15:43weavejesterferd: Because seqs already mean something in Ring.
15:45ferd:-(
15:47gfrederickswhat do seqs mean in ring?
15:47weavejestergfredericks: They're used for lazy responses
15:48weavejestergfredericks: So if you specify a lazy seq as the body of a response, it will be streamed to the client as it is consumed.
15:49ferdweavejester: thanks again and again. looks like I might go back to my "to-json" function for response
15:49gfredericksso wrap-json-response tries to allow both json data structures and lazy other things
15:50weavejestergfredericks: wrap-json-response tries to play nice with base Ring, so it only interprets data structures in the body that have no meaning to Ring.
15:51weavejesterBut thinking about it, perhaps I should make it an option instead.
15:51weavejesterLazy seqs are not often used as response bodies, and one could just wrap the JSON middleware around a subset of routes.
15:53ferdweavejester: I like that
15:54gfredericksyeah, I don't like the idea of an API distinguishing between vectors and seqs if it can be avoided
15:56gfredericksc.c/rationalize seems like magic
15:57bbloomhow do people ever do anything useful when all their data types don't have a sane notion of equality?
15:57ferdgfredericks: didn't know about it. Reminds me of old times with my hp48
15:57gfredericksI just don't know how it does what it does. I suppose the magic is in BigDecimal/valueOf
15:58gfredericksit must be a bunch of fudging
15:58gfredericks,(rationalize (/ 1.0 3))
15:58clojurebot3333333333333333/10000000000000000
15:58gfredericksah ha nevermind it's not magic
15:58Anderkent|awayTimMc: you don't want to use `list?` for code
15:58Anderkent|away,(list? `(1 2 3))
15:58clojurebotfalse
16:00Anderkent|awayother than that I'd have to think a bit whether using that would make my code cleaner :P
16:02frozenlockJust before I start coding, did anyone made the github-like next/back animation for clj/cljs? https://github.com/blog/760-the-tree-slider
16:04TimMcAnderkent: I check for both seq? and list?, actually.
16:09AnderkentHm. Okay, I s'pose. I'd like it more if there was lazy-seq? and Cons'es were handled eagerly, but oh well
16:10Anderkentas to use for cloverage, after consideration I don't think there'd be much point - I'd find myself doing a transform on every step and manually calling the recursion.
16:18TimMc*nod*
16:19gfredericksTimMc: I expect seq? is always true when list? is true
16:19gfredericksat least for the normal types
16:20TimMcInteresting point about Cons vs. lazy-seq? -- I'll have to think about that.
16:38pure_loulouhello :)
16:42pure_loulou(bindings [ x_from_macro value_from_macro ] ...) i tried to make it work but i had some problems
16:42xybreI'm seeing talk of JSdoc type hinting for a Clojure->JS compiler.. does this have anything to do with ClojureScript and the [#^String s] notation?
16:42gfrederickspure_loulou: maybe give a gist of an actual example?
16:43gfrederickspure_loulou: I can't tell what you mean from that line
16:43pure_loulouok :)
16:43pure_louloui wanted to evaluate a random boolean formula like (and a b),with local vars
16:43pure_louloui didnt know the formula
16:44gfredericksyou want to temporarily redefine a macro?
16:44pure_louloui had problems doing it
16:45pure_louloui stuck i am newbie
16:45gfrederickslots of subtleties here; some context would help
16:45gfredericks,(let [and +] (and 1 2 3))
16:45clojurebot6
16:46pure_louloui wanted to evaluate a random boolean formula,
16:47pure_loulouso i used for the symbols local vars
16:47pure_loulouand i macro to determine the random bindings
16:47gfredericksyou have a formula like (and a b (or c d)) and you want to give a,b,c, and d random values?
16:48pure_loulouyes
16:48xybre(not= "Clojure Compiler for JS" "ClojureScript") => yes/no?
16:50bbloomxybre: yes, clojurescript is currently a subset of clojure
16:50gfrederickspure_loulou: well I imagine you can use the normal values of and/or; is this formula literally nothing but and, or, and variables?
16:50bbloomxybre: it's the runtime subset, specifically
16:50pure_louloui wanted to evaluate a random formula,for random values
16:51gfrederickspure_loulou: I'm thinking wrapping the formula in a let where you assign the values, and then evaling it
16:51gfredericksfirst step is to figure out what variables it has
16:51xybreSo, Clojure just has a source to source JS compiler?
16:52pure_loulouthat will need a let difined from a macro i think
16:53pure_louloudynamic let
16:53dnolenxybre: yes
16:53gfrederickspure_loulou: you shouldn't need a macro if you're using eval directly; I'll have some code in a seond
16:54pure_loulouok :)
16:54xybreOkay, that makes sense.
16:54xybreAnd the Clojure compiler has support for comments that alter code functionality like: /** @type {String} */?
16:55dnolenxybre: the missing non-concurrency related bits will likely get worked in as we head to towards optional bootstrapping.
16:56bbloomxybre: the cljs compiler emits a minimal set of Google Closure type hints, etc
16:56gfrederickspure_loulou: https://www.refheap.com/paste/8791
16:56bbloomxybre: basically only what's needed for compilation, like @constructor
16:56gfrederickspure_loulou: the eval approach assumes you don't have the formula until runtime. if you have it at codetime then presumably you could use a macro, yes
16:58dnolenxybre: there are no hooks for optional type checking via GClosure.
16:59pure_loulougredericks thx alot i will read your code
16:59gfrederickspure_loulou: probably should have wrapped line 3 in distinct or set, but it shouldn't change how the code works
17:00xybreThanks bbloom and dnolen, I can tell I need to read more, there's a lot going on that I'm not familiar with yet :)
17:01bbloomxybre: the cljs compiler code, despite being a bit messy, is actually quite straightforward and understandable. you can probably just jump right into to analayzer.clj and then take a look at compiler.clj
17:01pure_louloui have some troubles with symbols like ' ` @ , but i started a week ago
17:01pure_loulouthx i will retry
17:03bbloomxybre: it's in the clojurescript repo
17:04xybrebbloom: oh I misread, but coincidentally I just cloned the clojurescript repo too
17:07bbloomi really like the signature of add-watch and remove-watch
17:07bbloom(add-watch reference key fn) and (remove-watch reference key)
17:08bbloomb/c most addListener things are basically key==fn
17:08bbloombut ::foo or some meaningful key is just so much easier to remove later
17:08bbloomthe other option i like is having the listen function return the unlisten function
17:09bbloomb/c then you don't need two bits of info to remove the listener
17:09gfredericksrobert.hooke uses the key approach, but makes it optional; you can pass in the function itself to remove
17:10gfredericksthe keyless version just defers to the keyed version with key==fn
17:10bbloomcan you always do that? or only if you omit the key
17:10bbloomyeah, that's what i thought
17:10gfredericksthe only case I can recall of a function being used as a map key intentionally
17:11bbloom*shrug* i've done it a few times
17:51bbloomtechnomancy: since you warned about signing up talks with unfinished code: i now consider it done-enough-to-release, but i'll permit it to continue baking until my talk :-)
17:54gfredericksbbloom: I intend to go the heck to that talk
17:55bbloomgfredericks: i'm glad people are interested :-)
18:05seangroveJust as a bit of a crazy whim, I'd like to be able to mark a function with metadata like ^:transparent/pure, and have the compiler give me warnings if I referenced any variables that weren't passed in as arguments (checking outside atoms, etc.) or if the function made function calls to other functions and didn't pass any arguments to it (probably relying on state)
18:06seangroveSeems like that shouldn't be impossibly hard as a compiler pass in cljs if I'm able to load a module to analyze the AST info?
18:06seangroveJust idly speculating, not likely to jump on this any time soon at all
18:07gfredericksseangrove: not caring about the false positives?
18:08seangrovegfredericks: False positives from what?
18:08gfredericksseangrove: e.g., calling functions that do rely on state even though you passed them arguments
18:09gfredericksyour checks would say that's a pure thing to do even if it isn't
18:09seangroveAh, yes
18:09seangroveThe metadata would be something like "please check this function for basic signs of not being X"
18:10seangroveIt'd be nice as a code style linter
18:12amalloyi think the difficulty of that problem is somewhere between "solving the halting problem" and "reimplementing clojure"
18:13amalloyeven a half-assed solution that barely works is going to be a lot harder than you thing
18:23technomancyamalloy: I bet typed clojure could do it with some tweaking
18:26bbloomthe real issue is that consuming memory is a side effect ;-)
18:26bbloomit's the whole thing with transients: if a tree falls in the forrest and whatnot
18:27bbloomif i use an atom in my observably pure function, i don't want my function being marked impure
18:27technomancyeasy enough to just allow for metadata to override inference errors
18:28bbloomsure
18:28bbloomi've wondered what an "associative" type system would look like
18:28bbloomrather than saying "the type of X is Y" it would be like "well, X implements method F and has linear runtime in terms of (count Y)"
18:29bbloombut those facts also need to be labeled as inferred, asserted, or provable :-)
18:30bbloomseems like an area of research for some codeq fans!
18:39aaelonyhmmm, I'm processing large files and i'm tempted to use promises when I encounter incomplete lines. Typically, an incomplete line will have 2 or 3 lines that make it whole later in the lazy-seq, and at that point the promises would be realized and delivered. curious as to what people would suggest...
18:39seangrovebbloom: Well, it's be nice to know where I have implicit state I could (possibly) clean up
18:40bbloomaaelony: i recently discovered that this is what the haskell people call a "finite state transducer"
18:40bbloomaaelony: https://github.com/brandonbloom/fipp/blob/master/src/bbloom/fipp/transduce.clj#L26-39
18:41aaelonybbloom: thanks, I'll look that up. I'm sure it's a fairly common problem, likely with some design pattern around it
18:41aaelonyawesome, thanks for the link :)
18:41bbloomthat's with reducers, but it's even easier to do with a lazy seq
18:41aaelonyI'll likely need reducers too
18:42bbloomso if you don't care about losing laziness, reduce into a vector
18:42aaelonyI'm thinking of using partition-all on a large lazy-seq and wrapping each partition in a future
18:42aaelonyI'll look to match the incomplete only within a partition since the incompletes are relatively rare and the partitions will be large
18:43bbloomhmm, that'd be a good trick, then you just apply concat on those ?
18:43aaelonyI don't know concat that well, but perhaps that's the angle I need...
18:44bbloomyou could probably skip the futures all together if you buffer during transformation
18:44amalloywhy would you wrap the partitions of partition-by in a future? they're not lazy
18:44aaelonybasically applying a fancy regex to a string in each line, and further exploding information out
18:44bbloomthat's what the "finite state transducer" is about. it's a map or reduce or similar transformation that proceeds linearly and preserves some state in the machinery of it... ie a buffer
18:44aaelonyI'd like to parallelize as much as possible
18:45aaelony…and make it as fast as possible
18:45amalloyso why not write (@(future +) @(future 10) @(future 9))? wrapping a value that's already computed in a future doesn't do you any good
18:46aaelonyamalloy: not sure I understand what you mean. my thought was to wrap a function that does a bunch of stuff on a line or set of lines in a future
18:46amalloyyou said, wrap each partition of partition-by in a future
18:47aaelonypartition-all
18:47amalloywhich sounds like you mean you want the partitions to be computed in a different thread
18:47aaelonyyes, that's right
18:47amalloyif you have some function, which you want to run in parallel on a different thread per partition, that's fine and works
18:47amalloybut computing the partitions themselves in a future is not possible
18:47aaelonythe former
18:48aaelonythe only reason to partition at all is to get some leverage out of parallelization
18:49bbloomaaelony: make it work... THEN make it fast :-)
18:49aaelonyI think I need partition-all because I don't want to lose the partitions that don't have all the elements in the last partition
18:50aaelonybbloom: heheh, true. It's about half of both right now ;)
18:50aaelonyactually, quite fast, but need to add the processing of incompletes into the mix
18:51aaelonyi think its faster than hadoop, so far…
18:51aaelonybut haven't tested enough
18:57rkzanyone know how to get something like python's pdb.set_trace() to work? I tried (debug-repl) in a route handler but it doesn't pause execution
18:58rkzor general debugging in nrepl, cdt doesn't seem to work
19:05scottjrkz: maybe look at ritz
19:10rkzlooks good
19:10rkzthanks
19:32tomoj&((juxt identity class) (gensym :foo))
19:34djwonkwhat's the clojure helper library for finding functions based on input and output?
19:38Anderkentdjwonk: findfn
19:39djwonkAnderkent: right! thanks
19:59majykI'm a Clojure n00b and I'm trying to write a naive directory tree walker using recur and I'm getting an error saying that recur is not in the tail position. I've Googled but I cannot figure out why what I've written is wrong. Can anyone help me? https://gist.github.com/4576052
20:00majykI know there is support in clojure.java.io to assist in walking a directory tree but I'm trying to learn how to write a recursive function
20:00bbloommajyk: tail position does not mean "at the end of the function" it means that no evaluation occurs after it
20:00bbloomin this case, that doseq wraps the recur
20:00majykah okay
20:01bbloommajyk: the purpose of recur is to have the compiler enforce that you won't use any stack space for a recursive or iterative algorithm
20:01bbloombut in this case you DO want to use stack space: you need to come back to go on to the next branch of the walk
20:01bbloomso instead of (recur file) you can (walk file) to get a non-tail-recursive algorithm
20:02seangroveIs there a function that given a hash-map and a list of keys, returns a new map identical to the original *except* for keys specified in the list?
20:02seangroveSomething like (without {:a 10 :b 100 :c 4 :d "a"} [:a :c :d]) => {:b 100}
20:03majykbbloom, thank you. I'm going to try this
20:04bbloommajyk: if you want to learn about tail recursion, change your let statement to be a loop and include an explicit stack: (loop [stack '() f (File. dir)] ...)
20:04bbloommajyk: then use recur with two arguments
20:04majykbbloom, okay thank you. I'll dig into to this.
20:05amalloyseangrove: ...apply dissoc?
20:05seangrove,(apply dissoc {:a 10 :b 100 :c 4 :d "a"} [:a :c :d])
20:05clojurebot{:b 100}
20:05seangroveamalloy: Err, sorry, that should've been pretty clear
20:07seangroveand thanks
20:29bbloomthe syntax of tagged literals just *feels wrong*... it's the only unary prefix operator that has a space between the operator and the operand
20:29bbloom#foo/bar{:x 1} seems reasonable for maps, but #foo/bar :keyword just seems wrong
20:30bbloombut that's not even valid tagged literal syntax for the map, since the lack of space implies it's a record
20:30bbloomhmm i guess metadata is a unary operation.... ^:foo :bar
20:31bbloom*shrug* still feels a tag weird
21:15tomojthrow+ is nuts
21:16tomojI never really experienced "if you do weird shit, unfamiliar people trying to read it will be very confused"
21:17tomojfirst thing I did in a port to ex-info was remove the +, then I tried to understand what was inside the throw+, forgetting about the +
21:20bbloomtomoj: slingshot?
21:21tomojyeah
21:21tomojI just noticed it actually throws ExceptionInfo now
21:21tomojand that gets a map of the environment, which is neat
21:22bbloomtomoj: seems pretty odd to me that it has it's own pattern matching facility
21:22tomojand that throw+ bundles format and sets up a binding for %
21:23tomojI guess you can just (throw+ map str) if you want
21:24bbloomi don't think a single one of my clojure projects ever catches an exception....
22:00technomancybbloom: the plan at one point was to integrate core.match
22:00technomancyit's not really pattern matching so much as a flexible predicate specification
22:00technomancybut I agree that the ability to throw arbitrary objects is kinda nuts
22:01bbloomseems like one should just *always* throw a map and that all unnamespaced keys be reserved for use by the system
22:02n_bI'm getting a Java OutOfHeap error with the following code when attempting to partition the 'fna var: https://www.refheap.com/paste/8799 ; I assume that it's realising the entire file into a string that's causing it?
22:03bbloomn_b: how large is the file?
22:03n_babout ~3.5MB
22:03bbloomn_b: how large is your heap? :-)
22:04bbloombut yeah, that's likely the issue... you're not just allocating 3.5MB
22:04n_bYea, that's what I expected
22:04bbloomyou're also allocating a string per line segment and then a sequence and some other junk
22:04bbloomshouldn't be TOO big, but apparently it is
22:05n_bReally I'd like to write it in a way that's as lazy as possible
22:05bbloomcheck your heap size & if it's low, try setting the jvm-opts
22:05amalloyhe's holding onto the head of the whole thing for no reason. you could easily do this totally lazily
22:05bbloomsorry, yeah dur, clearly amalloy is right (again)
22:05n_bjust do it all within the the reader context, right amalloy?
22:05amalloyi don't know that i can write it just from looking at this code though, because find-open-frames is nonsense. what is it supposed to do?
22:05amalloyyes
22:07Bronsakjhlkjhl
22:07Bronsawhops. wrong buffer.
22:09n_bIt's meant to find the long nucleotides within a genome, which are comprised of 3-char sequences and end when the pattern "TAA" is hit
22:10n_bso the input file is a very, very long sequence of strings like "CATTAAAGGACACGCT"
22:11n_bso this can be easily done recursively I suppose
22:19amalloyand each line's length is divisible by three?
22:44alex_baranoskytechnomancy: a site I've had up on Heroku for a long time, but which I haven't gone to in months doesn't seem to work anymore. Did something about Heroku change that would cause an old Noir site to no longer work?
23:11technomancyworks fine now
23:11technomancymust have been idling
23:12ludston.(range 0.1 1 0.1)
23:13ludston@(range 0.1 1 0.1)
23:13ludston&(range 0.1 1 0.1)
23:14ludstonLazyBot is dead?
23:14mattmosslazybot appears to be awol
23:15ludston,(range 0.1 1 0.1)
23:15clojurebot(0.1 0.2 0.30000000000000004 0.4 0.5 ...)
23:15mattmossYay floating-point!
23:15ludstonIs this a bug, or is that expected?
23:15mattmossMaybe, and mayhaps?
23:16mikeraexpected
23:16mikeradoubles can't express 0.3 exactly
23:16mattmossMany numbers cannot be represented exactly in FP. 0.3 would appear to be one such
23:16mattmoss,0.3
23:16clojurebot0.3
23:16mattmoss,(+ 0.1 0.2)
23:17clojurebot0.30000000000000004
23:17ludston,(= (range 0.1 0.4 0.1) '(0.1 0.2 0.3 0.4))
23:17clojurebotfalse
23:17ludston(= 0.3 (+ 0.1 0.2))
23:17ludston,(= 0.3 (+ 0.1 0.2))
23:17clojurebotfalse
23:17ludston:(
23:17mattmossYeah, don't do that.
23:18ludstonThat's extremely annoying.
23:18technomancyfloats are inexact
23:18mattmossFloating-point operations will introduce rounding error.
23:19technomancyhttps://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
23:19mattmoss,(< (- (+ 0.1 0.2) 0.3) 0.00001)
23:19clojurebottrue
23:20ludstonI get the theory behind it, but it's annoying that it's so easy to run into.
23:20mattmossEasy to avoid, too.
23:20ludston,(double 0.3)
23:20clojurebot0.3
23:21ludston,(double (+ 0.1 0.2))
23:21clojurebot0.30000000000000004
23:21mattmoss,(- (+ 0.1 0.2) 0.3)
23:21clojurebot5.551115123125783E-17
23:21xeqi,(range 0.1M 1 0.1)
23:21clojurebot(0.1M 0.2 0.30000000000000004 0.4 0.5 ...)
23:22xeqi,(range 0.1M 1 0.1M)
23:22clojurebot(0.1M 0.2M 0.3M 0.4M 0.5M ...)
23:22ludstonI guess I can live with it.
23:22ludstonThanks xeqi
23:23mattmoss,(+ 0.1M 0.5M)
23:23clojurebot0.6M
23:23mattmosseh
23:23xeqithats making them BigDecimal, so you'll lose speed but gain precision
23:24mattmossAnd gain size, methinks?
23:26ludstonmattmoss: size?
23:30mikerabigdecimals use quite a bit of memory IIRC
23:32mattmossludston: double is 8 bytes, bigdecimal is... ?
23:34amalloybigdecimal is willing to use all the RAM and swap on your computer
23:34mikeravariable, but probably at least 80 bytes
23:34mikerawhen you count the overhead of all the things it contains
23:36amalloyyou're likely to be much better off just getting used to the various tradeoffs of floating points, ints, etc, rather than trying to pretend computers can do infinite-precision arithmetic
23:41ludstonCommon lisp can do infinite-precision arithmetic without any obvious drawback
23:41gdevokay
23:42mattmosslolz no
23:43technomancyhehe
23:43mattmossThat's like saying I can shove the universe and a bag of chips into my CPU with no noticeable effect.
23:43ChongLifor some value of obvious I guess
23:43technomancyis that another way of saying they aren't up-front about the fact that it's much, much, slower?
23:43ChongLiif you aren't looking at the clock, the drawbacks are hard to see
23:44mattmossMaybe clipers never work with floats, so they never notice? Don't know... never done clisp myself.
23:44mattmoss*clispers
23:44ChongLiwouldn't it be great if we had computers that could work on real numbers in constant time and space?
23:44ChongLiahhh
23:45mattmossWe can dream...
23:45amalloyclisp> (float (/ 1 3)) ;;; 0.33333334
23:45senorflorWoot--just registered for Clojure/West and .cljs training! Will there be a swag-bag with instant infinite-precision arithmetic? I hear that's proposed for Java 8.
23:46ludstonChongLi: Real numbers in constant time and space, as in "104/105" with o(1) cpu?
23:46mattmossReally? I need to be there.
23:46ChongLiludston: as in pi with O(1)
23:46technomancyamalloy: [1] for certain values of infinite
23:46mattmossThe rational 104/105?
23:47ludstonmattmoss: Yes
23:47mattmoss,104/105
23:47clojurebot104/105
23:47mattmossAwesome.
23:47mattmossPoint being,... Not a great example to demonstrate the constant time of REALs with a RATIONAL.
23:48mattmossSee ChongLi ^^^
23:52amalloyrationals are real too :P
23:52mattmossBut... they're also... imaginary? o_O
23:54mattmossSomeone type pi!
23:54ludstonpi
23:54mattmossπ
23:54ChongLipi!
23:54mattmossOooo, pi factorial? Hmm.
23:54ludstonI'm not sure you can do that...
23:54xeqii
23:54ChongLiit's what he asked for!
23:55mattmossThat and a side of fries.
23:55xeqi√-1
23:57mattmossEgads, that's north!
23:57mattmossI should stop doing things after 10pm...
23:58mattmosse^iπ + 1
23:58mattmoss,exp
23:58clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: exp in this context, compiling:(NO_SOURCE_PATH:0)>
23:59mattmoss,clojure.contrib.math/expt
23:59clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.contrib.math, compiling:(NO_SOURCE_PATH:0)>