#clojure logs

2011-03-25

00:03amalloyi wish there were a way of doing the following that didn't involve messing around with vectors just for temporary holders: (apply myfn (if some-test [0] '[whoa not 0]))
00:08amalloyi could require that there be a one-arg case, which comes first, but ideally the compiler would magically know where i want to split the two halves of the if clause
00:08devnamalloy: once upon a time I actually had some code to generate docs and counted the number, but it's been awhile
00:08devnand lots of the stuff in .core is not relevant for most programs
00:08devnand by lots i mean...a little bit
00:09amalloydevn: i was just making fun of 4-600, which you intended to mean 400-600
00:09devnoh, right...
00:09devni think clojure only has like...4 functions...
00:09devn+, -, quot, and
00:09devnthat's all.
00:09amalloyit only has like four data types, so four functions should be fine
00:10amalloydevn: madness! why would you include + if you have -?
00:10amalloy&(- 10 (- 4))
00:10sexpbot⟹ 14
00:10devnamalloy: it's like car/cdr, except more hardcore
00:11amalloy&(let [+ (fn [& args] (- (apply - 0 args)))] (+ 10 20)]
00:11sexpbot⟹ 30 ; Adjusted to (let [+ (fn [& args] (- (apply - 0 args)))] (+ 10 20))
00:12devn:D
00:12amalloy$botsnack
00:12sexpbotamalloy: Thanks! Om nom nom!!
00:13devnI think it'd be fun to make $botsnacks /necessary/ for a bot to cooperate in the channel
00:13devnlike it just refuses to pay attention to you until you give it a few snacks and pet it
00:14amalloydevn: i'm sorely tempted to turn off the clojure plugin
00:14amalloyso that you realize the horror
00:14amalloy(dec amalloy)
00:14sexpbotYou can't adjust your own karma.
00:14devnamalloy: speaking of which, i heard you were toying with sexp/irclj to build a sort of generalized framework
00:14amalloywut. i'm not, srsly
00:14amalloyRaynes might be
00:15devni dont like that whole fnmap thing
00:15amalloyi mean, sexpbot already is a generalized framework, what more do you want?
00:15devnmultimethods dont make it much cleaner
00:15devnamalloy: it's too fat -- needs to be stripped down
00:16amalloyyou were saying this to Raynes months ago, weren't you? i don't think either of us got what you wanted
00:16devni was thinking about cond-let, fcase, or something to clean up the condp
00:17amalloyi mean, the whole thing is less than 600 lines if you don't count the entirely-optional plugin dir
00:17amalloyincluding blank lines and comments
00:17devni just think that fnmap is 'unclean' -- and there is some elegant solution but im still not quite sure what it is
00:17amalloyping me when you've mastered human-computer telepathy
00:18devnvia telepathy or by typing it into the window?
00:18amalloythe latter would be less impressive
00:19devni think the ultimate taunt would be to tell someone you've actually figured out a neural interface for your computer, but you refuse to share it, and you do so via your neural interface
00:21devn"Jesus, how the heck to do anything?"
00:22groovy2shoesdevn: that's my favorite so far.
00:24devngroovy2shoes: favorite what?
00:25groovy2shoesdevn: favorite post on the group
00:25groovy2shoesit made me giggle inside
00:25devnheh -- i need to review the thread -- if no one has posted a link to stuart halloway's "simplicity" talk they need to
00:26devn"why dont i already know how to fly a plane despite the fact i have absolutely no training"
00:33amalloydevn: you don't know how to fly a plane? i can fly seven at once
00:47mecdid java ever add invoke dynamic?
00:50amalloymec: java 7
00:50amalloythat said, people more informed than i tell me it's not that interesting from clojure's POV
00:51mecoh?
00:52scottjpeople as in rhickey :)
00:53amalloyscottj: i think it's fair to say he's better informed than i about clojure. maybe a close call, but i have to back down on that one
01:00mecMaybe clojure isnt as dynamic as I thought, rhickey does happen to be a wiz at interfaces
01:01scottjclojure isn't OO like the languages that need invoke dynamic
01:03amalloyscottj: that's a much clearer statement than the ten-thousand-page summary i read of why jruby luvs invokedynamic
01:12devnamalloy: link me?
01:12devn(to the jruby summary)
01:12amalloyuhhh
01:13amalloyit was...on twitter like a month ago
01:13amalloymaybe it was http://blog.headius.com/2008/09/first-taste-of-invokedynamic.html
01:13amalloybut that's years old
01:14amalloyi think that's it, all the same
01:14mecwell invoke dynamic has been around for like 5 years
01:15amalloymec: sure, i'm just surprised something this old would get tweeted about recently
01:15mecI just watched a presentation on it from '07 and i figured it had to be in the JVM by now :D
01:20hiredmanapparently the jvm guys askes rich what changes he would like to see in the jvm, he said just do what you do better and faster
01:20mecand tco ;p
01:21hiredmanwell, I for one would love to see tco
01:21hiredmanbut it doesn't seem to be high on anyone's priorities
01:22hiredmanhttp://www.infoq.com/presentations/Towards-a-Universal-VM
01:22mecIt would just make trampoline faster right?
01:22hiredmanclojurebot: towards
01:22clojurebotExcuse me?
01:22hiredmanclojurebot: ~search for towards
01:22clojurebot<#clojure:hiredman> clojurebot: towards
01:22clojurebot<#clojure:hiredman> http://www.infoq.com/presentations/Towards-a-Universal-VM
01:22clojurebot<#clojure:mids> fliebel: "Shifting right by n bits on an unsigned binary number has the effect of dividing it by 2n (rounding towards 0)."
01:22clojurebot<#clojure:devn> but most of clojure is geared towards making the things you do pure by default
01:23hiredmanmec: it would make a lot of interesting control flow abstractions possible and faster without using trampoline
01:24mecWould you have an example? I dont know that i've even ever used trampoline
01:25hiredmanmec: state machines
01:26mecI think I saw an example of that in scheme
04:26xkbhi again :)
04:26xkbStill puzzling with my DP boxes problem
04:26xkbhow would you translate this piece of code:
04:26xkbfor (int i=0;i<numBox;++i) {
04:26xkb for (int j=0;j<numBox;++j) {
04:26xkb if (i==j) continue;
04:26xkb if (graph[i][j] && level[i]+1 > level[j]) {
04:26xkb level[j] = level[i]+1;
04:26xkb prev[j] = i;
04:26xkb }
04:26xkb }
04:26xkb }
04:26xkbto clojure?
04:27xkbsry for the paste..
04:27xkbI'm thinking of (map .. (map ..))
04:28raeknested (for [..] (for [..] ....)) could be one approach
04:28xkbthe main problem I'm having is translating the "side-effects" of the code to something more functonal
04:28xkbe.g. level[] and prev[]
04:29raekbut note that the imperative programming paradigm and the funtional programming paradigm are very different from each other
04:29xkb:)
04:29raekso you can't in general translate code directly
04:29xkbThat's why i'm looking for a more functional approach
04:29xkbsomething like an accumulator springs to mind
04:29xkbor actually 2 in this case
04:33TobiasRaederMorning
04:36raekthe "looping" could be made easily with loop/recur, but can't at a glance really see what the data dependencies of the generetated level and prev values are
04:38raekxkb: this is an interesting problem, but I gotta go. there will probably be more people active here when USA wakes up
04:47hoeckxkb: I don't really know how to work with matrices in a functional way, so my approach would be to just translate this code line by line to clojure
04:47hoeckxkb: like https://gist.github.com/886553
04:47ejacksonhey all
04:49TobiasRaederGood Morning :)
09:15kenshofliebel: I played a bit with Java2D and the JMonkeyEngine but I haven't made any real game
09:47tsdhHi guys.
09:48tsdhCan anyone see if I could formulate these functions in a more performant way (especially the iseq defmulti at the bottom)? http://pastebin.com/Qm8P4xD5
09:49tsdhOne problem is that `type-matcher' is called gazillions of times, which might be a bottleneck. However, memoizing that makes it even slower...
09:51angermanif you are dispatching on class anyway, why not use protocols?
09:52tsdhBecause I'm new to clojure and haven't used them till now. ;-)
09:52tsdhDo you think that will perform better?
09:54angermancould only assume. don't know for sure.
09:54HavvyI have Clojure load from C:/Clojure/clojure.jar and I want it to load the file at C:/Havvy/Code/LISP/converter.clj
09:54HavvyHow would I do this?
09:55angerman(load "C:/Havvy/Code/LISP/converter.clj") ?
09:55stuartsierraload-file
09:55clgvwhat do you guys use when you want to have an exception-like behavior? clojure.contrib.condition?
09:55stuartsierraclgv: exceptions
09:56clgvhm but I would have to define a custom one since I want only to handle the special case I am throwing on.
09:56cemerickstuartsierra: I think your days on 20% /core duty are making you even snarkier. :-D
09:57stuartsierracemerick: Not possible. :)
09:57stuartsierraclgv: Rich's recommended approach is a dynamically-bound Var with your error-handling function.
09:58stuartsierracemerick: By the way, how can I sign the Clojure 1.2.1 JAR to upload to Sonatype?
10:00cemerickstuartsierra: Good question. The release plugin takes care of that automagically, I've never had to do it manually.
10:00cemerickstuartsierra: maybe http://maven.apache.org/plugins/maven-jarsigner-plugin/sign-mojo.html ?
10:00cemerickwhich appears to wrap jarsigner: http://download.oracle.com/javase/6/docs/technotes/tools/windows/jarsigner.html#Options
10:01stuartsierraok, thanks, will investigate
10:03tsdhangerman: I looked at protocols, but since I dispatch on the class of external Java objects, I think I would need to reify them. That doesn't sound better, does it?
10:04angermantsdh: you'd basically write your protocol and then extend the java types.
10:05angermansomeone please correct me if i'm wrong.
10:06TobiasRaederThat seems like the way to do and i think (can't provte it right now) that it "should" still be faster using protocols + extend-type than using multimethods
10:06angerman(defprotocol Foo (foo [_] "does foo"))
10:06angerman(extend-type java.lang.String Foo (foo [_] "whatevaaaa"))
10:06angerman(foo (String. "Hi"))
10:07angerman;; => "whatevaaaa"
10:07tsdhangerman: Hm, Vertex is the top-level Java class in a probably large, dynamically in-memory compiled class hierarchy. Would extending Vertex in clojure automatically extend all subclasses?
10:08angermantsdh: saw the example i just posted? — concerning the in memory complexity. Don't know if that has any impact at all. … just try?!
10:09TobiasRaederAnd it seems to work on subclasses
10:09TobiasRaeder(defprotocol Foo (foo [_]))
10:09TobiasRaeder(extend-type Object Foo (foo [_] (println "abc")))
10:09TobiasRaeder(foo (Object.)) -> "foo"
10:09TobiasRaeder(foo (String. "")) -> "foo"
10:10tsdhTobiasRaeder: What if the String "foo" had already existed before the extend-type? (That's the case for me)
10:12angermantsdh: seems to work as well.
10:12stuartsierraextend-type doesn't modify classes, it modifies the protocol. So it works on pre-existing types & objects.
10:13tsdhYes, just checked it.
10:13tsdhNice.
10:13stuartsierraThat kind of dispatch won't be as fast as in-line methods in a deftype or Java method definitions, but should still be faster than multimethods.
10:14tsdhAnother question. Why do defprotocols API docs have various *this* in the method sigs, but not the Protocols section on the clojure homepage.
10:14angermantsdh: make it "self" and feel pythonic
10:14stuartsierra'this' isn't a special symbol, just a convention borrowed from Java.
10:15stuartsierraBut every protocol method is required to have at least one argument, which is commonly called' this'.
10:16dnolenstuartsierra: 'won't be as fast' - the difference is negligible in my experience. dispatch via extend-type is still in billions of ops per second territory.
10:16stuartsierraSome early versions of the protocol API omitted the first "this" argument.
10:16tsdhstuartsierra: Ah, ok.
10:17stuartsierracemerick: Come to think of it, where's the key?
10:17tsdhWell, then I'll see if protocols improve performance...
10:18cemerickstuartsierra: ~/.gnupg on build.clojure.org, last I knew
10:20stuartsierragot it. thanks.
10:25tsdhHm, what's the error in http://pastebin.com/JnJ8YsBb ?
10:26stuartsierratsdh: You have a call to the `iseq` protocol method with incorrect arguments somewhere.
10:28tsdhstuartsierra: Before, iseq was a defmulti dispatching on the class of the first arg. There, all tests passed (and of course no compile errors). Shouldn't the calls look identical?
10:30stuartsierraI don't think protocol methods can have variable arity.
10:30stuartsierraInstead, define one protocol method with fixed arity, and a helper function to do default arguments.
10:33tsdhstuartsierra: My defprotocol was wrong. Different arities are given by: (iseq [this] [this cls] [this cls dir]), as the docs also indicate.
10:33stuartsierraah, right.
10:34tsdhHm, but now I get exceptions at runtime: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: No distinct mapping found
10:34gfrlogis there any good way to handle a java dependecy with leiningen that is not in any maven repo that I can see?
10:35gfrlogapparently putting the jar in lib will add it to the classpath, but anything automated is preferred
10:35tsdhgfrlog: AFAIK, the answer is, make your own local maven repo. :-(
10:35stuartsierragfrlog: You can install it locally, with mvn install:file
10:36gfrlogstuartsierra: okay, thanks
10:36angermanis there a cvs reader for clojure?
10:36stuartsierralots, with varying degrees of bugs.
10:36gfrloglike the version control system? or the drug store?
10:37stuartsierraoh, I assumed csv
10:37gfrlogthat's why I asked :)
10:46gfrlog(defn csv-parse [csv] (map #(s/split #"," %) (s/split #"\n" csv)))
10:47stuartsierrathere are a surprising number of edge cases with CSV parsing.
10:47gfrlogstuartsierra: I would imagine so. Probably a lot of escapes, and you might want options to use the first row as a header and thus output maps
10:48AWizzArdgfrlog: https://github.com/davidsantiago/clojure-csv/blob/master/src/clojure_csv/core.clj
10:48jolyespecially with quotes and such, iirc
10:48AWizzArdThis is a small 150-LOC parser/writer. It lacks lots of features.
10:51gfrlogbut mine clearly does what I intended it to do :)
10:55fliebelneato! Calling addDirtyRegion multiple times gets collapsed into one repaint. Now I can just add that as the watcher for my ref.
11:00semperoshappy friday
11:00consboxIt seems that there is no way to read record from string even though there seems to be reader syntax for that (but create method is missing, clojure 1.2.1) ==> (defrecord Test [x]) (read-string (binding [*print-dup* true] (pr-str (Test. nil)))) ; any workaround?
11:00gfrlogsemperos: likewise
11:01woobyconsbox: work is being done on adding it, see http://dev.clojure.org/display/design/defrecord+improvements for ideas and details
11:04fbru02Hi guys i asked this before , does anyone know how to complie clojure source code (github.com/clojure/clojure) using eclipse or intellij ?
11:04stuartsierrafbru02: Current 1.3.0 alpha Clojure source supports building with either Ant or Maven.
11:05fbru02stuartsierra: thanks i will try it out
11:20devngood morning everyone
11:26fliebelgood mornign devn
11:27fliebelWhat happens when I assoc a record? Do I get a new one? Does it do structural sharing? I'm going to assoc it quite much, so it'd be unfortunate if I was creating thousands of huge objects.
11:33devnstructural sharing fliebel
11:33fliebeldevn: Thanks :)
11:34devnerr fliebel sorry no
11:34devnfliebel: you mean a defrecord?
11:34fliebelyea
11:34devnokay im going back and forth here -- but yes, i do believe they use structural sharing
11:34devnhttp://stackoverflow.com/questions/4575170/where-should-i-use-defrecord-in-clojure
11:35fliebelright there they say 'no' again.
11:36fliebelah, and then 'yes' again
11:37fliebelWe'll see what the JVM thinks of my code...
11:38fliebelIf I run into trouble, I might use either regular maps(meh), or deftypes with mutable fields(meh)
11:39devnalex miller is generally very knowledgable and i dont know mikera but im inclined to believe that defrecord does do structural sharing
11:40devnlet me check one more resource for your quick
11:42devnfliebel: im inclined to believe that you'll be fine performance-wise with defrecord
11:43angermanam I doing something wrong, if I think about performance tuning to come last?
11:43devnangerman: you're doing it right and wrong, simultaneously! :)
11:44angermangreat
11:44devnangerman: reasonable attention to the problem you're going to be solving and recognizing some of the performance issues you may run into is a good thing to do before you commit to a solution
11:45devnangerman: but in general you're going to want to "tune" last
11:45devnthat's my opinion
11:45devnbbiab
11:47angermandevn: sure. The more complex your problem is and the broader your solutions space, a sensible heuristic (performance) may be a good guide finding a workable solution.
11:49angermanFor me though, I've often had to deal with problems that consisted more of writing actual code then to choose from a large solution space. And I feel that a working solution is often more than good enough; rarely a perfect solution or a very near perfect solution is asked for.
11:50devnangerman: it all depends, and you seem to be aware of how muddy the water is around this particular topic
11:51devni can't really give an informed answer to your question without understanding the full context, problem, etc. which is more time than i have available unfortunately :)
11:51devnbest of luck, heading back to work... cheers!
11:51angermanlol
12:05technomancyis anyone submitting a clojure talk to oscon?
12:10fliebelIs there any way I can extend Fn to implement an abstract subclass of Runnable, or is a proxy the way to go here?
12:13dnolenfliebel: what subclass of Runnable?
12:13fliebeldnolen: java.util.TimerTask
12:14fliebelSo close, yet so far! The beauty of just passing a fn to Timer and make it work.
12:15hiredmanugh
12:15hiredmandon't use timertasks or timers
12:15fliebelhiredman: What else?
12:16hiredmanhttp://download.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html
12:16fliebelah!
12:16fliebelJust what I needed!
12:17fliebelhiredman: Thanks a lot, you saved my life, or at least my sanity, or at least.. well thanks :)
12:17hiredmanclojurebot: search for schedule
12:17hiredmanclojurebot: ping?
12:17clojurebotPONG!
12:18hiredmanhttps://github.com/hiredman/clojurebot/blob/master/src/hiredman/schedule.clj
12:19fliebelhiredman: It says it does not use a bound threadpool, so setting that is not helping much in your code, I assume.
12:21fliebelAnd I don;t think unit is used.
12:22hiredmanfliebel: look at the example call at the bottom
12:24hiredmanfliebel: While this class inherits from ThreadPoolExecutor, a few of the inherited tuning methods are not useful for it. In particular, because it acts as a fixed-sized pool using corePoolSize threads and an unbounded queue, adjustments to maximumPoolSize have no useful effect.
12:24fliebelhiredman: Ah, it's called tu inside the function :)
12:24hiredmanthe constructor I call sets the corePoolSize
12:24fliebelhiredman: So that is just the maximum really?
12:25fliebelokay, clear :)
12:28fliebelhiredman: Why do you do proc+1?
12:29hiredmanfliebel: no idea
13:28fliebelWhat model does Aleph use for concurrency? Threads or cooperative? Blocking or non blocking?
13:31amalloyLauJensen: someone asking clojureql stuff on SO, and from reading the cql source the behavior he sees doesn't make a lot of sense to me
13:32amalloyhaha nevermind, the second i pressed enter there the question got deleted
13:32dnolenfliebel: it's an async IO lib built on top of Netty.
13:33fliebeldnolen: Well, than I need to figure out how Netty works.
13:33xkbhttps://gist.github.com/887234
13:33dnolenfliebel: if you understand why people like node.js, you can understand what Netty is all about.
13:34fliebeldnolen: Well, I do, but I heard node is cooperative, so if you do heavy computations it just gets stuck. And I don't like nested callbacks very much.
13:35fliebelI wrote some Twisted app, and then you go like "get this and then… oh, wait let me define another function somewhere"
13:37dnolenfliebel: Aleph recently added a async macro which allows you to write async code in a more natural way.
13:44amalloydnolen: ztellman was really excited about his async macro when i met him at a meetup recently; i wasn't aware it was a part of aleph. do you happen to have a link to the macro in question?
13:48dakroneclojurebot: ~search for json
13:48clojurebot<#clojure:TimMc> http://hubpages.com/hub/Dont-use-XML-JSON-for-Clojure-only-persistence-messaging
13:48clojurebot<#clojure:paraseba> long live S-expressions ... no more json needed
13:48clojurebot<#clojure:brehaut> its no different to using json frinstance
13:48clojurebot<#clojure:TimMc> brehaut: https://github.com/joshua-choi/fnparse/wiki/Sample-JSON-parser
13:53choffsteinHey all. I have sort of an algorithm design question. I have a bunch of data that is date indexed. I want to create different groupings based on the first day of week definition. So if the first day is wednesday, I want to lump them into successive Wednesday-Tuesday groups. I've been playing around with group-by and Calendar to try to create a unique key based on the year and week-number, but unfortunately it messes
13:53choffsteinup when the week crosses over into a new year (obviously). If I use week-number alone, however, it won't work either because it will group weeks in different years. Any thoughts on an easy way to achieve this?
13:56sritchiechoffstein: could you just use the starting day, and the period length?
13:57sritchieie, use the julian day calendar, and forget about weeks?
13:57sritchie(after grouping, that is)
14:03choffsteinah, that might work
14:17angermanis there a maximum number of fields a record may have?
14:17dnolenangerman: if there is, I imagine it's a Java limit.
14:18amalloyyeah, clojure doesn't impose one
14:18amalloyjava has a limit on classfile size, but it's huge i think
14:19angermanweird...
14:20angermanadding a 9th field to the record, and I get NoSuchMethodErrors.. let's see if they persist after cleaning
14:20amalloyangerman: clojureql has a record with ten fields so that's certainly allowed
14:20amalloyNSME is a versioning conflict
14:21amalloyusually involving AOT
14:22angermanHmm. After cleaning all classes and restarting swank, it works.
14:22amalloyLauJensen: since i was looking at cql, i saw that RTable.deref returns (fn [rs] (doall rs)) - is there a reason it doesn't just return doall?
14:25fliebelamalloy, dnolen: Has the async macro surfaced yet?
14:25amalloyfliebel: no; i'm hoping someone will be more excited about it than i am and do some googling
14:27fliebelI am: http://groups.google.com/group/aleph-lib/browse_thread/thread/28478c992cbb5555
14:34fliebelhttps://github.com/ztellman/lamina/blob/master/src/lamina/core/expr.clj#L343
15:01mecIs there any difference between (amap a i _ (f (aget a i))) and (amap a i r (aset r i (f (aget a i))))
15:03amalloy&(doc amap)
15:03sexpbot⟹ "Macro ([a idx ret expr]); Maps an expression across an array a, using an index named idx, and return value named ret, initialized to a clone of a, then setting each element of ret to the evaluation of expr, returning the new array ret."
15:03xkbhi
15:05amalloy&(seq (amap (into-array [1 2 3]) i _ (inc (aget a i))))
15:05sexpbotjava.lang.Exception: Unable to resolve symbol: a in this context
15:06mec(let [a (long-array [0 1 2 3 4])] (= (seq (amap a i _ (inc (aget a i)))) (seq (amap a i r (aset r i (inc (aget a i)))))))
15:06mec&(let [a (long-array [0 1 2 3 4])] (= (seq (amap a i _ (inc (aget a i)))) (seq (amap a i r (aset r i (inc (aget a i)))))))
15:06sexpbot⟹ true
15:06xkbI'm still tinkering with my algorithm: I have a matrix nxn with contents per cell either 0 or 1. A 1 in a cell implies we can navigate from row y to row (column of 1). The algorithm should return all possible paths. Starting from cell [n-1,n-1]. I wrote something similar to this: https://gist.github.com/887234 (with recurs everywhere). This code however does not terminate.
15:06amalloy&(seq (let [a (into-array [1 2 3])] (amap i _ (inc (aget a i)))))
15:06sexpbotjava.lang.IllegalArgumentException: Wrong number of args (5) passed to: core$amap
15:06amalloyblah whatever. anyway mec it looks the same to me but i don't use amap a lot
15:12amalloyxkb: you don't mention what the "list" argument starts out as. i don't pretend to follow your algorithm, but setting "list" to (nth orgmat (count more)) looks bizarre out of context
15:13xkbamalloy: Ah, good remark. It starts with the bottom row of the matrix
15:13amalloyfwiw i also don't see why you use recur in most cases, and then not in the x=1 case
15:13xkbI will paste the non working algorithm
15:13amalloybottom as in last?
15:13xkbthis was just a test :)
15:13xkbyes
15:14xkbthis is the code as is: https://gist.github.com/887415
15:15xkbIt has become way more uglier than I started with, just trying to find out why it doesnt work
15:15amalloyyou seem to be actually treating [7, 1]=1 as meaning row 7 can move to row 7, not row 1
15:15amalloy(count more) will be 7 since there are 7 elements *left* in the list
15:15xkbah yes, I reverse the list
15:16amalloyhaha no offense but i'm going to murder you
15:16xkbcool :)
15:16xkbNow I'm hoping I dont live near you :)
15:16xkbmaybe I should just step back to the intital problem
15:17xkbgiven the matrix, how would you calculate the paths
15:18amalloyummmm, that depends on what you mean by "paths". you want to take this graph of direct connections and turn it into a graph of "nodes interconnected by paths of any length"?
15:18xkbbtw this actually represents stacking boxes :)
15:19xkbMy goal was to create lists of path's, e.g. [7 5 3 1] means from row 7 to 5 to 3 to 1
15:20amalloyi don't think you can do that in a tail-recursive way. you need a stack to keep track of where you are, no?
15:20xkbI starting to think that way as well
15:20xkbfor the backtracking part
15:21xkbanyway, as of now, I cant even calculate one path :)
15:21amalloyhave you looked at http://en.wikipedia.org/wiki/Transitive_closure
15:21amalloyit may not be exactly what you want, but it's closely related and might be useful
15:22xkbinteresting
15:22xkbthe root problem is an ACM programming contest problem, known as Stacking Boxes. In imperative languages it is implemented using Dynamic programming
15:23amalloydynamic programming just means "memoize except you have to implement it by hand every time"
15:24xkbindeed
15:24xkbso I started using memoize for the recursion parts
15:25xkbin my C# solution I use 2 arrays to keep track of the calc. history
15:26xkbmuch like this solution: http://chchwy.blogspot.com/2008/11/acm-103-stacking-boxes.html
15:27stuartsierraClojure 1.2.1 staged to https://oss.sonatype.org/content/repositories/orgclojure-069/ - how's it look?
15:35fliebelIs there something like update-in for sets? Essentially it's just (conj (fn (disj key))), but there might be just a nice one somewhere that does this already.
15:36fliebels/disj/get/
15:36sexpbot<fliebel> Is there something like update-in for sets? Essentially it's just (conj (fn (get key))), but there might be just a nice one somewhere that does this already.
15:36fliebelno, wait… hmmm
15:36fliebel(conj (disj key) (fn (get key)))
15:40amalloyfliebel: i don't think so
15:40fliebelamalloy: Okay, I'll craft my own, it's but a single line.
15:40amalloyin particular it wouldn't work if the thing you wanted to update to were already in the set? or at any rate it would behave oddly
15:41hiredmanhow so?
15:41hiredmanthe thing you want to be in the set would be in the set
15:41amalloyhiredman: update-in would be decreasing the size of the set, which it never does for maps
15:42amalloy&(let [s #{1 2 3} k 1] (conj (disj s k) (inc (get s k))))
15:42sexpbot⟹ #{2 3}
15:42amalloywhich seems "odd" by my lights, but it depends what fliebel wants it to do
15:43fliebelamalloy: It's not a proper update indeed, but I want to just take the value from a set, do something to it it and put it back.
15:44hiredmanupdate-in is a transform on a map
15:44hiredmangetting a new map out with different properties is to be expected
15:45hiredmanthe update-in-set thing would be a transform on a set, getting a new different set out seems like something that should be expected
15:45fliebelbut… this is of no use…
15:46fliebelOh, maybe it is, let's just see how it works out...
15:50ossarehmorning all
15:55LauJensenamalloy: Anything I need to respond to RE CQL ?
15:56amalloyLauJensen: nah, i think he was just blaming his problems on far-away code
15:56amalloythough i do still wonder about the doall thing
15:56fliebelOh, I'm sure there is some multimethod or extend-type to make java object print-friendly?
15:56amalloy$google amalloy hubpages xml json
15:56sexpbotFirst out of 4 results is: Don't use XML/JSON for Clojure-only persistence/messaging - HubPages
15:56sexpbothttp://hubpages.com/hub/Dont-use-XML-JSON-for-Clojure-only-persistence-messaging
15:56LauJensenamalloy: okay
15:56amalloyfliebel: ^
15:57amalloy(the stuff you want is at the end but it's not such a long article)
16:03fliebelamalloy: Can't get it to work :(
16:04amalloyfliebel: what is your goal? print a java object so that you can read it back in with (read-string)?
16:04fliebelamalloy: No, just stuff away all the crap it prints.
16:04fliebel#<BufferedImage BufferedImage@77c30993: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@ed0f59e transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 215 height = 471 #numDataElements 3 dataOff[0] = 2>
16:04amalloyfliebel: it's calling foo.toString
16:05fliebelamalloy: I know, but can I do anything about that?
16:05amalloyi suspect that's hardcoded into the repl
16:06amalloywhat do you want to see instead?
16:07fliebelJust… something like <BuferedImage> probably with the width and height, I don;t care for the rest.
16:08amalloyi don't believe any such feature exists
16:09fliebeloh, I thought I had seen it, but it was probably print-dub. What does that do then, if not what I want?
16:11TimMcfliebel: Prints an eval-able representation.
16:12amalloy&(do (pr *ns*) (binding [*print-dup* true] (pr *ns)))
16:12sexpbotjava.lang.Exception: Unable to resolve symbol: *ns in this context
16:12amalloy&(do (pr *ns*) (binding [*print-dup* true] (pr *ns*)))
16:12sexpbot⟹ #<Namespace sandbox10597>#=(find-ns sandbox10597)nil
16:12TimMcYou have to override the print-dup multimethod for most Java objects though.
16:36dsantiagoI feel like there should be a clever function already around that takes a sequence of functions and an initial value as argument and applies all the funcitons in order, to the output of the previous one?
16:37brehaut(comp comp reverse) ?
16:37ampleyflytake a look at -> and ->>
16:37ampleyflyif I understood you correctly
16:37brehautbah no comp is varargs. ignore me
16:38dsantiagoAh, comp should do it, I can apply it.
16:38ampleyfly&(doc ->)
16:38sexpbot⟹ "Macro ([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
16:39dsantiagoampleyfly, yeah, that's not quite what I want, because I don't have the list of functions in hand.
16:39ampleyflyah
16:39brehaut(comp (partial apply comp) reverse) is what i ment
16:41dsantiagobrehaut, yes, thanks. That's perfect.
16:41dsantiagoThese things are never named any of the things I try searching the docs for.
16:41CaffeineIs there a way en emphasize that a global value is a constant? I know usually global values are between * .. and I know the macro trick to kinda make C #defines, but well yeah, anything else? convention? Being principally a Java programmer I'd write them in caps.. and btwn * maybe
16:41ampleyflybrehaut: that's cool
16:41technomancyCaffeine: emphasizing that something is constant means implying other things aren't.
16:41Caffeinehaha
16:41Caffeineseen that way
16:42Caffeineokay.. you're right... then you just hope someone doesn't use set! on it I guess :)
16:42technomancywe're all big kids here
16:48ossareh&(= [] '())
16:48sexpbot⟹ true
16:48ossarehsuprising to anyone?
16:49dnolenossareh: why should that be surprising?
16:49dnolen,(= [1 2 3] '(1 2 3))
16:49clojurebottrue
16:49brehautossareh: collections are compared based on the interface they support rather than the concrete type
16:49ossarehdnolen: a nice surprise, btw.
16:50ossarehbrehaut: aha, I like that.
16:50brehaut,(= (array-map :a 1) (hash-map :a 1))
16:50clojurebottrue
16:50fliebelDo any of the big O's know what is the fastest way to detect collisions? It seems to me that you almost need to compare every object to every object, but I'm sure you can do some smart elimination.
16:50dnolenossareh: in the presence of lazy sequences it seems like the only reasonable behavior, otherwise you pay for conversions.
16:51stuartsierraAny ideas while compiling the Clojure tests would throw java.lang.ClassCastException: clojure.test_clojure.genclass.examples$loading__4293__auto__ cannot be cast to clojure.lang.IFn, compiling:(examples.clj:9) ?
16:51stuartsierras/while/why/
16:51sexpbot<stuartsierra> Any ideas why compiling the Clojure tests would throw java.lang.ClassCastException: clojure.test_clojure.genclass.examples$loading__4293__auto__ cannot be cast to clojure.lang.IFn, compiling:(examples.clj:9) ?
16:52dnolenfliebel: are you talking about collisions in a collection?
16:52fliebeldnolen: no, the game type of stuff.
16:52fliebeloverlapping bounding boxes.
16:53hiredmansounds like an abi mismatch, new clojure with older classfiles sitting around or similar
16:53stuartsierrahiredman: possibly, but Clojure is what I'm building. :)
16:53brehautfliebel: buckets of geometry math and 2D or 3D tree structures let you eliminate tests
16:54fliebelbrehaut: Okay, sounds good, do you have any terms I can google for?
16:55hiredmanstuartsierra: do you start with a clean tree? like clear out target or classes or whatever
16:55stuartsierrayeah
16:55brehautRTree, QuadTree, Octree, bsp tree
16:56hiredmanseems likely it could be something with the lazy var->fn loading
16:56hiredmanbut that went in weeks ago
16:57brehautfliebel: im not a game programmer, but ive done stuff with mapping so i might be a bit off with actual game structures, but those should give you an idea of where to go
16:57danbellhey, anyone know how to parameterize a SQL statement with multiple parameters in contrib.sql?
16:57fliebelbrehaut: Thanks :)
16:57danbellnm, I think I got it
17:01tsdhCan anyone tell me what this exception means? http://pastebin.com/DupydhJy
17:02stuartsierratsdh: maybe a Protocol method invocation with multiple possible implementations?
17:04tsdhstuartsierra: You mean, I might have implemented a foo method for A, B, and C, where B implements A and B, and now a method was called for a B instance?
17:04stuartsierrayep
17:05tsdhHm, I'll check. The real strange thing is that if I run the form the testmacro executes in the REPL, it works fine.
17:06hiredmanrestart your repl
17:06stuartsierratsdh: it might depend on which namespaces you have loaded at the time.
17:06tsdhhiredman: That doesn't change anything.
17:07hiredmanclear ./classes and restart your repl
17:08tsdhOk, I'll do so.
17:12tsdhhiredman: Oh, great. Now I get the same error at the repl. ;-)
17:17amalloytsdh: i think that may have been his goal. now you've confirmed your code is buggy and don't have to worry about stale classes in the repl or otherwise
17:18tsdhamalloy: Yes, I know. But after adding a (println "foo") in the function just before the line that was the error position in my code, C-c C-k to recompile, bang!, it works again at the repl.
17:24tsdhNow I quit the repl, did lein clean again, lein swank, new repl, and this time it works instantly...
17:32tsdhHm, now the testcase that always errored runs fine, and another one errors. The first place of my own code in the backtrace is my defprotocol...
17:32stuartsierrasounds like an order-of-loading issue
17:34tsdhAnd how do I find out what's the right order? And how do I affect the order?
17:34stuartsierrayou shouldn't have to control the order.
17:35stuartsierraIf the behavior of the code is different depending on what is loaded when, you've got a bug.
17:37hugodtsdh - I always require the defining namespace wherever I import the protocol, and never use :reload or :reload-all int he tests
17:37stuartsierra:reload or :reload-all in a `(ns…)` is always wrong.
17:38tsdhOh, I'll remove that. I had it there, cause lein new added it automatically
17:38stuartsierrayes, that's a bug.
17:38technomancyfixed in 1.5.0; time to upgrade.
17:38stuartsierragood to hear
17:40tsdhRunning lein upgrade now. ;-)
17:41technomancyit would have been fixed sooner except there's no way to do :reload with load-file, so there's some heinous monkeypatching in swank-clojure to work around that.
17:41tsdhBut anyway, removing :reload and any AOT and gen-class doesn't help either.
17:41hugodthe effects of reloading namespaces, at the repl or with :reload, seems to get everyone the first time they use protocols
17:43tsdhhugod: You said, I should require the namespace defining the protocols. Now I see that I :use it. Is that wrong?
17:43stuartsierrathat shouldn't matter
17:44hugodtsdh: use or require should work
17:44tsdhok
17:48fliebelYay! My "game" is working! http://yfrog.com/ny71230492p
17:48stuartsierracool
17:52groovy2shoesfliebel: w00t!
17:56Raynesbrehaut: Ping.
18:03brehautRaynes: pong
18:03Raynesbrehaut: I'm sure you've told me this before, but why is fault a record?
18:04brehauti cant actually remember off the top of my head!
18:04RaynesHehe.
18:05stuartsierraw00t! Got Clojure to build all the way with my new plugin!
18:05brehauti think i wanted a concrete type to make it distinct from real values that are returned; there is a fault? predicate to test for its presence, and the attempt-all (average name) that also uses that
18:06Raynesbrehaut: It's actually okay, since I can just check the type to see if something went wrong.
18:06RaynesFor the record, it seems to be working just fine.
18:06stuartsierrahttps://github.com/stuartsierra/new-clojure-maven-plugin
18:06brehautRaynes: from the client RPC function?
18:07RaynesI didn't catch a question.
18:08brehautRaynes: checking for a fault response from the 'call' function
18:08RaynesYes, because in this case, it means "Yo, you gave me wrong credentials. I'm sad now."
18:10brehautRaynes: were you expecting it to be an exception?
18:10RaynesNo.
18:10RaynesI would have expected it to be a map with a :fault? key. I haven't used much code that uses records.
18:10RaynesNor written much.
18:11RaynesAnd by much, I mean any.
18:15brehautRaynes: there is also potential that 'corrupted by haskell' is part of the reason
18:15Raynes:p
18:20Raynesbrehaut: (= (type blogs) necessary-evil.fault.Fault)
18:20brehautRaynes: necessary-evil.fault/fault?
18:21Raynesorly
18:21RaynesI didn't want to import anything.
18:22brehautwhys that?
18:23RaynesBecause I plan to have no less than 600 lines of Swing imports before I'm finished. But this is much prettier, so I'll make an exception.
18:23brehautoh yeah swing. :S
18:23brehautyou also want to look at attempt-all in the same namespace
18:23brehautits like let that is fault aware
18:26brehautRaynes: an example https://github.com/brehaut/clj-pingback/blob/master/src/clj_pingback/server.clj#L68-83
18:26RaynesCool.
19:32JanPalencarHi guys, anybody experienced strange kind of behaviour with compojue 0.4.0, ring 0.2.0, when routing to .... (file "filename"). After some time Jetty says, IAE: No method in multimethod 'render' for dispatch value: class java.io.File. Perhaps run out of file handles?
19:33brehautJanPalencar: those are really old versions of ring and compojure; are you following an old tutorial?
19:33JanPalencar@brehaut, i tried to stick to stable RCs
19:35brehauti was not aware that either project claimed that those versions were stable
19:36brehautJanPalencar: perhaps try [ring/ring-core "0.3.7"] and [compojure "0.6.2"]
19:36brehautoh make that [ring "0.3.7"]
19:37JanPalencar@brehaut I know they are older, well what i did is that i replaced file with slurp
19:37JanPalencareverything went fine from that point on
19:41JanPalencar@brehaut sorry i used RC2, didnt meant it was stable
19:46p_l|homeare there any nice libraries for working with RMI in Clojure?
19:51JanPalencar@brehaut Do you know about uptodate API docs for the 0.6.2 compojure ?
19:52brehautJanPalencar http://weavejester.github.com/compojure/ ?
19:54JanPalencar@brehaut More than half of the links are broken in API docs
19:54brehautperhaps try #compojure
19:55brehauti dont use compojure myself
19:55brehauti only know bits and pieces from reading the source
19:58JanPalencar@brehaut
19:58JanPalencarthanks
19:58JanPalencarbbye
19:59brehautno problem
20:10amalloy@brehaut so cute when twitter leaks into irc
20:10hiredman:(
20:10amalloyhiredman: take heart, i don't actually approve
20:13brehaut@amalloy: haha #notreally
20:14brehauti really dislike hashtags
20:14amalloythey're meh
20:15amalloyi find it hard to imagine feeling strongly about them
20:16brehauti skim my twitter thing and hashtags are grey rather than black. people put their actual message into hash tags way too often and i miss it thus get confused later on
20:17hiredmanhashtags often say important things like #notserious
20:17hiredman#justkidding
20:17technomancy#totallylying
20:17hiredmanetc
20:23TimMcMeh, I used @-addressing *before* it was popularized by twitter, #backwhenitwasonvinyl
20:23amalloyTimMc: #backinmyday we called it email
20:25TimMcOh hey, I didn't even think of that.
20:26TimMcI used a format like "@amalloy: You're wrong." in blog commenting and such. Now I feel stupid when I use it. :-(
21:04ngwguys, I know nothing about java, so please bear with me
21:05ngwI keep looking at some projects and I'm baffled by the file structure
21:05ngwlike src/clj/http/async
21:06ngwit seems something that comes from java, but I might be wrong
21:06ngwis there some naming 'general rule' that I am missing ?
21:06ngwmost of those directories are empty, so I don't really see why someone would want to adopt a structure like that ...
21:13ngwnobody ?
21:13ngwa link is fine, I can read :p
21:15ataggartjava packages are represented in the file system as a hierarchy of directories
21:16ataggartthe src/clj is the root directory for clojure source, as opposed to src/java for java source, etc.
21:16hiredmanonly if you are using the clojure maven plugin
21:17technomancyactually I think in this case the project is called clj-http, so src/ is the source root
21:17ngwleinigen puts a core.clj under src/project
21:17hiredmanother clojure build tools omit the langauge part of the path, because you are building clojure
21:17ngwI see
21:17ngwthank you
21:19technomancyngw: short version is if you did src/foo.clj, it would go into Java's "default package" which is a no-mans land from which code can't always be loaded consistently
21:19technomancyso there's a convention to put it at least one throwaway directory deep.
21:19technomancyalso many Java programmers get paid a commission on a per-directory rate.
21:24ataggartAssuming one had the power to change field values on JIRA tickets, where would one find those actions in the UI?
21:25amalloytechnomancy: i can confirm that when i last wrote java, my classes were in com.mycompany.cassandra.mapreduce.myproject.hadoop.* or something
21:26technomancyamalloy: bonus!
21:26amalloytechnomancy: i get points for the confused notion of how cassandra and hadoop fit together?
21:27technomancysure. even more if it's nested in maven's modules/src/java/main goop.
21:27hiredmancom.company.southeastasia.factory.automation.ConfigurationFactoryFactoryStrategy
21:28amalloytechnomancy: sorry, i stay away from maven if i don't have cake/lein as a buffer
21:28technomancyalso helps justify purchase orders for widescreen monitors
21:28amalloytechnomancy: i prefer to order expensive word-wrapping software
21:29hiredmandeviant
21:31ngwI waited a bit to answer because I wasn't sure the per-directory commission basis was a joke
21:32ngwI didn't want to offend anyone :)
21:32ngw(it's a joke, right ?)
21:32amalloytechnomancy: your joke was more of a flop than you thought
21:32ngwlol
21:33hiredmanjoke?
21:33clojurebotOh, I know the best knock-knock joke! It goes like this... OK, you go first:
21:33technomancyamalloy: great, I'll have to stick to my old tried and true HTTP status code burns.
21:34amalloytechnomancy: 100
21:34hiredmanzing!
21:34technomancydang; he called my bluff
21:34technomancy501
21:35amalloyngw: anyway, java loves really-deep package names to make sure they're globally unique even if your evil clone in an alternate universe is working on a project to do the same thing
21:35ngwthanks amalloy, I got it now
21:35technomancyamalloy: good point; better move all my directories to src/earth-616/technomancy
21:35ngwI don't think I will conform to this practice honestly :)
21:36amalloyngw: clojure doesn't like them that deep
21:36amalloyjust src/myproject/{core,utils,whatever}.clj
21:36hiredmanngw: it's ok, I doubt I'll ever use code you write, so do whatever you want
21:37ngwI wouldn't use the code I write as well, I understand
21:37ngw:p
21:38hiredmandeviation from the norm is not to be recommended unless you understand the norm, and are familiar with the ins and outs of it
21:39hiredmanthe first thing anyone will say if you ask for help is "this code is in a weird style, rewrite it in the accepted style so I can follow it"
21:41ngwcompojure uses the same style
21:41hiredmanwhat style?
21:41ngwsrc/project/*.clj
21:41ngwwhere project is compojure
21:41hiredmanthat is the accepted style
21:41amalloyngw: indeed, there's a reason it's called conventional/standard
21:41hiredmanit isn't project
21:41ngwoh fantastic
21:42hiredmanit just happens that most projects use the name of the project as the first segment of the namespace
21:42ngwno I was asking about deeper structures, that's what I don't like / understand
21:42hiredmanclojurebot: okay is pokau
21:42clojurebotOk.
21:42hiredmanclojurebot: pokau is okay
21:42clojurebotOk.
21:43amalloyngw: deeper structures are used when you have "too many" files to shove all in the top level of your project, or some of them naturally seem grouped together
21:43hiredmanthe deeper structures are generally the result of people refusing to give up their death grip on maven
21:44amalloyhiredman: i assumed he meant src/myproject/communication/{write,read}.clj or what have you. you're not saying that's a maven symptom, are you?
21:44hiredmanpeople who do things like drop a java source file in there for no real reason
21:44hiredmanamalloy: could be, a lot of things are
21:45ngwI was looking at https://github.com/neotyk/http.async.client/
21:48amalloynot exactly an inspiring example
21:49ngwthat's why I asked, it didn't seem right
21:49ngwbut it's a lib I'm using, so ...
21:51ataggartAnyone present able to modify a CLJ ticket's field values in jira?
21:54dnolenshot in the dark, anybody ever look at the Threads Yield Continuations paper?
21:59amalloydnolen: no, but i remember seeing something on twitter a month or two ago called, maybe, "call/cc? i yield!"
21:59amalloywhich sounds like it'd probably at least be interesting to you
22:04dnolenamalloy: hmm interesting, thanks, but not quite what I was looking for. I was curious about about the performance profile of the implementation in Threads Yield Continuations paper with respect to the JVM.
23:14CaffeineAny data structure with quick indexed access? I need to make a ± big 2D table with indexed access.
23:17tomoj±?
23:18tomojvector access by index is O(log_32(n))
23:22Caffeineabout 5000 x 5000
23:22Caffeineok, good
23:22Caffeinethanks
23:49amalloytomoj: i choose to believe that log32(n) === 1
23:50tomojsure
23:50greghI choose to live in a 32-dimensional world
23:50tomojbut since O-notation is really about asymptotics it seems wrong to say O(1)
23:52p_l|hometomoj: except it feels right when you think of "constant function"
23:53tomojhuh
23:56p_l|hometomoj: technically, O-notation is a case of two functions, O(X), where O is a constant function representing worst-case cost, which multiplies the result of function X. '1' is basically "X is a constant function".
23:57p_l|homeOr at least that's what my barely churning, forced to work with Java and RMI brain dug out from memory.
23:57technomancyhttp://p.hagelb.org/oscon-clojure.org.html feedback welcome
23:58tomojp_l|home: what you say makes little sense to me
23:58tomojbut my brain, though thankfully not forced to work with java, is soaked in alcohol