#clojure logs

2009-02-08

00:13replacaI *do* miss reader macros - used them all the time in CL.
00:14replacaBut I'll happily prefer good syntax for data structures (and good integration too) in exchange
00:15replacaPlus, there's no real reason you *couldn't* write your own variant of the reader
00:15replacaand plug it in (at least at the repl and folks could call it directly other places)
00:25karmazillaOT: a JDBC connection is closed and returns to its connection pool. The pool sees that the physical connection is too old and closes it (in the same thread). This physical close causes an SQLException. Should this exception bubble up to user code?
01:48durka42darn bugs trying to hide
01:49ayrnieuwhen I can easily add a (println x) to the dodgy routine, they're easier to find :-)
01:53offby1it's the 21st century and we're still debugging with printfs :-|
01:54ayrnieuI just added a (send last-recv #(do % cl)) ; happy?
01:56hiredman(just-bloody-do-it ...)
01:56durka42(defmacro cry-about-it [& body] `(try ~@body (catch Exception e (clojure.contrib.stacktrace/print-stack-trace e))))
02:05ayrnieuI attached a debugging println to a server, but printed the wrong thing; server stops responding; I look at agent-errors, see the problem, clear the error, redefine the handler, restart the server -- and the effect is as if it had been a little laggy
02:05greghyou know the saying, "when in doubt, print more out"
03:01rfgpfeifferis there a difference between :when and :while in for expressions?
03:02ayrnieuYes.
03:04ayrnieu,(take 2 (for [x (range 100) :while (> x 50)] [x]))
03:04clojurebotnil
03:04ayrnieu,(take 2 (for [x (range 100) :when (> x 50)] [x]))
03:04clojurebot([51] [52])
03:05ayrnieuhttp://github.com/ayrnieu/clj-actors/blob/1c062dc5dcde01e4774793840e5f149f7d5dbc37/examples/chat_server.clj -- rough.
03:06ayrnieupresently it ignores clients until they send something, as the initial .isAcceptable() SelectionKey differs from subsequent .isReadable() SelectionKeys, which are consistent.
03:06rfgpfeiffer,(for [a [1 2 3 1] b [:foo :bar] :while (< a 3)] [b a])
03:06clojurebot([:foo 1] [:bar 1] [:foo 2] [:bar 2] [:foo 1] [:bar 1])
03:06ayrnieuso on connect I've no idea who I'm talking to :-/
03:06rfgpfeiffershouldn't the sequence stop after [:bar 2]
03:07ayrnieuthe test stops before [:foo 3], and then stops before [:bar 3]
03:09rfgpfeifferso the while only stops the sequence next to it
03:09ayrnieuwhere do you get that from?
03:12rfgpfeiffer,(for [b [:foo :bar] a [1 2 3 1] :while (< a 3)] [b a])
03:12clojurebot([:foo 1] [:foo 2] [:bar 1] [:bar 2])
03:13ayrnieuthat isn't about :while's nearness to a, but about the way that for traverses space
03:13ayrnieu,(doc for)
03:13clojurebot"([seq-exprs expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by an optional filtering :when/:while expression (:when test or :while test), and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. (take 100 (for [x (range 100000000
03:13ayrnieu>> Collections are iterated in a nested fashion, rightmost fastest,
03:14ayrnieuso it says [:foo 1] [:foo 2] [:foo -- oh, stop here.
03:14rfgpfeifferdoesn't that mean the same?
03:14ayrnieudoesn't what mean the same?
03:16rfgpfeifferwhile does not stop the rightmost first
03:16rfgpfeiffer,(for [a [1 2 3 1] :while (< a 3) b [:foo]] [b a])
03:16clojurebot([:foo 1] [:foo 2])
03:17ayrnieu,(for [a [1 2 3 1] :while (< a 3) b [:foo :bar]] [b a])
03:17clojurebot([:foo 1] [:bar 1] [:foo 2] [:bar 2])
03:17ayrnieurightmost fastest.
03:18rfgpfeifferi see
03:18rfgpfeifferanyway, a :break condition that stops everything would be handy
03:18ayrnieuif you're looking at list comprehension because you said "how do I loop in this thing?!" and 'for' seemed right, please look elsewhere.
03:20hiredmanfor is a. lazy b. not a loop, so :break does not make sense
03:20rfgpfeifferI have this prolog solver and the solutions for a query are a lazy list
03:21rfgpfeiffer:break would be the cut operator
03:21rfgpfeifferi can use take-while instead
03:22ayrnieuplease use that instead.
05:04Lau_of_DKGood morning gents
05:23niffwhere can i discuss complexity theorya nd computational models?
05:24kotarakniff: concerning Clojure? Here or on the google groups list.
05:25Lau_of_DKniff: #Haskell ? :)
05:26niffi mean in general
05:26niffCS-theory
05:28leafwniff: you can discuss anything you want, but if nobody answers, they may have put you on ignore.
05:28leafwsuch is everyone's freedom.
05:30niffone thing I dont understand is, all computational models can simulate each other. but can it be proven that there is no more powerful model?
05:31niffquantum computing for example. 1 might not be realizable; 2. doesnt solve problems turing machines cant?;
05:33Lau_of_DKtechnically it doesnt solve problems other turning machines cant, but practically it will
05:34kotarakThere is a difference between "can solve" and "can solve realistically".
05:34Lau_of_DKThats what Im saying
05:35turbo24prgis there an equivalent to sorted-map-by for a sorted-set?
05:37kotarakturbo24prg: It's an open issue.
05:37Lau_of_DKturbo24prg: You mean something like
05:37Lau_of_DKuser> (sorted-set :c :b :a)
05:37Lau_of_DK#{:a :b :c}
05:37Lau_of_DKuser> (sort [:c :b :a])
05:37Lau_of_DK(:a :b :c)
05:37Lau_of_DK
05:37Lau_of_DK?
05:37kotarakturbo24prg: http://groups.google.com/group/clojure/browse_frm/thread/9d280b6229aef384/157d50d4caeae354?lnk=gst&amp;q=sorted-set-by#157d50d4caeae354
05:41turbo24prgah, ic
05:42turbo24prgwell, it doesn't work for lists and maps but seems to work for vectors
05:42Lau_of_DKAs far as I understood, lists are to be avoided
05:42turbo24prgerm, storing these things in a sorted-set
05:42hiredmaneh?
05:42hiredmanwhat doesn't work for lists?
05:43turbo24prgi tried to store lists and maps and sets in a sorted-set
05:43turbo24prgan exception is thrown that they aren't convertable to comparable
05:43hiredmandefine doesn't work
05:43hiredmanah
05:43kotarakturbo24prg: this probably works only with sorted-set-by with a custom comparator.
05:43turbo24prgyep, that's why i asked for it
05:44turbo24prgbut it seems to work for vectors
05:44hiredman,(sorted-set '(2 3) '(4 3))
05:44clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Comparable
05:44kotarakVectors maybe compare by comparing there elements lexicographically.
05:44hiredmaninteresting
05:45turbo24prg,(sorted-set ["a"] ["c"] ["b"])
05:45clojurebot#{["a"] ["b"] ["c"]}
05:45kotarak,(sorted-set ['(1)] ['(2)])
05:45clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.Comparable
05:46turbo24prgstill, i like clojure a lot
05:46hiredmanmust be a performance consideration
05:46hiredmanhmmm
05:46turbo24prginteresting to see how the api evolves
05:46hiredmanbut you have to walk thought the whole thing anyway
05:49flupso is compleity thoery more concerned with practically computable functions thtan theoretically ones?
05:55kotarakflup: I think as the name says: complexity theory talks about theory. Compare assembler and Clojure. Both get you to your target, but Clojure maybe a bit less code.
05:56kotarakflup: then complexity theory talks about worst case complexity. Talk a SAT solver: the problem is np-hard AFAIK, but is use with great success in verification of electronic circuits, because the worst case almost never happens in reality.
06:09flupprogs.imagesearch.algorithms.rbm can i then do (:require (progs.imagesearch.algorithms [algorithms :as alg])) and alg/rbm/run?
06:11flupno doesnt work
06:11fluphow do import every file ina dir?
06:59zakwilsonSomething makes me think that agents and watchers would be a great way to implement something like Ken Tilton's Cells dataflow library.
07:05foresthow is 'clojure' supposed to be pronounced
07:05forestis it like 'closure'
07:06zakwilsonThat's how I pronounce it. I'm not sure if there's a FAQ on that anywhere.
07:10leafwinstead of clo/Z/ure I say clo/SH/ure, but I bet everybody does it differently.
07:11flupclosure si what hickey says in the videos
07:14forestye, indeed, clo/Z/ure he says, actually i am listening to an audio lectore on it in background
07:52punyahi everyone
07:52punyai'm new to clojure
07:52punyadoes anyone have any tips on using clojure with slime and qt jambi?
07:53punyai'm running this on windows vista and though everything seems to evaluate just fine, i don't see any GUI output
08:00klirrpost your code...
08:00klirri use java-swing + contrib-miglayout for GUIs
08:02punyahttp://paste.lisp.org/display/75055
08:02punyaklirr: my main reason for using jambi is that it has nice webkit bindings
08:03punyaklirr: i should mention that this code works (i.e. displays a window) when i run it from the command line using clojure.lang.Script
08:05klirrwhen doesnt it work then?
08:05punyaklirr: from slime
08:05klirrfrom the repl in slime?
08:05punyaklirr: yes
08:05klirrhmm i just use clojure +emacsmode for clojure
08:06klirrwhere do i download qt jambi?
08:07punyaklirr: http://www.qtsoftware.com/downloads/opensource/appdev it's a pretty big download, and possibly not worth the pain if you're just curious
08:08punyaklirr: (you have to pick one of the two qt for java links)
08:08klirrok
08:20punyaokay, well thanks for taking a look!
08:20punyaand good night
08:32wlrzakwilson: re Cells: not a new thought. search for posts, esp by Stuart Sierra, on clojure's google group.
09:04slaney /clear
09:04slaneyheh
10:15te'LO
10:15teerr, 'lo
10:26zakwilsonwlr: It also looks like there's a Cells library by Kre?imir ?ojat. I'm interested in building a library to make working with Swing nicer, and I think a Cells-style dataflow extension is required.
10:32tewhoa.
10:32teim having a mild epiphany with regard to lisp, clojure, etc.
10:35te]\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\===========================''''''''''=\
10:35te]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
10:35tewhoa.
10:35slaneycat?
10:36tespaced out really bad haha
10:36teim in deep thought trying to visualize the way the data moves in lisp
10:36slaneynice
10:48teIs there a diagram anywhere that shows a function and a diagram side by side?
10:54wlrzakwilson: intiguing are comments from rhickey suggesting a rethinking of the whole cells-like paradigm based on a more concurrent/parallel pov. when i try, my meager apportionment of gray cells quickly goes tilt.
10:56zakwilsonwlr: It seems like things would be quite parallel if a cell was an agent and the inputs were any of the IRef types.
11:01wlrzakwilson: does "being consistent" have any meaning without some notion of a logical or actual point in time at which they are consistent?
11:01teholy shit
11:01tei think i just got it
11:01tesorry guys -- having some eipiphanies
11:01teepiphanies
11:05zakwilsonwlr: I can see how that would be a problem for some applications - values of cells made using agents could become out of date in a concurrent application. Maybe updates need to happen in a transaction... but that doesn't really match the simple agent/watcher model I had in mind.
11:09wlrzakwilson: surely i've got to clarify my thinking on the matter. anyway, good luck with your library.
11:25niffisnt this correct: (let [s (svm.)]
11:25niff (load_model s data)
11:25niff s)) ?
11:26niffah
11:26niff.
11:27dreishI wish I'd gone with Carbon Emacs instead of Aquamacs.
11:28durka42why?
11:28dreishI've wasted so much time over the last few months just trying to find that little vertical-bar cursor.
11:28niffwhy doesnt i get an error when usign a method that doesnt exist?
11:28durka42what happens instead?
11:28dreishniff: Are you talking about load_model above?
11:29dreishIf that's supposed to be a method invocation rather than a function call, it should be (.load_model s data)
11:30tedurka42: could you show me an example of passing a sequence of functions to a function?
11:31Chouser,(map #(% 1 2) [+ - * /])
11:31clojurebot(3 -1 2 1/2)
11:31teChouser: was that at me?
11:32te,(map #(% 1 2) [ - + / *])
11:32clojurebot(-1 3 1/2 2)
11:32niffdreish: changed that
11:32stimulihi
11:32tehello
11:32durka42hello again
11:32Chouserte: yep, that was a sequence of functions (seq [+ - * /]) being passed to a function 'map'
11:33stimulithat errorkit thing looks pretty cool
11:33stimuliIf someone had asked me if you could have lisp style conditions in clojure I would have said "it can't be done on the jvm"
11:33stimuliso natually someone did it
11:33Chousukehow does it perform though? :/
11:33stimulino idea
11:34stimulinot as fast as exceptions I'd suppose
11:34ChousukeI guess that's not always an issue though
11:34dreishClojure is Turing-complete.
11:34stimulibut if you need it ...
11:34stimuliTeX is turing complete :)
11:34Chousukedreish: and macros make it possible to hide the awkwardness of pretty much anything :)
11:34dreishOf course, a Turing machine would probably take trillions of years to do conditions.
11:35ChouserI have't profiled it yet (want to get it correct first) but with-handler, handle, continue and raise should all be very fast, possibly faster than Java exceptions.
11:36stimuliI assume you're just wrapping up the handlers in some data structure and passing them down the call chain
11:36Chousersorry, continue-with, not continue.
11:37Chouserusing continue, bind-continue, or just returning a value from a handle should be competitive with Java exceptions, but may be slower.
11:37kefkaI know that killing threads in Clojure/Java is deprecated. What's the proper way to free a thread that you don't want any more?
11:37dreishPoll a variable. :(
11:37durka42it seems to me that a condition system like this will get deeply ingrained in an application's logic, so if someone were worried about performance (which isn't always the case) profiling data would be good, because extracting it might take a substantial rewrite
11:37Chousukekefka: poll Thread/isInterrupted I think
11:38Chousukekefka: and then from outside run .interrupt on it.
11:38stimulikefka you have to have a protocol between threads
11:38stimuligoogle "java thread interrupt"
11:38stimulithere are lots of ways to do it wrong
11:38durka42~thread
11:38clojurebotNo entiendo
11:38durka42~destroy
11:38clojurebotNo entiendo
11:38ChousukeClojurebot just uses stop :p
11:38stimulibut basically waht chousuke said
11:38durka42he has a factoid on it, but i forget what it's called
11:39kefkaSo I poll Thread/isInterrupted, then if it's not, use .interrupt
11:39teIs it possible that I'm simply not smart enough to learn clojure?
11:39kefkaAnd interrupting frees the resources?
11:39Chousukekefka: .interrupt on a thread makes isInterrupted return true; nothing more.
11:39kefkate: It's possible, but unlikely. If you're smart enough to learn Java, you're smart enough to learn Clojure
11:40Chousukekefka: except if it's waiting, in which case it'll throw an InterruptedException in the thread
11:40tekefka: I didn't come from Jabba
11:40tekefka: Easy on the insults
11:40Chouserte: what's your background?
11:40teRuby, C++
11:40Chousukeruby is closer than C++
11:41ChouserI think Clojure is *much* simpler than C++
11:41kefkate: No insult.
11:41teyeah i was just reading that in paul graham's book
11:41niffhttp://www.textpresso.org/clustering-software/javadoc/libsvm/SVM.html
11:41niffthats what im trying to use
11:41forestlisp is generally hard for people
11:41tehe showed the example of def blah { |i| i+=1 }
11:41kefkate: I know nothing about you. There are some people who are not smart enough to learn Clojure, but I highly doubt you're one of them, if you're here.
11:41stimuliyeah ..... C++ is hard to learn and hard to use .... Lisps are hard to learn and easy to use
11:41Chousukeforest: I think it's functional programming that people have a hard time adjusting to
11:41forestit is needed to think differentky
11:41Chousukeit's just that much difficult.
11:41tekefka: thanks -- im just trying to marinade myself in it long enough to get it
11:41Chousukeer,
11:41Chousukedifferent* P
11:41Chousukenot difficult :P
11:41stimulite : don't be in a rush and have fun
11:42tegood advice
11:42forestyes, add FP to lisp and things get even more difficult
11:42Chousukeforest: er, no.
11:42Chousukeinherently, lisp is not difficult.
11:42Chousukenor is FP
11:42durka42niff: those are all static methods, you will want to call (SVM/svm_load_model "etc")
11:42Chousukebut they're different from waht people are used to
11:42forestsure, if you are not accustomed to java/c/pascal
11:43lisppaste8klirr pasted "libsvm donka donka" at http://paste.lisp.org/display/75064
11:43Chouserdoing anything with a function besides calling it is one step more difficult, like pointers vs. named variables in C
11:43ChousukeIt'll just take some time to rewire your brain so that it's not dependent on mutability and imperative tools.
11:43durka42are you getting errors on that import? i would think the jvm is case sensitive there
11:43Chouserand even the less functional lisps do a lot more of that than C++ or Java do.
11:43testimuli: i think i just need to build my confidence, the language seems daunting at first -- i think i just need to get my hands on something i can toy with
11:43temaybe compjure is a good idea
11:44Chousukeif you get past that, functional programming is *easier*
11:44Chouserte: I highly recommend doing the Project Euler problems from the beginning.
11:44offby1Chouser: I did the easiest ones first :)
11:44offby1and then pooped out after 40 or so.
11:44offby1(And didn't do them in Clojure, either)
11:45stimuliI think "compojure" is a great name .... I predict its outrageous success on name alone
11:45teyeah definitely
11:45forestwould be interesting to see clojure solution to this http://www.topcoder.com/stat?c=problem_statement&amp;pm=10268&amp;rd=13696&amp;rm=&amp;cr=9946038
11:45dreishThe SICP lectures were helpful for me in learning functional programming.
11:45Chousukewhat I like most about functional programming is that I can write one function, ensure it does what it does, and then forget entirely how it's implemented, since it doesn't matter :)
11:45tedreish: ive been watching those
11:45tebut that guy with the lack of hair and excess sweat
11:45temakes me cringe
11:46forestChousuke: it is also true for imperative langs
11:46niffah i see
11:46Chousukeforest: no it's not. with FP, all that matters is whether your function returns the values it's supposed to; with imperative programming, what matters is what the function DOES.
11:46dreishAnd I also solved my hard-to-find Aquamacs cursor problem: M-x customize-group <enter> cursor <enter>; change color to something with better contrast against my background.
11:46Chouseroffby1: yeah, I've not gotten past about 50
11:46durka42forest: behind a login :( want to paste it or something?
11:47durka42now i'm curious
11:47Chouserbut that's plenty to get a decent level of comfort on a new language.
11:47offby1and I cheat, too: I mostly use a particular math library which, I suspect, was written specifically to do Project Euler. Many of my programs are like three lines long
11:47offby1cheating is underrated
11:47Chousukeforest: it's about side-effects: functional languages avoid them, while they're everywhere in a imperative language.
11:47ChouserIf I ever learn Haskell I'll probably do those same problems again.
11:47niffChousuke: yeah me too, mostly i like sideeffectfree very composotional programs you get so you can isolate effects and errors easily and much easier prove the program works
11:48niffthen if you want to go "all" the way like haskell or not is another less important question
11:48forestChousuke you can still add Unit tests)
11:48Chousukeforest: in a function in an imperative language, even something simple as an assignment may make a crucial difference between whether your code returns the correct value or not.
11:49Chousukeif it's multithreaded for example.
11:49Chousukeit's not perfectly isolated.
11:49forestdurka42: i am sorry without a login it is not possible, i thought it was generally available, (Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited) sorry for confusion
11:50durka42no worries
11:51Chousukeniff: I don't think provability matters
11:51Chousukeniff: but the ability to make pure functions efficiently does.
11:52Chousukepure functions are much easier to reason about and use than something that might have external dependencies.
11:52Chousukeyou can have pure functions in C too of course, but they're cumbersome to write and very likely inefficient as well :/
11:56forestmultithreading is an issue, but with a good architecture you may have pretty much isolated units of code almost always in single threaded environment
11:57Chousukeforest: functional programs have that architecture by default though :)
11:57Chousukeespecially if it's enforced, like in haskell :P
11:59forestok, let me change a problem given a matrix 10x10 compute its permanent, http://en.wikipedia.org/wiki/Permanent
11:59forestwould be nice to see clean implementation
12:01durka42i don't even understand that formula :\
12:02Ariensyou must read the symetric group definition 2
12:02forestit is like determinant, but you never substract
12:04ChousukeI don't even remember how to calculate the determinant :P
12:04Arienslol
12:05forestnever mind :)
12:05Ariensforest: why don't you use the recursive solution for determiants?
12:05durka42so you could calculate it like the determine but without doing that checkerboard sign thing?
12:06ChousukeI can't figure out what that small sigma notation is supposed to mean, either
12:06durka42it's the symmetric group
12:06durka42there's a formula without sigma on http://en.wikipedia.org/wiki/Computation_of_the_permanent_of_a_matrix
12:07forestsigma - it is just a permutation if {1, 2, ..., n}, and iteration is over all of them (n!)
12:07forestif=of
12:08forestAriens: yes, recursive solution is intended
12:08durka42ouch, O(n*n!)
12:09forestlet matrix be 6x6 - it is fast
12:11Ariensforest: use a recursive solution with and hash with 2 element lists as keys and make a function reject to create a new hash based on some criteria
12:11forestso even here in very simple example you need to update many cell of an array (vector) - and you have to get penalty of persistent collections even if you don't need previous version
12:11Ariensan*
12:13forestit seems to me that doing computations in clojure is pain
12:13gnuvince_how so?
12:14forestyou have to pay big penalty for persistent collections
12:15Arienshave you tried type hints?
12:15foresti believe there is no chance adding plain mutable collections and arrays that are local to a function
12:15forestwhat are type hints
12:16dreishWhat do you mean no chance? You can have Java arrays in Clojure.
12:17Ariensforest: you can tell clojure an argument is of a particular type
12:17Ariensit improves performances for intensive numeric jobs
12:17dreishYou can use java.util.HashMap if you're dead certain you want it.
12:18foresti need to investigate into it...
12:18dreishdoto is a nice syntax for working with Java collections.
12:18Arienssince Big number arithmetic is replaced by native arithmetic
12:19forestthe author of the language is so much talks about how persistent is absolutly good that i supposed there is the only way to go)
12:20dreishI tend to agree, but nobody's forcing you to refrain from using what Java offers.
12:21Arienswe need a matrix library in clojure
12:21Ariens:p
12:21dreishI think your code is going to end up being harder to reason about in 99% of cases, and that it's better to write it the idiomatic way first and get it working, then see whether and where you need major efficiency gains, and whether there's any way to get them.
12:23durka42all right how do i check if i calculated the permanent correctly :p
12:23forestwe can always write a hard part in low level language like java
12:24Ariensdurka42: you print it?
12:24durka42no, i mean i need to check my answer
12:24durka42i imagine i could do it with matlab or mathematica
12:24Ariensformaly?
12:24Ariensll*
12:25foresti guess it is no easy way
12:25Ariensyou need a formal proof that you code is correct?
12:26durka42not at all
12:26durka42i want a reference implementation so i can spot-check my calculation
12:27Lau_of_DKGood evening gentlemen
12:27danlarkinHi Lau
12:28durka42hi lau
12:28Lau_of_DKdanlarkin: so... any news? :)
12:28Lau_of_DK"Bio Hansard" ? :)
12:29danlarkinhaha
12:29danlarkinnope no news yet
12:29Lau_of_DKk
12:36StartsWithKlisppaste8: help
12:36lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:37niffhow do is et a make-array from clojure?
12:37niffohw ait i use arrays interface
12:37lisppaste8StartsWithK pasted "Tree paths" at http://paste.lisp.org/display/75066
12:38StartsWithKChouser: i tried to finish that tree paths function, this is the shortes solutions i could find, any ideas how to make it shorter?
12:45stimulihere is one for you guys : does anyone know a O(n * ln(n)) algorithm to partition a directed graph into mutually recursive subgraphs ?
12:45tehow do i do this in compojure: (routes/ANY "/*" [(html (bold ("Hello world!")))]))
12:45stimuliI have a simple polynomial time algorithm
12:45niffhow do you dow ith your user-file? put it ina namespace?
12:45niffbut then it is not asscessable by defualt right?
12:46niffAriens: why? I made a simple one...but there is java colt if you want a high performanc ehigh quality one
12:46zakwilsonforest: I wrote image processing code in Clojure and got decent performance (with a bit of optimization help from Rich), so it's certainly possible to write fast computational code.
12:47Lau_of_DKte, something like (ANY "*" (layout "foo" [:h1 "Hello"]))
12:47foreststimuli: define the problem better what is mutually recursive
12:47Lau_of_DKIn the definition of your servlet
12:47forestzakwilson: and what about memory consumption, is it higher that it would be in plain java
12:48zakwilsonSince I never wrote a Java version, I couldn't tell you for certain, but my guess would be no.
12:49zakwilsonIt was destructively modifying a Java BufferedImage, but computing the pixel values was a pure Clojure function.
12:49teLau_of_DK: hmm how can i make say a sidebar, and then pass that as a function to the servlet Lau_of_DK
12:49teor whoever
12:50foresti just was watching presentation with famous ant colony example - it ate >140M, too big
12:51foreststimuli: your question does not make any sense to me
12:51stimuliforest : mutually reachable ... that is if a can reach b and b can reach a
12:52stimuliforest : think of functions that can call each other
12:53teLau_of_DK: that threw an error
12:53Lau_of_DKte: I dont know how you make a sidebar specifically, but you pass it as you would anyother function, replacing (layout ...)
12:53forestmaybe it is vertexes ? that are reachable one from another ?
12:53niffis there a way to slurp line by line from clojure?
12:53te,layout
12:53clojurebotjava.lang.Exception: Unable to resolve symbol: layout in this context
12:53leafw,(doc line-seq)
12:53clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
12:54foreststimuli: maybe it is vertexes ? that are reachable one from another ? subgraphs and functions are still not connected for me
12:54leafwniff: so yes, as per above. Use in combination with: (with-open [...] ... )
12:54Lau_of_DKte, scrap layout, use (html (doctype :html5) [:html [:head [:title "Hello"] ] [:body "Hi there"]]) If that doesnt work Im blank, my experience with compojure is 15 minutes of reading
12:54stimuliforrest : yes
12:55leafwniff, see an example here: http://github.com/acardona/xmms2-clj/blob/89ae9d125af9968fefcf7c31505c23000a29c0f4/xmms2.clj#L34
12:55stimuliuh .. say function one calls function two .. then draw and arrow from one to two
12:55stimuliso now your function dependencies are a graph
12:55durka42is there a remove-nth?
12:55kotarak_durka42: dissoc fot vectors?
12:55stimuliI want to find all the mutually recursive clusters
12:56durka42,(dissoc [1 2 3 4 5 6] 2)
12:56clojurebotjava.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to clojure.lang.IPersistentMap
12:56foreststimuli: it is http://en.wikipedia.org/wiki/Strongly_connected_component
12:57durka42,(concat (take 2 [1 2 3 4 5 6]) (drop 3 [1 2 3 4 5 6]))
12:57stimuliyeah
12:57forestwhich can be solved in O(E+V)
12:57durka42uh
12:57durka42clojurebot: botsnack
12:57durka42oh dear
12:57stimulibut I need to find all components that intersect
12:57forestthey form a tree
12:58forestwhere a vertex of this reachability tree - is strongly connected component
12:58niffhwta is \r ?
12:59forestand the strongly component consists of vertexes each pair from which is mutually reachable or how you call them mutully recursive
12:59durka42niff: carriage return
12:59stimuliright .. I was sort of doing tarjan ... I was hoping for something wehre I didn't have to walk a tree from each node
12:59durka42niff: windows encodes line breaks as \r\n. unix as \n
12:59foresthttp://en.wikipedia.org/wiki/Kosaraju%27s_algorithm - it linear on number of edges
13:00forestyou just can not do better
13:05stimuliforest : thanks ... that link gave me a solution
13:07te,paste
13:07te,paste
13:07foreststop paste )
13:07tehow do i get the pastie
13:08durka42~paste
13:08durka42oh yeah, clojurebot died
13:08ted'oh
13:08durka42lisppaste8: url
13:08lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
13:09lisppaste8te pasted "compojure" at http://paste.lisp.org/display/75067
13:09tehow do i make that sort of thing workj?
13:09tework?*
13:10lisppaste8durka42 pasted "permanent" at http://paste.lisp.org/display/75068
13:11Lau_of_DKCan somebody dig up that link from the logs, that technomancy pasted last night? The file was called concourse.tar.gz, but I lost the full path to it
13:11durka42forest: there you are
13:11Lau_of_DKte: If somebody finds that link, it'll answer all your compojure related questions
13:12Lau_of_DKIf you have some time, you might want to hold out for danlarkin's project: Clabango Django Jango, it should be quite interesting
13:12danlarkinoh jeez
13:13teLau_of_DK: http://paste.lisp.org/display/73997
13:13Lau_of_DKnope
13:13forestdurka42: unable to resolve symbol remove-nth
13:13teerrr this? http://paste.lisp.org/display/75030
13:13durka42Lau_of_DK: this one? http://p.hagelb.org/concourse.tar.gz
13:13durka42forest: whoops, rename that without function to remove-nth
13:14Lau_of_DKte: http://p.hagelb.org/concourse.tar.gz
13:14Lau_of_DKoh.. yes durka durka
13:14Lau_of_DKthats the one
13:15durka42that google custom search doesn't seem to index so well
13:15teLau_of_DK: durka42: sweet!
13:15tethanks
13:16Lau_of_DKno probs
13:16tethis is what ive been looking for all along
13:17Lau_of_DKFriends like Durka durka and I ?
13:18danlarkinhow best to express a function that takes a collection of functions and applies (rest coll) to (first coll) successively down the coll
13:19Lau_of_DKcascade-fn ?
13:21forestdurka42: nice, but less much readable that imperative implementation
13:21foresti suppose it was also much harder to implement
13:23durka42eh, it was just fiddling
13:23durka42that impementation is also how i think of the formula
13:24durka42you expand across a row/column, multiplying each element by the permanent of the matrix created by removing the row and column containing said element
13:24forestalso i guess it will be also pretty hard to add memoization, for computing perm for matrixes say 20x20
13:24forestlike in perl)
13:25durka42there is clojure.core/memoize
13:26durka42i wonder if it would speed things up, since you'd have to do deep compares every time
13:27forestsure current implementation will never stop for for 20x20
13:28durka42never?
13:28forestaha, a disaster will happen earlier that will break the machine
13:30forestbest way to do memoization is having a key as integer with corresponding bits set for used columns
13:30forestso it is very fast - 2^n *n
13:30Chousuke2^n*n is fast? :/
13:31forestit is all relative, if compared to n! - yes )
13:32forestif i remember correctly computing permanent is NP-hard, so you can not do much better, for n=20 it is fast enough
13:32durka42but will you ever be computing the same permanent?
13:35forestsuppose you used columns 1 4 5 in first three rows having current product X, after that you need to sum all permutations of matrix without first three rows and columns 1 4 5 and multiply by X
13:36forestso you need perm of that new matrix - and it depends only on number of first rows and which columns we already usd
13:38durka42sorry, i don't really get it
13:40forestif T[i] - matrix A without row and column i, that perm A = A[1][1]*(perm T[1]) + A[1][2]*(perm T[2]) + .... +A[1][n]*(perm T[n])
13:40forest*without row 1
13:41durka42yeah
13:41gnuvince_,(* 33 237)
13:41durka42the bot has left us :(
13:42durka42forest: but you only use (perm T[i]) once for each i
13:42forestif Q[a][b] is matrix A without rows 1, 2 and cols a b that perm A = Sum_over_all_pairs(a, b) A[1][a]*A[2][b] * perm(Q[a][b])
13:43durka42oh, i might see what you mean
13:43durka42although trying to visualize it is making my head hurt
13:43RaynesRun fo'est run!
13:43forestthen triples and so on
13:43durka42i should be able to do this since i took linear algebra...
13:44durka42clojure.core/memoize doesn't help at all
13:44forestyou'd better think of it as if you never knew linear algebra
13:44durka42why?
13:44forestit is elementary thing
13:45forestyou just take A[1][a]*A[2][b] out of parenthes for all products that have a in row 1 and b in row 2
13:47blbrown(defmacro async-call [display & body] ...in this code, what is the purpose of the '*&'
13:48stimuliblb : it binds body to a stream of the remaining arguments
13:48ayrnieuasync-call receives one argument, bound to display, and then N arguments in a list, bound to body
13:48stimuliayr : is it a list or a stream ?
13:49durka42it's just a list
13:49stimuliok
13:49kotarak_blbrown: (async-call the-display) => body is nil, (async-call the-display some) => (some), (async-call the-display some thing) => (some thing) ...
13:49forestit is easy to find out - just run Repl under debugger
13:49stimuliof course, by stream I meant seq
13:49ayrnieuclojure.lang.ArraySeq , looks like.
13:49lisppaste8klirr pasted "dss" at http://paste.lisp.org/display/75071
13:50ayrnieuforest - or you can just ((fn [& rst] (class rst)) 1)
13:50niffwhy isnt memoization working there? ^^
13:51ayrnieuniff, it works fine there.
13:51forestayrnieu: ye it is slightely more handy
13:51durka42my guess is the internal calls to fib don't call the memoized version
13:52stimuliwhen I'm coding I'm almost never aware if I'm using a col or a seq ... I'm sure sooner or later that will cause a bug
13:52niffayrnieu: yes it works but it isnt speeded up
13:52niffdurka42: so how do i make them?
13:52niffmemoization ony works for recursion right?
13:53niffor does the jvm store the function calls then so it is not for recursion but rather for caching?
13:53ayrnieuniff - (let [f-aux (memoize fib)] (defn f [n] (binding [fib f-aux] (f-aux n)))
13:53ayrnieuniff - subsequent (f 34)s return immediately, as you'd expect. The memoization works, it's just what durka said.
13:54lisppaste8durka42 annotated #75071 with "striking difference" at http://paste.lisp.org/display/75071#1
13:55durka42forest: FWIW, matlab is still churning on my 10x10 matrix
13:55durka42clojure: FasterThanMatlab!
13:55durka42unless the matlab permanent function i found just has a bug
13:55niffi see
13:55niffdurka42: how can anything be churning ona 10*10 matrix?
13:56niff10K you mean?
13:57forestn! grows rather fast
13:57durka42clojure did the 10x10 matrix in 53 seconds
13:58Ariensis the result correct?
13:59ayrnieu(defn matrix-multiy [& _] 0)
14:01niffanyone used libsvm? i have a weird error : unknown text in model file , could eb windows usign \r\n and not just \n. anyone know?
14:01durka42ayrnieu: i'm not sure about that approximation :)
14:01niffis matlab generalyl slow? allt he matlab toolbox stuff is it written in matlabs language or in C?
14:02Chousukeniff: matlab is not slow
14:02Chousukeit would be stupid if it were...
14:02durka42well, it is sometimes
14:03Chousukewell, I guess.
14:03durka42i've certainly heard of people writing things in matlab because it's good at math, and then porting to C
14:03forestin any language they could implement it for small sizes up to 15-20 to be lightening fast
14:03Chousukedurka42: I guess matlab's own language is not that fast
14:03blbrownayrnieu, in your macro example earlier. I guess it doesn't make any sense to do this. (defmacro m [a b & body something-else] ...
14:03forestpermanent is rarely used function I suppose
14:03blbrownayrnieu, eg something-else wouldn't work
14:03Chousukeit's just "glue" for the libraries that are fast
14:04ayrnieublbrown, what macro example?
14:04Chouserblbrown: that's right
14:04Chouser,(fn [a & b c])
14:04durka42blbrown: clojure doesn't allow that
14:04durka42java.lang.Exception: Unexpected parameter
14:04Chouserbut you can destructure in the 'rest' position
14:05blbrowndurka42, so define the arguments 'required' before the & body ...stream (I am not explaining that right am I ?)
14:05Chouser(,(let [[a & [b c]] [1 2 3]] [a b c])
14:05blbrownChouser, oh man are you confusing me
14:05Chouser:-)
14:05Chouserclojurebot too, apparently.
14:05Chouser,(let [[a & [b c]] [1 2 3]] [a b c])
14:05ayrnieuclojurebot died earlier.
14:05durka42Chouser: what is the point of using the rest position, then?
14:05durka42i gave clojurebot a ClassCastException and he died
14:05durka42i seem to be good at that
14:05blbrownhehe
14:06blbrownhe needs my new
14:06blbrown(when-try) macro
14:06durka42blbrown: define the required parameter first, yes, and then you can have a & before the last parameter to gobble the rest into a seq
14:06Chouserdurka42: it's optional
14:06durka42parameters*
14:06blbrowndurka42, good explanation
14:06durka42i mean, if you're going to use [a & [b c]] why not just do [a b c]
14:07Chouser((fn [a b] {:a a, :b b}) 1 2) ==> {:a 1, :b 2}
14:07Chouser((fn [a b] {:a a, :b b}) 1) ==> Exception
14:07Chouser((fn [a & [b]] {:a a, :b b}) 1) ==> {:a 1, :b nil}
14:08gnuvince_Isn't it the inverse order?
14:08gnuvince_{a :a, b :b}?
14:08Chousersorry, now I'm confusing you
14:08Chouserthe map there isn't destructuring, just returning results
14:08durka42ah, i see
14:09ayrnieugnuvince, it's {key value key value}
14:09durka42that seems like a klunky way to have optional parameters, but it works
14:09durka42what the hell is wrong with matlab
14:09Chouserdurka42: yeah, I wouldn't recommend it.
14:10Chouser((fn f ([a] (f a nil)) ([a b] {:a a, :b b})) 1)
14:10durka42right
14:10Chouserthey're all kinda clunky when packed onto one line
14:15niffwhat is the advantage of matlab over something like java matrix lib like colt? all the toolboxes?
14:15niffbut if you want to use it in an application...?
14:15leafwniff: matlab has a debugger and docs built in
14:15nifflike clojure :)
14:16skogs(defmacro mm [arg] (let [[p q] arg]`(and (isa? 'x ~p) (isa? y ~q))))
14:16durka42what are x and y? and why not take [p q] instead of [arg]?
14:17skogsmy q is would y same as lexical y into which it expands
14:19durka42in the future remind me not to set matlab on a 15 minute calculation and not print out the answer
14:19skogscan i write a macro that expands to use a lexical symbol
14:20gnuvince_Does C-c C-c work for anyone in SLIME to stop a Clojure operation?
14:21skogsany macro experts in house?
14:23ayrnieuassume that they're here and ask a question that they may answer.
14:24skogsayrnieu: did u see the macro i just posted
14:24ayrnieu(defmacro inc-it [] `(dosync (commute ~'it inc))) , (let [it (ref 0)] (inc-it) (inc-it) (inc-it) @it)
14:25durka423
14:25ayrnieuskogs - `y expands to *ns*/y -- look at ['a 'b `a `b] at the repl
14:25durka42~'it prevents quasiquote from trying to resolve it
14:26skogsoh! so i need a quasiquote
14:26durka42sorry, quasiquote is the backquote
14:27ayrnieuyou've already found quasiquote: `
14:27durka42`
14:27durka42i screwed something up so i can't type ` except in vim, need to fix that
14:28skogsso *ns*/x is different from lexical x?
14:28ayrnieuit depends on the namespace.
14:29skogswell, in the same namespace
14:29skogsas macro expands to *ns*/x and thats not same as x
14:29ayrnieutry: (let [it 0] (eval `(+ it 1)))
14:29AWizzArdif you have in ,,user" (def x 10) and then do (let [x 15] (print user/x)), then it will print 10
14:30gnuvince_If I have a 2D vector ([[0 1] [2 3] [4 5]]) and that I want to conj something onto one of the inner vectors, how should I do that?
14:30skogsso *ns*/x resolves to global variable
14:30AWizzArdskogs: indeed
14:31ayrnieu'namespace variables', you could say.
14:31ayrnieuif you (def x 10) x is also in the lexical scope of the subsequent forms
14:31skogsr they same as dynamically scoped variables
14:31ayrnieuno.
14:32durka42so the clojure program is correct, and fourteen times faster than the matlab program
14:32ayrnieuOK, nevermind.
14:32ayrnieu(def x 10) (defn f [] (+ x 10)) (binding [x 20] (f))
14:33AWizzArdgnuvince_: you traverse your datastructure
14:33AWizzArdgnuvince_: basically you write your own version of filter
14:33AWizzArdIt is a design pattern in functional programming languages to implement map/reduce/filter from time to time.
14:33gnuvince_AWizzArd: nothing built in?
14:34AWizzArdwell, in principle you could also work with these zippers I guess
14:34skogsayrnieu: got it, thx
14:34durka42(concat (take (dec n) matrix) (conj (nth matrix n) 12) (drop (inc n) matrix))
14:35AWizzArdgnuvince_: and you could do it also with built-in functions, but it might not always be very clean
14:35ayrnieugnuvince - write a matrix-oriented update-in
14:35Chousukeayrnieu: matrix-oriented? :/
14:35ayrnieuYes.
14:36Chousukeif your matrix is a vector of vectors, you can just use the regular update-in
14:36Chousukefor non-vectors I suppose you'd need something else.
14:37gnuvince_ayrnieu: ah, this works well enough: (update-in [[0 1] [2 3] [4 5]] [1] conj :a)
14:37ayrnieuoh, I tried it wrong.
14:56durka42,(prn "I'm alive!")
14:56clojurebot"I'm alive!"
14:56durka42yay
14:56durka42hiredman: do you know what happened?
14:56hiredmanmachine went offline
14:56durka42oh
14:56durka42so it just happened to coincide with my buggy code
14:57hiredmanmaybe your buggy code killed the machine :P
14:58durka42it was just a ClassCastException!
15:03blbrownam I wrong or should the macro (time) display 'secs' as opposed to msecs
15:04Chousukeblbrown: no, it shows msecs
15:04hiredmanlast I checked (months ago) it was msecs
15:04Chousuke,(time (+ 1 1))
15:04clojurebot2
15:04clojurebot"Elapsed time: 0.152 msecs"
15:04blbrown,(time (+ (range 100))
15:04clojurebotEval-in-box threw an exception:EOF while reading
15:05Chousukeforgot apply :)
15:05hiredmanyou need an apply there
15:05durka42,(time (Thread/sleep 1000))
15:05clojurebot"Elapsed time: 1001.088 msecs"
15:05blbrownhmm
15:08ayrnieu,(java.util.Date. (long (* 1000 1234567890))) ;; THIS WEEK
15:08clojurebot#<Date Fri Feb 13 15:31:30 PST 2009>
15:08blbrown,(time (Thread/sleep 10000))
15:08clojurebotExecution Timed Out
15:08blbrown,(time (Thread/sleep 3000))
15:08clojurebot"Elapsed time: 3001.374 msecs"
15:11forest,(.. System getRuntime (exec "sudo reboot"))
15:11clojurebotjava.lang.NoSuchFieldException: getRuntime
15:11blbrownooooooo
15:11forest)
15:11blbrowndenie
15:11blbrownd
15:12hiredmanwell
15:12hiredmanyou have to use System/getRuntime
15:12hiredman,(System/getRuntime)
15:12clojurebotjava.lang.NoSuchFieldException: getRuntime
15:12Chousuke,(System/runtime)
15:12clojurebotjava.lang.NoSuchFieldException: runtime
15:12hiredmaner
15:12Chousukehmm
15:12blbrownit is blocked I bet
15:12hiredmannah
15:13Chousukeit is, but that's not the right exception
15:13Chousuke,(.getRuntime System/Runtime)
15:13hiredman,(System/Runtime)
15:13clojurebotjava.lang.Exception: No such namespace: System
15:13clojurebotjava.lang.NoSuchFieldException: Runtime
15:13hiredman,(.getRuntime (System/Runtime))
15:13clojurebotjava.lang.NoSuchFieldException: Runtime
15:13blbrown,(let [r (. Runtime getRuntime)])
15:13forest,(.. Runtime getRuntime (exec "sudo reboot"))
15:13clojurebotnil
15:13clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
15:13ayrnieu,(.. Runtime getRuntime availableProcessors)
15:13clojurebot1
15:13ayrnieu,(-> Runtime (.getRuntime) (.availableProcessors))
15:13clojurebotjava.lang.IllegalArgumentException: No matching field found: getRuntime for class java.lang.Class
15:13blbrown ,(.. Runtime getRuntime totalMemory)
15:14hiredman,(Runtime/getRuntime)
15:14clojurebot#<Runtime java.lang.Runtime@1401d28>
15:14hiredman,(.exec (Runtime/getRuntime) "sudo reboot")
15:14clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute)
15:14hiredmanthere we go
15:14blbrown ,(.. Runtime getRuntime freeMemory)
15:14blbrown ,(. Runtime getRuntime freeMemory)
15:14hiredmanhmm
15:14hiredmanclojurebot: ping?
15:14clojurebotPONG!
15:15blbrowndoesn't like me
15:15hiredmannah
15:15blbrown ,(. Runtime getRuntime maxMemory)
15:15Chouser~roulette
15:15clojurebotclick
15:15hiredmanit doesn't like your spaces
15:15blbrown,(. Runtime getRuntime maxMemory)
15:15Chousuke,(.. Runtime getRuntime gc)
15:15clojurebotjava.lang.Exception: Unable to resolve symbol: maxMemory in this context
15:15clojurebotnil
15:15blbrown,(.. Runtime getRuntime maxMemory)
15:15clojurebot66387968
15:15blbrown,(.. Runtime getRuntime totalMemory)
15:15clojurebot5177344
15:15blbrown,(.. Runtime getRuntime freeMemory)
15:15clojurebot2472128
15:16blbrown64 MB default jvm memory, you might increase that
15:16hiredman*shrug*
15:16blbrownhiredman, are you running the bot
15:17hiredmanI used to run it with a lot less
15:17hiredmanyessir
15:17blbrownnice
15:17blbrownhiredman, you run it off a virtual host or your own home box or somethig
15:17ayrnieu,(-> (.. Runtime getRuntime maxMemory) (/ 1024) (/ 1024))
15:17clojurebot1013/16
15:17blbrown(. System getProperty "os.name")
15:17blbrown,(. System getProperty "os.name")
15:17clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission os.name read)
15:18Chousuke,(/ (.. Runtime getRuntime maxMemory) 1024 1024)
15:18clojurebot1013/16
15:18forest,(. System exit 0)
15:18clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0)
15:18blbrownhiredman, OK, I will stop messing with the bot
15:18durka42well, they do have the same ip address
15:18blbrownforest, you are evil, hehe
15:18forestjust security tests ...
15:18Chousukeforest: if you succeed in breaking it you have succeeded in breaking the java sandbox model.
15:19Chousukeit has a few weaknesses though
15:19blbrownI bet a runtime error could choke it
15:19Chousukeyou can spawn new threads for example.
15:23ayrnieubut if you want to have fun breaking it, please get the clojurebot source and do it without pulling a durka42 :-)
15:24blbrownclojurebot, source
15:24durka42clojurebot: where are you?
15:24clojurebothttp://github.com/hiredman/clojurebot/tree/master
15:24durka42what did i do the first time? i think i OOMed him
15:24blbrown'source' is less verbose
15:24blbrownhehe
15:24durka42clojurebot: source is http://github.com/hiredman/clojurebot/tree/master
15:24clojurebotIn Ordnung
15:28AWizzArdclojurebot: max people
15:28clojurebotmax people is 145
15:28AWizzArdwow
15:31niffclojurebot: commit suicide
15:31clojurebotHuh?
15:31niffclojurebot: do a forward loop
15:31clojurebotTitim gan �ir� ort.
15:34ayrnieuhum.
15:34ayrnieu,(java.util.Date. (long (* 1000 1234567890))) ;; <-- 12345678900000 is too large for a Java long. So what's happening, here?
15:34clojurebot#<Date Fri Feb 13 15:31:30 PST 2009>
15:35durka42,(class (long (* 1000 1234567890)))
15:35clojurebotjava.lang.Long
15:35durka42,(long (* 1000 1234567890))
15:35clojurebot1234567890000
15:35durka42,(java.lang.Long/MAX_VALUE)
15:35clojurebot9223372036854775807
15:35durka42not too large
15:36forestnot to long
15:36forest*not too long
15:36ayrnieulong x = 1234567890000; fails with fixn.java:3: integer number too large: 1234567890000
15:37forestlong x = 1234567890000L;
15:37forestto big for int ok for long
15:37forest*too
15:37ayrnieuok, sorry.
15:37durka42ayrnieu: that's why you use clojure :)
16:01blbrownhttp://paste.lisp.org/display/75073 I know it doesn't look pretty, but I was trying to use' ref in this way, but my values aren't being set. Anyone see something
16:03blbrownand really all I want to access a hashmap of objects from any function (globally). I guess in java, it would be. Class.field = new HashMap();
16:03Chousukeblbrown: yeah, it always returns a new ref
16:04Chousukeyou need to (def *mymap* (ref {}))
16:04Chousukemake a global definition
16:04blbrownhmm
16:05blbrownChousuke I thought calling 'findgrep-widg-state' would do that
16:05Chousukeit defines a new ref, which is then promptly discarded
16:05Chousukeyour set operation works; you just throw away the ref immediately afterwards :)
16:06blbrowndope
16:06Chousukealso, it's usually not useful to have have nil values in a map like that.
16:06Chousukesince trying to get a key that does not exist returns nil
16:07blbrownChousuke, so it should just be nil
16:08Chousukeso what you want is (def *widget-state* (ref {})); then get-state would be @*widget-state* and set would be (dosync (commute *widget-state* assoc fkey widg))
16:08Chousukeyou can also pass around the ref manually, but the global style is fine too
16:09Chousukeas long as it's really *state*, not just trying to emulate mutability becuase you don't want to think of a functional approach :)
16:10Chousukein that case it seems like it's correct to use a ref though.
16:13djpowellthe other day I mentioned that I was considering dealing a lazy-seq out to multiple seqs after wrapping the input seq in a seque, so that one thread doesn't lag behind of the others leading to unpredictable memory usage
16:14djpowelljust wondering if there are any liveness issues with using a seque like that
16:31Chouserdjpowell: you mean having multiple thread pulling from the same seque-generated seq?
16:35djpowellyeah
16:36djpowellwell, from separate seqs dealt out from a seque
16:37djpowellso if one thread raecs ahead, it will block putting new items in the seque
16:42djpowellif the fastest thread gets too far ahead of the slowest thread, then the fastest thread will block, because when it tries to pull a new element into the seque's queue it will block cause it has filled the seque's buffer, the other threads will carry on running.
16:42djpowellthat sounds ok.
16:44djpoweller i think. i'm confused
16:49djpowellno, that won't work will it. the blocking will only affect the producer
16:53djpowellperhaps i want something like: http://java.sun.com/javase/6/docs/api/java/util/concurrent/LinkedBlockingDeque.html
16:57Chouserno seque's block both sides.
16:57Chouserbut I'm not sure having multiple consumers will work
16:58Chouserif you call 'rest' on a seque before the producing thread is ready, you'll block.
16:58Chouserif the seque's internal queue is full, it won't call 'rest' on the producing seq until there's room.
17:00djpowellbtw - in case I didn't explain, the consumers read from seqs that were dealed out from the seque via: http://paste.lisp.org/display/74970
17:02Chouserah, so your consumer threads will skip appropriate amounts of the seque to get full coverage without the same item going to more than one thread
17:02Chouseryeah, that should work.
17:03Chouserbut it might be easier to use a LBQ directly
17:03djpowelli'll have to have a read of Java Concurrency In Practice - that book is good
17:04djpowellThe number of classes in java.util.concurrent is a bit overwhelming without it
17:04Chouserbecause then your consuming threads wouldn't have to be coordinated like that -- when each is done processing an item, it could just grab the next one from the LBQ without having to partition so specifically
17:06djpowellyeah
17:07djpowellnot sure what the difference between LinkedBlockingQueue and LinkedBlockingDeque is yet
17:08forestdo you know what is the difference between queue and deque
17:08stimuliis paste.lisp.org down ?
17:08stimuliI'm getting proxy errors
17:08forestme too
17:08stimulirats
17:08stimuliI was about to post something
17:08djpowellforest: no - i'll take a look
17:09hiredmanjcip mentions deques as useful when each consumer has a queue of input, and if it finishes, it can steal work off the back of another consumers queue
17:09foreststimuli: there is a lot of such services, we use http://rafb.net
17:09hiredmanthere is also gists
17:09hiredmangist
17:09stimuliforest: thanks
17:12djpowellthe consumer is based in java, so I think using LBQ directly makes sense
17:21djpowell0
17:21djpowelloops - the perils of using emacs for irc and a repl
17:24RaynesPeople actually use Emacs for IRC?
17:24Raynes:|
17:24gnuvince_Yes.
17:24Hunof course
17:24djpowellM-x erc is ok
17:24Hunwhat else?
17:25forestxchat
17:25HunM-x irc is nicer
17:25gnuvince_It actually has advantages over other clients.
17:25ayrnieuRaynes - I used to live in rcirc.
17:25foresti doubt it )
17:25ayrnieuOne big advantage is that you can edit what you say, and see all of it over multiple lines.
17:26ayrnieualso, it's a good example of the benefits of lisp. You can hack on your IRC client while you use it, fix bugs, add features.
17:26forestnot convincing at all )
17:27ayrnieuread Cat's Paws and Catapults, then :-)
17:27djpowelli use emacs for mail a bit too - on my laptop - it is the only imap client that i've seen that works like webmail
17:27forestxchat has perl and python integration
17:28RaynesI use XChat simply because I can't find a better client that I like. The only thing I /don't/ like about XChat is that for some reason it crashes on me if I click thinks too fast.
17:28hiredmanof course, the one true irc setup is screen+irssi
17:28Rayneshiredman: On windows Irssi is shit.
17:29RaynesIn my opinion,
17:29hiredmanRaynes: screen
17:29hiredmanssh -> unix
17:29RaynesWhat is screen?
17:29hiredmanwho runs windows anyway?
17:29hiredman:P
17:29hiredmanScreen is a full-screen window manager that multiplexes a physical terminal
17:29hiredmanbetween several processes (typically interactive shells).
17:30Rayneshiredman: I do. Because I don't have another option. I'd explain, but Lau_Of_DK might crack his whip for offtopic chat.
17:30forestthere is no user friendly alternative to xchat is far as i know
17:30AWizzArdWhile I am on Windows I use putty to connect to my box in which a screen runs irrsi.
17:30ayrnieuforest, http://github.com/ayrnieu/clj-actors/blob/1c062dc5dcde01e4774793840e5f149f7d5dbc37/examples/chat_server.clj starts a simple chat server and then drops into a repl. So you can add features to the server, fix bugs, add tracing, perform tricks (bypass the broadcast and send a message to only one person, or give one person extra commands), etc.
17:30Hundepends on the value of user. and friendly.
17:30Raynesforest: mIRC is userfriendly. But it's a horrible client.
17:31hiredmanso is xchat
17:31AWizzArdRaynes: you could use Putty to connect to your Linux box
17:31RaynesI don't have a linux box.
17:31forestRaynes: right now i am in mIRC, what is wrong with it
17:31AWizzArdthen mirc is probably your best bet :-)
17:32forestfor windows - mIRC is the best option )
17:32RaynesI don't get how anyone can recommend mIRC :|
17:32ayrnieuforest - so there's 'classical' development of edit->compile->run->crash->, and there's the 'dynamic' development cycle of edit->run->crash->, and there's a development style that few environments really provide: edit->run->(edit->edit->)
17:33forestayrnieu: right, but fixing an IRC client happens one or zero times in life
17:33gnuvince_IRCing from Emacs: auto-completion of more than just nicks, flyspell support, searching, extensibility with Elisp (possibly to give interactions with interpreters), etc.
17:33ayrnieuforest - you're thinking like a user. Pretend that you also program.
17:34forestmy brain just refuses to extend this philosophy to IRC client
17:35forestemacs just does not have enough space needed to draw every tab
17:36Hunwhy would you do that? sounds like a truly horrible idea
17:36gnuvince_tabs?
17:36forestfor each channel
17:36Hundon't try to summon the great old ones (that's M-x fhtagn for you)
17:37gnuvince_Emacs people don't use tabs.
17:37forestwhat do they use having 10 open irc channels
17:37gnuvince_plain old buffers
17:37Huni use events
17:37gnuvince_Emacs users use buffers
17:37ayrnieurcirc notes activity in the modeline.
17:37Huneverytime someone says something, the channel gets added to the active list
17:38Huni can switch to and from that with a single keystroke
17:38RaynesOMG HIS COMPUTER IS ALIVE
17:38forestbecause emacs does not have anything more to offer, it is good for text editing, but as i think something more is needed for IRC
17:39Hunwhat is irc /besides/ multiplayer text editing?
17:39RaynesHun: It is everything mankind has accomplished since coming into existence.
17:39ayrnieuforest, now you're talking about what an Emacs IRC client could possibly offer. Why don't you TIAS?
17:39forestscripting, user coloring)
17:40Hunis done by emacs. perfectly fine
17:40gnuvince_forest: like I said earlier, it offers auto-completion, it offers spell checking, it offers backward search, etc.
17:40ayrnieuyeah, Emacs buffers are much better than "/lastlog ... aw, crap, I'll just grep the logs."
17:40forestayrnieu: what's TIAS
17:40Hunayrnieu: try M-x occur :)
17:41ayrnieutry it and see
17:43blbrown(apply (fn [x y] (str x " " y)) ["1" "2" "3"]) I want to do a join in clojure, I am assuming this is wrong
17:43hiredmanuh
17:43ayrnieu,(apply str (interpose " " ["1" "2" "3"]))
17:43clojurebot"1 2 3"
17:44hiredmanyour fn there takes two args
17:44foresti don't use auto-completion and i feel fine about misspelling, i search in logs and it happens once a year, etc, so for me emacs just offeres lack of tabs and colors
17:44hiredmanand you applied it to a seq of three args
17:44hiredman*boom*
17:44hiredmanyay clojure!
17:44Hunforest: it has those. though tabs are still a bad idea
17:44blbrownhiredman: I programmed in broken imperative languages most my life, bad habits are hard to break
17:45ayrnieufor newlines: (apply str (interleave ["1" "2" "3"] (repeat \n)))
17:45ayrnieu...
17:45ayrnieufor newlines: (apply str (interleave ["1" "2" "3"] (repeat \newline)))
17:46ayrnieuoh, clojurebot did respond. Darned log.
18:13danlarkinI did not get enough sleep this weekend, I am having trouble reasoning about what I need this function to do :)
18:15forest,(.danlarkin sleep (* 1000 (* 8 (* 60 60))))
18:15clojurebotjava.lang.Exception: Unable to resolve symbol: sleep in this context
18:15forest,(. danlarkin sleep (* 1000 (* 8 (* 60 60))))
18:15clojurebotjava.lang.Exception: Unable to resolve symbol: danlarkin in this context
18:15forestno wonder, you just can't sleep
18:17danlarkinMmmmm 8 hours would be nice
18:18kotarak,(.sleep danlarkin (* 1000 8 60 60))
18:18clojurebotjava.lang.Exception: Unable to resolve symbol: danlarkin in this context
18:19kotarakYeah. Doesn't work.
18:19c|phello all
18:19c|pback from my trip
18:20c|pto those of you who were discussing with me about books, my parents surprised me with a common lisp book
18:20c|pgood enough for my purposes
18:22ayrnieuwhich book?
18:25c|p"lisp" by patrick henry winston, 3rd edition
18:26c|pits a bit old
18:26c|pbut i wanted a book more for exploring functional programming than anything else
18:26c|pso its just fine
18:27Hunc|p: that one is cool. especially the later xps chapters
18:29c|pyeah, im on chapter 16 or so
18:29c|pi slept a bit moer than i intended :)
18:37blbrownanother newb question coming
18:38blbrownhow do you append a value to a sequence
18:38durka42conj
18:38durka42well
18:38durka42conj appends to the end of vectors, prepends to the beginning of lists
18:39blbrownconjoine
18:40ayrnieu,(concat "h" "i")
18:40clojurebot(\h \i)
18:41forestso you have to be aware all the time what you are working with, is it a vector or a list
18:41forestnot very nice
18:43ayrnieuno, that doesn't follow.
18:43kotarakforest: you should be aware anyway, since lists and vectors have different performance characteristics...
18:44forestkotarak: appending an element, taking first and rest are almost the same
18:44durka42true, but one of the points of generic seq functions is so you can swap out lists for vectors if you discover that they would be faster
18:44durka42i agree with forest that it seems inconsistent
18:46foresti believe that language author said in a presentation that it is transparent to change datatype - he was lying a little
18:47durka42i mean, if you are using conj and pop to implement a stack
18:47durka42then you can switch data types transparently
18:47durka42because both of those switch
18:47durka42if you are using first and pop it will need tweaking
18:50forestusing conj and first seem to me very common operations
18:50forestas they come from older lisps
18:50lisppaste8jjkk pasted "slow prime-summing" at http://paste.lisp.org/display/75083
18:50ayrnieucons and first, rather.
18:51beepbeepimajeephttp://paste.lisp.org/display/75083
18:51beepbeepimajeepwhy is it taking so long?
18:52foresthow big is maxi
18:54ayrnieuclj defines those functions pretty quickly.
18:54beepbeepimajeepmaxi is sqrt of the nbr to be tested
18:55Chouserthat's a slow algorithm for finding primes. You could probably improve the run speed a bit with primitive number types, but it might not be sufficient improvement.
18:55forestok, how big is the nbr to be tested )
18:55beepbeepimajeepfrom 0 to 2000000
18:55beepbeepimajeepeach nbr
18:56beepbeepimajeep(prime? 2000000) is instant
18:56durka42well, it is basically the same algorithm as in the wiki, except for the even number part
18:56durka42unless i misread i
18:56durka42t
18:57Chouserhm, indeed
18:57forestone good improvement would be checking to all numbers up to sqrt(p) but only already found primes <= sqrt(p)
18:57Chouserhow long is "so long"?
18:57forestto all = not all
18:59hiredmanclojurebot: Sieve?
18:59clojurebotPardon?
19:00hiredmanclojurebot: Seive?
19:00clojurebotGabh mo leithsc�al?
19:00foresthttp://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
19:02Chouseryour prime? is testing at least twice as many numbers as the wiki version, since it's counting up by 2 instead of 1
19:02hiredmanclojurebot: google genuine seive
19:02clojurebotFirst, out of 1190 results is:
19:02clojurebotWikiAnswers - Name of the tissue that cotains seive tubes
19:02clojurebothttp://wiki.answers.com/Q/Name_of_the_tissue_that_cotains_seive_tubes
19:02hiredmangah
19:03hiredmanuseless
19:03forestChouser: doesn't it make it test twice LESS numbers
19:04gnuvince_,(let [x [1 2 3], f (fn [y] (identical? x y))] (f x))
19:04clojurebottrue
19:06Chouserforest: I messed up my English. With wiki version uses (+ i 2) instead of (inc n)
19:07forestanyway it will find divisor 2 immediately
19:07forestfor even numbers
19:08foresti don't think it influences much on runtime
19:08durka42the wiki vewrsion doesn't say anything about how long it takes
19:09forestit must be pretty long
19:10forestsieve of eratosthenes is fast
19:24Hundepends on the range of numbers you use it on
19:25Hunand on your test. using it naively on bignums is /slow/
19:25forestwhere do bignums come from ? 2 000 000 fits in int fine
19:26Chousukeit's by default a boxed integer
19:26Chousukewhich is still a lot slower than primitive math
19:26forestbut still it is not bignum
19:27ChousukeI'm assuming Hun meant boxed integers
19:27forestby bignums, you have a vivid imagination)
19:30ChousukeThough even my crystal ball sometimes fails :/
19:34xooxHow do I find out where in my clojure code an exception is being raised? Trying to do (.printStackTrace *e) in slime returns nil. The exception is "Wrong number of args passed to: LazilyPersistentVector". The backtrace provided by slime is unhelpful.
19:37ayrnieu,([])
19:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector
19:37ayrnieu,([] 1 2)
19:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentVector
19:37ayrnieu,([] 1)
19:37clojurebotjava.lang.IndexOutOfBoundsException
19:37hiredman,(vec 1 2 3)
19:37clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$vec
19:38xooxI understand but how do I find out where it is occuring?
19:38xooxIs there no backtrace for clojure code?
19:39ayrnieuthere's the backtrace that you've already found unhelpful, if that's the same that (.printStackTrace *e) would give you
19:39ayrnieuyou can find clj-backtrace on github, which tries to give better backtraces
19:40xooxayrnieu: Are the backtraces supposed to reference clojure code?
19:42ayrnieuat clojure.core$inc__3264.invoke(core.clj:685)
19:43ayrnieuand as this error rises from (send ag inc), you can also see clojure.lang.Agent$Action.doRun(Agent.java:69)
19:43ayrnieu,(doto (agent nil) (send inc) (await) (-> agent-errors first (.printStackTrace)))
19:43clojurebotjava.lang.RuntimeException: Agent has errors
19:43ayrnieu,(doto (agent nil) (send inc) (await) (-> agent-errors first (.printStackTrace)))
19:43clojurebotAgent has errors
19:43ayrnieuthere's a nasty race condition in that code.
19:44durka42shouldn't the await prevent it
19:44xooxIs anyone working on instrumentation of clojure code for the purposes of debugging?
19:44ayrnieudurka42 - await is what's throwing the exception
19:44durka42oh
19:45forestxoox: why, http://clojure.org/getting_started#toc5
19:47xooxforest: Does that provide anything like the slime debugger?
19:47skogswhy does condp throws an exception instead of returning nil on no matches
19:48ayrnieuskogs - it's useful.
19:49teHello all
19:49tedoes someone have the concourse.tar.gz link
19:49teit should be within the last 12 hours
19:49temaybe some one has it in their buffer?
19:49skogsit could be, but seems odd compared to cond and other control structures
19:49ayrnieu Lau_of_DK> te: http://p.hagelb.org/concourse.tar.gz
19:49forestxoox: not sure
19:49tethanks
19:50forestthere are some pictures http://bc.tech.coop/blog/081023.html
19:50xoox(xml1-> foo-dom zf/descendants :table
19:50xoox #(when (re-find #"sortable_table_id_0" (attr % :id))
19:50xoox (node %)))
19:51xooxsorry, wrong buffer
19:51teIs it useful to think of clojure as "divide and conquer"? Sort of a: build this module, build that module, pass both modules to this module, which completes the calculation?
19:51forestan example why i don't like emacs as IRC client
19:52c|pemacs has an irc client?
19:52c|pwell, not all surprising
19:52c|pemacs has everything
19:52durka42heck emacs has a web browser
19:52tec|p: it's pretty neat tbh
19:52c|pheh
19:52teim new to emacs
19:52Chousukeno, it's not emacs as an irc client!
19:52tebut i think the split windows and such is really cool
19:52c|pmakes me think of like
19:52forestit was quite a discussion a little earlier
19:52c|p"what os do you use?"
19:52c|p"emacs"
19:52Chousukethat's like saying "java as an irc client"
19:52teits kind of like screen + ncurses environment
19:52drewrI'm using ERC Version 5.2 with GNU Emacs 22.3.2 (i386-apple-darwin9.5.0, Mac Carbon) of 2008-11-29.
19:53tedoes Java have curses libraries?
19:53teI would assume so...
19:53ayrnieute - yes.
19:53c|pthere is one that i know of
19:53forestis it unix only ?
19:53tei googled and got my answer
19:53ayrnieuit's a curses library. It's curses only.
19:53tencurses?
19:55ayrnieuhttp://www.nongnu.org/jcurzez/doc.html also supports windows
19:55durka42console gui widgets library
19:56foresttested on win9X ))
19:56foresti would not call it windows support
20:12teI hope I'm not offending the author if he's in here
20:12tebut I am not really enjoying "Programming Clojure" thus far
20:12teit's a beta, so things may well change
20:12forestis it a book ?
20:12tebut i think it is kind of a harsh introduction
20:12teyes
20:12tepragprog.com
20:14teTechnomancy isn't here is he?
20:14ted'oh
20:14teI need his .emacs configuration -- I don't remember how to do this
20:32teException in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner
20:32tegrrrrr
20:33tenevermind found it -- absollute path i think will fix the config
20:33teabsolute*
20:34tels
20:38xoox(xml1-> (xml-zip (xml/parse url startparse-tagsoup) zf/descendants :img))
20:38xooxWhy do I get OutOfMemory? ^
20:41skogson an IllegalArgumentException, how do i identify where its coming from
20:41mofmogSo I can get an apache server
20:42mofmogshould i ask for tomcat or jetty? I know people prefer jetty w/ clojure but tomcat seems likeless hassle
20:42skogsthere r multiple functions that throw this exception, but i only want to catch my high level one
20:50hiredmanskogs: all functions throw that Exception if you pass them the incorrecct number of args
20:51skogstough luck i guess
20:57skogswhat's the recommended way of writing tests in clojure
20:58skogsi'd like to keep the tests near the code itself
20:58durka42(doc test)
20:58clojurebottest [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception; arglists ([v])
20:59durka42you can put a test in the metadata of a function
20:59durka42at the key :test
21:00skogshow do i execute the test then/
21:01stimulihi
21:02durka42(defn #^{:test #(= 2 (plus 1 1))} plus [a b] (+ a b))
21:02durka42(test #'plus)
21:03durka42hmm, that test is wrong, it has to throw an exception if not satisfied
21:03skogscool, thats a good test then
21:04skogsbtw why cant u just call (test plus)
21:05durka42wrap the test in an assert to fix it, #(assert (= 2 (plus 1 1)))
21:05durka42because you need the var
21:05durka42^plus is nil
21:05durka42^#'plus has the :test key
21:05durka42symbols don't have metadata, vars do
21:06skogsoh
21:06durka42(defmacro test-fn [f] `(test #'~f))
21:07skogsthats neat
21:08skogsi heard about test-is
21:08skogsany comments on its utility?
21:08stimuliit works as well as any other unit test framework
21:08durka42not from me, haven't used it
21:08durka42probably works better than straight clojure.core/test as described above
21:09Chouserxoox: parens in the wrong place?
21:09Chouserxoox: (xml1-> (xml-zip (xml/parse url startparse-tagsoup)) zf/descendants :img)
21:15skogsdurka42: thanks for ur help
21:17defnso what is performance really compared to say, perl, ruby?
21:17defnive read all sorts of dissenting opinion
21:18ayrnieuyou read people who said that their Clojure program ran slower than their similar Ruby program?
21:18defnno definitely not
21:18defnim just curious if there it is faster by a factor of N, etc.
21:19ChouserClojure and JVM startup time hurt pretty bad.
21:19ayrnieuwhich knocks you out of using clojure for trivial things. Oh well :-/
21:19defnso compared to say, C++? what does that comparison look like?
21:19durka42could use nail
21:19durka42nailgun*
21:20Chouseronce running, the JVM is dramatically faster than the runtime engines of perl, python, and ruby.
21:20defnChouser: i assumed as much i supposed
21:21Chouserany particular library functionality may be faster in one language than another. I've heard complaints about Java's large number speed compared to python, though I've not run any tests myself.
21:24Chouserayrnieu: depends on how trivial. On my computer, clojure startup costs perhaps a second. Interactively at the shell prompt, that's usually not a deal breaker.
21:24defnwhat is a deref? eg @form => (deref form)
21:25defnwhy would that be useful?
21:25durka42get the value out of a ref/atom/agent
21:25ayrnieudefn - you'll use it with STM and concurrency.
21:26defnhm, durka42 what are those?
21:26durka42what ayrnieu said
21:26durka42i recommend reading the relevant sections on clojure.org for starters
21:26defnyeah im reading it right now
21:27defnits weird that the second link after getting started is "The Reader", which makes reference to many obscure ideas that I've never been introduced to before
21:27ayrnieuProgramming Clojure also helps, and reading clojure.org more carefully a second time helps, and so does slamming into walls doing things that are very simple in anticipation and in retrospect, but not while they aren't working :-(
21:27defnhaha true
21:28defnayrnieu: I bought programming clojure, but it's not finished yet and it seems kind of well, disjointed
21:28blbrownChouser they say a lot of that startup performance hit is because of the loading of the core Java libraries, in terms of the quantity and since all the boostrap libraries are archived files. Wonder if someone would fork the jdk to resolve this issue
21:28defnnot very linear anyway
21:29Chouserdefn: what languages have you used previously?
21:29defnRuby, C++
21:29defnI know there are many similarities to Ruby, or at least, more than C++
21:29defnI guess I just am getting hung up on the idea of functional programming
21:30Chouseryes, clojure and ruby are both dynamic and have some high-order functions.
21:30ChouserC++ is neither. :-)
21:30defnwhat i dont understand is the order in which things are mixed together
21:31Chouserwhen Clojure is evaluating a line of code?
21:31defnyes
21:31blbrowndefn if you want, you can keep a lot of the imperative style programming as you do in Ruby/C++. even though it is not advised. The syntax is going to be different E.g parens but you can code almost line for line like you would in ruby.
21:31defni need a flow chart to show me what is happening behind the scenes
21:31blbrowndefn actually, you can code line for line like you would in java, just different syntax
21:31defnbecause i feel like there is some magic happening im unaware of
21:31Chouserdefn: with the exception of macros, clojure expressions are evaluated from the inside out, args left to right, just like in Ruby.
21:32defni think the parens that span multiple lines and encompass other things are making my head spin a bit
21:32defni might be making this too hard
21:33durka42it's just that pretty much anything can be nested inside anything else
21:34defnhow do i pass a function as an argument? lets say I want to make some module that filters a list of integers and outputs integers with a remainder of 0
21:34defnand then i have a list that keeps on making random numbers
21:34defnerr a fn that makes random numbers
21:35defnhow could i tell my filter to start outputting the results of the data ive generated
21:35defn(after this ill leave you alone for a bit, but this would be helpful if you could explain nit)
21:35blbrownyou might ask one question at a time, maybe a little easier for others to help
21:36defnyeah im sorry, just anxious
21:36Chouseranytime you use a functions name that's not at the head of a list, you'll get its value
21:36Chouser,(prn +)
21:36clojurebot#<core$_PLUS___3183 clojure.core$_PLUS___3183@1afd9cc>
21:36ayrnieu,(filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(rand-int 10))))
21:36clojurebot(9 9 9 0 0 0 3 6 9 0 6 0 0 0 6 9 0 3 6 3 3 0 0 6 0 9 9 9 9 9 6 0 3 3 0 9 0 3 9 0 0 9)
21:36Chouserthere 'prn' is at the head of a list, so it gets called with + as a parameter.
21:39defncould you explain what you mean by that?
21:39Chouserwho, me?
21:39defnyes, please
21:39Chouserprn is function and + is a function
21:40defnhow is prn at the head of a list, it seems like its off on its own
21:40defnerr d'oh
21:40defnim sorry i see
21:40Chouser:-) no problem. Code is data can be a little surprising at first.
21:40defnim just trying to understand the effect of it on the 2nd line you posted
21:41defnoh god, im terrible, that was ayrnieu
21:41durka42read it inside-out, starting at rand-int
21:41Chouseryeah, ayrnieu's using a couple convenience macros there that may obscure a bit what's really going on.
21:41Chouserhe solved your whole problem in a single line.
21:41defnyeah the -> threw me
21:42blbrowndefn, do you understand the prefix notation?
21:42ayrnieu,(filter (fn [n] (zero? (rem n 3))) (take 100 (repeatedly (fn [] (rand-int 20)))))
21:42clojurebot(6 15 15 9 3 15 12 12 15 18 9 12 18 18 18 9 12 15 15 6 3 0 15 6 15 6 9 18 18 9)
21:42defnblbrown: yes i believe so
21:44defnso repeatedly takes a function rand-int 10, and returns an infinite sequence of calls to it
21:44defntake 100 limits it
21:44ayrnieuright.
21:45defnthen you define an anonymous function with an argument n that checks if its zero, if yes, it gets the remainder of n and 3
21:45durka42it checks whether the remainder of n/3 is zero
21:45ayrnieuno. What argument does zero? have?
21:45defnzero has (rem n 3) as an arg
21:46ayrnieuzero?'s just a function, so (rem n 3) must be evaluated before zero? can see if it's equal to zero.
21:46ayrnieu,(rem 6 3)
21:46clojurebot0
21:46ayrnieu,(rem 7 3)
21:46clojurebot1
21:46defnso for every element in the sequence we check to see if the remainder of n and 3 is 0, if zero? is true
21:47defnthen we output it
21:47ayrnieuwell, filter returns a lazy list of numbers divisible by three, drawn from the first hundred elements of an infinite sequence :_)
21:47defnhaha
21:48ayrnieu,(let [cnt (ref 0)] (filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(do (dosync (alter cnt inc)) (rand-int 20))))))
21:48clojurebot(15 18 6 6 9 9 18 3 3 15 6 12 12 18 15 3 6 6 3 12 18 0 0 3 12 15 12 12 9 18 15 0 6 18 9 12 15)
21:49defnokay let me think here
21:49defn:)
21:49ayrnieu,(let [cnt (ref 0) lst (filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(do (dosync (alter cnt inc)) (rand-int 20)))))] [@cnt lst])
21:49clojurebot[2 (0 6 0 9 0 18 12 12 9 15 0 3 3 0 9 3 0 12 15 18 18 12 0 9 3 12 0 12 15 18 9 9)]
21:49ayrnieu... that doesn't seem right :-/
21:49defnoof that is tough
21:49durka42erm... that didn't work so well did it
21:49defnis that the concurrent version?
21:50ayrnieuthat sets cnt to (ref 0), to keep a count of the times that the function given to repeatedly is called.
21:50defnyou use cnt (ref 0) to keep track of state
21:51ayrnieu,(let [cnt (agent 0) lst (filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(do (send cnt inc) (rand-int 20)))))] (await cnt) [@cnt lst])
21:51clojurebot[1 (9 0 18 18 6 0 15 12 0 0 9 6 12 6 0 12 6 12 18 15 18 6 0 6 15 9 0 15 9 3 9 18 18 6 0 15 18 6 6)]
21:51defnayrnieu: what is that -> stuff?
21:51defnit looks familiar, from squeak maybe? limbo?
21:51ayrnieu(-> x expr1 expr2 expr3) becomes (expr3 (expr2 (expr1 x)))
21:52durka42ayrnieu: throw a doall around the list
21:52defnahhh
21:52ayrnieudurka - I want to see how many times it's really called, though, not force 100 calls
21:52ayrnieudefn - likewise, (-> x expr1 (expr2 y)) becomes (expr2 (expr1 x) y)
21:53defnthis is awesome.. i feel a lot better just having someone hold my hand for a minute -- with 0 lisp experience im always very unsure of what im doing with clojure
21:53ayrnieu...
21:54ayrnieu,(let [cnt (agent 0) lst (filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(do (send cnt inc) (rand-int 20)))))] (doall lst) (await cnt) [@cnt lst])
21:54clojurebot[100 (9 6 18 3 12 3 12 0 9 0 3 9 12 3 0 0 9 12 9 9 12 0 6 3 6 18 0 15 9 6 12 6 15 0 3 9 9 6 18 15 0 3 12)]
21:54ayrnieu,(let [cnt (agent 0) lst (filter #(-> % (rem 3) zero?) (take 100 (repeatedly #(do (send cnt inc) (rand-int 20)))))] (await cnt) [lst @cnt])
21:54clojurebot[(6 6 12 15 18 6 6 9 6 9 12 18 15 3 18 15 9 12 0 18 0 12 15 9 9 18 3 0 3 9 9 12 3 9 15 3 0 9 12 12 18 6 18 6) 1]
21:54blbrownshow off
21:55ayrnieuhey, I was confused.
21:56durka42ayrnieu: i think the transactions are being run after stuff is printed
21:56lisppaste8durka42 pasted "untitled" at http://paste.lisp.org/display/75093
21:57defnhow does #() work in these cases?
21:57Chouserright, filter etc. are lazy, and aren't forced until printed.
21:57ayrnieu#(...) becose (fn [] ...); #(... % ...) becomes (fn [x] ... x ...), and so on.
21:58ayrnieus/becose/becomes/.
21:58Chouserayrnieu: almost. #(foo) becomes (fn [] (foo))
21:58Chousernot the inner parens on the output form
21:58Chouser*note
21:58defnoh, so #(foo) is just short-hand for an anonymous definition
21:59durka42ya
21:59c|p#() is sugar for lambda etc
21:59defnah okay
21:59ayrnieu,(#(do %2) 1 2)
21:59clojurebot2
21:59ayrnieu,(#(do %3 %2) 1 2)
21:59clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: sandbox$eval--1062$fn
22:28blbrownCan I not do this to set a value defined by 'ref' (defn set-directory-open [path] (dosync (commute (set! *directory-open-state* path))))
22:28blbrownwhere *dir....open* is a string
22:29Chouserno, you can't.
22:29Chousertry 'ref-set'?
22:29Chouser(doc ref-set)
22:29clojurebotMust be called in a transaction. Sets the value of ref. Returns val.; arglists ([ref val])
22:29blbrowndope
22:30blbrownChouser, would I need the 'commute' then?
22:31ayrnieu(dosync (commute *directory-open-state* #(do % path)))
22:31ayrnieu(dosync (commute *d-o-s* ref-set path))
22:31blbrownhehe, don't like my long name
22:31durka42isn't ref-set inside commute redundant?
22:32ayrnieuoh, you can just (dosync (ref-set *d-o-s* path))
22:32ayrnieuit needn't be.
22:32ayrnieuactually, if it weren't, it would be useful for (send ag ref-set new-value)
22:32blbrownand for my own edification, we use 'ref' and sometimes 'agent' for setting 'global' values
22:33durka42ayrnieu: that doesn't make sense, an agent is not a ref
22:33ayrnieudurka - it doesn't make sense because commute is redundant, do you see?
22:33durka42i suppose so
22:33durka42(send ag #(do new-value))
22:33ayrnieu#(do % new-value)
22:34c|pis there a method that returns the classpath?
22:34ayrnieu#(do %2) new-value
22:34durka42yes, that
22:34c|pwait
22:34c|pyes there is
22:34c|plol
22:34durka42(System/getProperty "java.class.path")
22:34durka42,(System/getProperty "java.class.path")
22:34clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission java.class.path read)
22:34c|pye
22:35ayrnieublbrown, ref access provides STM. Atom access provides dumb spinlocking. Agents... are interesting.
22:37blbrownayrnieu, do you think there is any future for adding a distributed actor model kind of like erlang?
22:37ayrnieublbrown - http://github.com/ayrnieu/clj-actors/tree/master , but that doesn't address distribution.
22:40ayrnieublbrown - I think distribution is possible.
22:42danlarkinthere's so much cool work happening in clojure, it's hard to keep up with it all :)
22:45blbrowndanlarkin, is this you? http://twitter.com/danlarkin
22:45danlarkinone and the same
22:46danlarkinalthough that is not me in the picture
22:46danlarkinI just think it's hilarious
22:47blbrownthis is me in the picture. http://twitter.com/berlinbrown if you follow, ignore the stories of drunken debauchery
22:49danlarkinheh, will do
22:51ChouserThis is not me, and has nothing to do with me: http://twitter.com/chouser
22:51blbrownmy function names are ridiculously long
22:53danlarkinoh Chouser you should petition twitter to give you @chouser, I'd follow you!
22:54gnuvince_Has anyone ever noticed that as your program becomes more correct, it becomes slower also?
22:55danlarkingnuvince_: yeah what the hell right?
22:56gnuvince_danlarkin: yeah :) When I dumped all the actions of a Starcraft replay into one vector, analyzing 1000 replays tooks 3 minutes 40 seconds. Now that I separate actions by player, it takes move than five minutes.
22:56gnuvince_*took
22:57blbrowngnuvince, what in the world are you doing...woooa
22:57gnuvince_blbrown: http://github.com/gnuvince/clj-starcraft/tree/master
22:58danlarkinoh, do you live in hungary, gnuvince_?
22:59danlarkinoh, nevermind, I see what it is
22:59blbrownthis is my clojure tool, but will probably be used by the company first. Maybe I can release it later to the public. http://img17.imageshack.us/img17/3748/screenshotoctanetextvierk1.png
22:59gnuvince_danlarkin: Canada. I'm using the lib of someone else to unpack the replays.
23:02danlarkingnuvince_: yes, my mistake
23:02gnuvince_danlarkin: no problem.
23:03blbrowngnuvince, what can you do with them after they are unpacked
23:03gnuvince_Anyway, I'm trying to trim down the processing time of a single replay as much as I can (without compromising correctness), because some guys have collections of thousands of replays.
23:04gnuvince_blbrown: Once they're unpacked, it's a binary format that I decode and it gives you a complete history of what happened during a game. Every action is recorded with a time stamp and a player id.
23:04gnuvince_So it's possible to know how many actions per minutes a player was doing (good players keep in the 300 apm range), what units were produced, etc.
23:16hiredmanwhen I visit my parents in korea I watch the pro starcraft players on tv
23:16hiredmancrazy
23:19gnuvince_durka42: it is.
23:19gnuvince_Very popular in South Korea.
23:19hiredmanthey have their own tv channel fror starcraft and counter-strike
23:19gnuvince_There are English commentaries of the pro games
23:19gnuvince_http://www.youtube.com/profile?gl=CA&amp;hl=en&amp;user=VioleTAK&amp;view=videos
23:19hiredmanthey wear jumpsuits
23:19gnuvince_hiredman: they used to :)
23:19hiredman(the contestants)
23:19gnuvince_They've now reverted to sports jackets.
23:20durka42hey, if you can manage to get paid for it... :p
23:20gnuvince_http://www.mymym.com/gfx/bisu_skt1.jpg
23:20gnuvince_They look more like this.
23:20gnuvince_Anyway, I'm a pretty big fan of the korean pro scene.
23:21blbrownis starcraft mostly a mix of strategy or 'physical speed'. When I play, I am too slow to do anything
23:21hiredmanI bought my copy of sc in korea many years ago
23:21blbrowntalking about starcraft, I wonder if I can play it on wine
23:21hiredmanblbrown: I am pretty sure it is one of the main use cases
23:22ayrnieublbrown, I played SC on wine on a P133 -- obviously a long time ago.
23:22gnuvince_blbrown: speed plays a big part, because players need to attend to many tasks at once, but it is not impossible for slower players to dominate faster players if their game sense is more finely honed.
23:23hiredmanI think someone was porting SC to C# on mono
23:23blbrowninteresting. I bought the boxed version a couple of months ago, I might install it right now
23:23gnuvince_blbrown: http://www.youtube.com/watch?v=PPP8aSi1PeM
23:24gnuvince_This is a first person video from a pro gamer
23:24gnuvince_You'll see he's *very* fast
23:25c|pis there a sort-of #' equivalent for java functions
23:25ayrnieu,(map #(.getName %) (.getMethods String))
23:25clojurebot("hashCode" "compareTo" "compareTo" "indexOf" "indexOf" "indexOf" "indexOf" "equals" "toString" "length" "isEmpty" "charAt" "codePointAt" "codePointBefore" "codePointCount" "offsetByCodePoints" "getChars" "getBytes" "getBytes" "getBytes" "getBytes" "contentEquals" "contentEquals" "equalsIgnoreCase" "compareToIgnoreCase" "regionMatches" "regionMatches" "startsWith" "startsWith" "endsWith" "lastIndexOf" "lastIndexOf" "lastI
23:25hiredmanc|p: there are no functions in java, just methods :P
23:26c|pwell, i hope what i meant was implied :)
23:26ayrnieu,(let [f #(System/getProperties)] (f))
23:26clojurebotjava.security.AccessControlException: access denied (java.util.PropertyPermission * read,write)
23:26gnuvince_c|p: memfn maybe?
23:26durka42(doc memfn)
23:26clojurebotExpands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn.; arglists ([name & args])
23:26gnuvince_,((memfn .valueOf) 3)
23:26clojurebotjava.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Malformed member expression, expecting (.member target ...)
23:26gnuvince_,((memfn toString) 3)
23:26clojurebot"3"
23:26c|pi see
23:27c|pthat will work
23:27gnuvince_,(macroexpand-1 '(memfn toString))
23:27clojurebot(clojure.core/fn [target__4019__auto__] (. target__4019__auto__ (toString)))
23:35blbrownhiredman, this is awesome, I am about to install now
23:35hiredmanhmmm
23:36blbrownmy appreciation for linux just went up
23:36hiredmanactually I just tried and wine died
23:37blbrownhiredman, I am on Ubuntu , put in the CD and then navigated to the dos devices in Wine and launched setup.exe