#clojure logs

2010-07-16

00:43BahmanHi all!
02:11bortrebHow do I upload all the jars that I've hand-pick for my project to clojars, all under by group id?
02:27bortrebwhat happens if you screw up uploading something to clojars? can you remove it?
02:28chouserI think you can send email to ask that it be removed. :-/
02:30robtphey - does anyone care to critique this for style and idiomatic usage? http://gist.github.com/478019
02:31robtpthat's the prisoner-lightbulb problem
02:31robtpand other than the fact that storing turned-off and turned-on is redundant
02:32bortrebI wouldn't put (main) in the file itself because that will trigger it when it is 'used'
02:32robtpand then, another question - is there a readymade function to count the number of elements of a collection passing some test?
02:33robtpcount-passes(coll, #(> % 5)) ; for [5, 7, 2, 9, -1] => 2
02:34bortrebyou could always combine count and filter
02:36bortreb(defn count-passes [pred? coll] (count (filter pred? coll)))
02:48cais2002,((fn count-passes [pred? coll] (reduce #(+ %1 (if (pred? %2) 1 0)) 0 coll)) #(> % 5) [5 7 2 9 -1])
02:48clojurebot2
02:53robtpahh, nice
02:54chouser,((fn count-passes [pred? coll] (count (filter pred? coll))) #(> % 5) [5 7 2 9 -1])
02:54clojurebot2
02:54chouserbortreb's is nice
02:55cais2002will filter create another copy of coll ?
02:57chouserit will lazily walk coll as count forces it to
02:57chouserso no, there will not be a full copy of coll alive in memory
03:00cais2002i mean a filtered copy of coll being created?
03:07bortrebIs it possible to delete stuff from clojars if you make a mistake?
03:21robtpin my test case, the reduce method works many times faster
03:21robtp~5-6x
03:21clojurebotNo entiendo
03:21robtp ~5-6x
03:24cais2002robtp: that's what i expect, as it avoids creating a filtered coll
03:41bortrebOn my machine my version is about 20% faster
03:41bortreb,(time (dotimes [_ 30] (+))
03:41clojurebotEOF while reading
03:41bortreb,(time (dotimes [_ 30] (+)))
03:41clojurebot"Elapsed time: 1.155 msecs"
03:45bortreb,(time (dotimes [_ 50] ((fn count-passes-reduce [pred? coll] (reduce #(+ %1 (if (pred? %2) 1 0)) 0 coll)) even? (range 100))))
03:45clojurebot"Elapsed time: 26.85 msecs"
03:45bortreb,(time (dotimes [_ 50] ((fn count-passes [pred? coll] (count (filter pred? coll))) even? (range 100))))
03:45clojurebot"Elapsed time: 7.049 msecs"
03:51kuwabaraI can't seem to compile a class, not even the example from the doc. It says: "Could not locate clojure/examples/hello__init.class or clojure/examples/hello.clj on classpath", although the source is in clojure/examples/hello.clj.
03:51kuwabaraHow do I add "." into the classpath ?
03:56bortrebfirst off, you can literally type "." in the -cp argument to java
03:56bortrebyou also have to have the ./classes directory on the classpath to compile files
03:57bortrebare you using emacs and connecting via slime?
04:01kuwabarabortreb: no, I'm simply at the repl.
04:02kuwabaraI added "." in the cp when running clojure, but I get the same error.
04:03kuwabaraecho "(compile 'clojure.examples.hello)" | java -cp /usr/share/java/clojure.jar:. clojure.main
04:05kuwabaraOops. I renamed clojure/examples/hello to clojure/examples/hello.clj and there is no more FileNotFoundException.
04:05bortrebthat's great
04:05kuwabarabut still java.io.IOException: No such file or directory (hello.clj:1)
04:06kuwabaraLine 1 of hello.clj is: (ns clojure.examples.hello (:gen-class))
04:08esjMorning all.
04:08bortrebyou may try a more complete (:gen-class)
04:08kuwabaraFound it. -cp /usr/share/java/clojure.jar:./classes:. works.
04:08bortreblike
04:08bortreb(:gen-class
04:08bortreb :name rlm.push
04:08bortreb :main true)
04:09bortrebwhat did you change?
04:10kuwabaraI added ./classes
04:10kuwabarawhich seems to be the hardcoded destination of compiled files, but it's not added to the cp by clojure
04:11bortrebyeah
04:11bortrebyou can change *compile-path* to get a different destination
05:27cais2002what's the best way to do this in clojure: opts=[]; if (condA) opts+=[valA]; if (condB) opts+=[valB]; if (condC) opts+=[valC]; return opts;
05:37esjcais2002: dunno if its the best, but a seq comprehension might help
05:38esjsomething like
05:38esj,(apply + (for [c '([1 1] [0 2] [nil 3]) :while (first c)] (second c)))
05:38clojurebot3
05:38esjwhere the first elementi in each pair is your condition, and the second the value
05:38boojumcals2002: (let [opts []] (cond condA (conj opts "valA") condB (conj opts "valV) ..)
05:39esjor leave out the apply + if you want it as a seq of the values
05:39mjulboojum: we need to reduce over the list - evaluation stops on the first true in cond
05:40boojummjul: true
05:41mjulcals2002: are you trying to append to the list for each true condition or just get the sum of the vals for which the corresponding condition is true?
05:41cais2002esj: I end up using reduce again, but similar to ur approach
05:41esjcais2002: reduce is awesome
05:41cais2002mjul: append.. but I want to know the general way to do it
05:41esjcons ?
05:42esjconj if you're using vectors, say.
05:42cais2002I mean the python way I mentioned above is intuitive to me.. but the clojure versions are not that obvious
05:43esj,(into [] (for [c '([1 1] [0 2] [nil 3]) :while (first c)] (second c)))
05:43clojurebot[1 2]
05:46mjulejs: sweet :-) using for is so much more readable than reduce
05:46esjmjul: especially for pythonistas
05:48cais2002esj: talking about this, could explain why the reduce version is not faster?
05:48cais2002,(time (dotimes [_ 50] ((fn count-passes-reduce [pred? coll] (reduce #(+ %1 (if (pred? %2) 1 0)) 0 coll)) even? (range 10000))))
05:48clojurebot"Elapsed time: 580.593 msecs"
05:48cais2002,(time (dotimes [_ 50] ((fn count-passes [pred? coll] (count (filter pred? coll))) even? (range 10000))))
05:49clojurebot"Elapsed time: 529.725 msecs"
05:50esjcais2002: i'm afraid i can't, except to speculate that the provided higher order functions are likely to be better written than what you or I could do.
05:51cais2002I thought filter would create another list, while reduce does not..
05:51bortrebdon't forget about derefrenceng
05:51bortreb,(into [] (for [[cond? value] [ [ true 1] [true 2] [false 3 ] [true 4]] :when cond?] value ))
05:51clojurebot[1 2 4]
05:53Chousukecais2002: creating a new list isn't necessarily very expensive at all
05:54Chousukecais2002: the clojure core functions make use of a whole bunch of tricks that improve performance, so doing things in a way that "seems" more efficient is not guaranteed to be so.
05:55cais2002Chousuke: if the elements are not simple structure, will that make a difference?
05:57Chousukewhat do you mean by simple structure?
05:58Chousukecais2002: rhickey just has put a lot of effort into making map/filter/for/into etc. really fast so that you don't need to write contrived code to get performance.
06:00Chousuke~def reduce
06:00Chousukereduce is fast too though
06:00cais2002Chousuke: I am just wondering whether it's only to create the pointers to point to the objects or it's replicating the objects/elements.. simple refers to (range 10000), it's all integers in the list
06:01Chousukein java you only have pointers.
06:01Chousukeexcept if you have primitives
06:01Chousukes/java/JVM/
06:02Chousukeand the integers created by range are objects too
06:03Chousukesince you can't have a list of primitives.
06:04ChousukeBut then JVM optimisations will kick in and all those object allocations will suddenly be virtually free, in the best case :P
06:04bortrebheh the jVm makes stuff "virtually" free :)
06:05Chousukeheh, no pun intended :P
06:08cais2002,(into [] (concat [1 2] [3 4]))
06:08clojurebot[1 2 3 4]
06:08cais2002,(vec (concat [1 2] [3 4]))
06:08clojurebot[1 2 3 4]
06:09cais2002thanks, guys, my code looks a bit easier to understand now..
06:24cais200288 guys
06:37mjulLauJensen: hej! the Docjure lib for spreadsheet import/export is now open source: http://github.com/ative/docjure
06:46zmilamjul, it can read/write xlsx? so based on latest version of POI
06:46zmilaour project uses old version, only for xls (2003) files
06:46LauJensenmjul: Great! Did you used a hacked version of Lein for that? :)
06:48zmilamaybe the project was created before the -jure commit :)
06:52mjulit was created before the -jure commit :-) (it has been underway since 2009)
06:53mjul- and it reads/writes xlsx, too
07:30powr-tocHey... is anyone using cljr http://github.com/liebke/cljr
07:31powr-tocIt looks to be a pretty awesome complement for lein, for the times when you don't want a project, and just want a quick repl for experimenting with libs etc...
07:32powr-tocI was wondering though, if anyone knows whether you can get it to work with a .user.clj file
08:08jowagis it possible to dump the current environment?
08:13zmilaright question is half of the answer. what is enviroment?
08:17Kttmmwe found the solution of the problem of yesterday. There was some old code in the Library/Java/Extensions directory which was loaded and caused some troubles
08:17Kttmmthanks to all for the help
08:19rhudsonjowag: if you mean system environment vars, (System/getenv)
08:21jowagI mean all the clojure Vars, all the stuff I've defined and loaded from .clj files
08:22jowaglets say I've been hacking in REPL and I want to save my stuff and later continue with it
08:22rhudson(ns-publics *ns*) maybe?
08:26jowagok that will give me all the vars in the current ns, now what is left is how to dump a var
08:26powr-tochmm I can't seem to get add-classpath to work properly with cljr... does it work ok in lein??
08:31rhudsonjowag: any defn or macro is gonna be a problem
08:50BjeringI find time really neat for interactivly test runtime performance of what I do, is there an eqvivlant function for memory usage, something like (mem-usage [value] (...)) to give me how many bytes a particular value is occupying?
09:01ragnardHow (if possible) can I write a function or a macro that, given a function as an argument returns a namespace qualified symbol (or a name/namespace pair) that can be used to resolve the given function?
09:02neotykdefn: lol, you must be getting notified quite a lot ;-)
09:02defn:)
09:02defnragnard: i can answer that but i need to pull up my editor
09:04ragnarddefn: cool, excitedly waiting... :)
09:04defnragnard: you could use (meta)
09:06rhickeychouser: whither finger trees?
09:06defnragnard: (ns-name (:ns (meta #'doall)))
09:07defn,(ns-name (:ns (meta #'doall)))
09:07clojurebotclojure.core
09:07defn(:name (meta #'doall))
09:07defn,(:name (meta #'doall))
09:07clojurebotdoall
09:07defnragnard: would using that work for you?
09:08chouserrhickey: haven't touched them in ages. they work but the api and probably the performance should be improved.
09:08rhickeychouser: did you ever compare to the functional java ones?
09:09chouserno, that's at the top of my list for once the book is out of the way
09:09defn,#^meta
09:09clojurebotEOF while reading
09:09chouser...can see the light at the end of the tunnel now. And by tunnel I mean the process of adding index links
09:10chouserrhickey: if I can't match function java performance, I have officially failed. :-)
09:10ragnarddefn: yes, thank you... I didn't realise I could use meta for this...
09:10defn#^ was deprecated, yeah?
09:11ragnarddefn: so basically, all vars have metadata containing their name, and namespace (amongst other stuff)
09:12defni believe the answer to that ragnard is yes
09:12defnbut i only have ever used this with core
09:13defnit might not work on all vars
09:14defnit looks like it does... (def foo 9) (meta #'foo)
09:14rhudsoni believe the metadata is put there by def defn defmacro etc, so anything defined "the usual way" should be ok
09:14raekhow often is the list on clojure.org/contributing updated?
09:14defnyeah rhudson
09:14ragnarddefn: The docs says: http://clojure.org/special_forms#def
09:15defnrhudson: do you know if defmacro behaves similarly
09:15rhudsonsuspect so, but don't know
09:16defnand the answer is yes
09:16chouserrhickey: you have a finger tree use case or something?
09:17defnpriority queue?
09:19chousersorted set or map often works well for priority queue.
09:21raekrhickey: sorry for bugging you, but do you happen to know if my CA has arrived? (from Rasmus Svensson)
09:22rhickeychouser: it would be a nice addition to Clojure, I think. No specific use case here
09:22rhickeyraek: sorry, it's been a couple of weeks since I last checked the box. Will try to get there today
09:23raekok, thanks!
09:23raekacknowledged.
09:24chouserrhickey: ok. fwiw the possibility of getting finger trees included in Clojure has been and is a primary motivator for my work on it, so thanks for bringing it up again.
09:24chousera few more weeks and I should be able to start making progress on it again.
09:25rhickeychouser: I periodically get asked about persistent data structures with efficient insertion, and reluctantly admit Clojure hasn't got one yet
09:26chousersorted sets and maps :-) But I know what you mean.
09:28chousertesting the performance of my code vs. PersistentQueue and PersistentTreeMap was a bit discouraging.
09:37LauJensenchouser: How discouraging? :)
09:43chouserpretty discouraging. I forget the actual numbers, but conjing onto a vector is *fast*
09:50AWizzArdrhickey: The search box on the upper right side of http://clojure.org/ produces an error when being used.
09:50AWizzArdchouser: was the PersistentTreeMap more efficient?
09:51chouserfor anything that existing clojure collections can do, they're faster than my figer trees are right now.
09:59rhickeyAWizzArd: it says "Search is temporarily unavailable." So, search is temporarily unavailable.
10:18AWizzArdWill read-lines be moved from clojure.contrib.io into clojure.java.io sooner or later?
10:22pjstadigrhickey: saw the keyword GC change
10:23rhickeypjstadig: work ok for you?
10:23pjstadighaven't tested it just yet, but i think it will
10:26neotykAWizzArd: I've released ahc-clj 0.1.1 with your suggestion on NPE, thanks!
10:37BahmanHi all!
10:45yacindoes = not work for java arrays?
10:45yacin,(= (into-array Byte/TYPE (map byte (range 10))) (into-array Byte/TYPE (map byte (range 10))))
10:45clojurebotfalse
10:49AWizzArdneotyk: oh cool!
10:50defn,(into-array Byte/TYPE (map byte (range 10)))
10:50clojurebot#<byte[] [B@53ff89>
10:50defn(into-array Byte/TYPE (map byte (range 10)))
10:50defn,(into-array Byte/TYPE (map byte (range 10)))
10:50clojurebot#<byte[] [B@184681f>
10:51defnyacin: they're not equal?
10:51yacinnope: http://osdir.com/ml/clojure/2010-03/msg01184.html
10:52yacinlooks like it just compares the references
11:01tomojdid prim and friends make it into beta1, I wonder?
11:03chouserno
11:03chouserI think they've been officially pushed to post-1.2
11:10tomojdarn
11:26defnis there a way to print the full contents of a java array?
11:27defni mean the obvious answer is yes, but using aget and looping doesn't seem very elegant
11:29jkkramer,(seq (into-array [1 2 3]))
11:29clojurebot(1 2 3)
11:31AWizzArddefn: for multidimensional arrays you will have to manually traverse them
11:55tomojis there no way to test whether something is a java array?
11:59AWizzArdtomoj: yes
12:00AWizzArd,(let [x (byte-array 5)] (and (class? x) (.isArray x)))
12:00clojurebotfalse
12:01AWizzArd,(let [x (byte-array 5)] (and x (.isArray x)))
12:01clojurebotjava.lang.IllegalArgumentException: No matching field found: isArray for class [B
12:01AWizzArdok, no, .isArray must be called on a class
12:01AWizzArdso, it would be more like
12:02AWizzArd,(when-let [c (class (byte-array 5))] (.isArray c))
12:02clojurebottrue
12:02AWizzArd,(when-let [c (class 42)] (.isArray c))
12:02clojurebotfalse
12:04tomojah
12:05tomojI was surprised not to see (array? x)
12:06AWizzArd(def array? #(when-let [c (class %)] (.isArray c)))
12:06AWizzArd(def array? #(boolean (when-let [c (class %)] (.isArray c))))
12:06AWizzArdor if-let vs boolean
12:08arohnerdefn: pprint handles arrays, I believe
12:08arohnerdefn: or, it definitely handles 1-d arrays, not sure about 2-d
12:40mefesto_clojure couchdb driver "clutch" no longer on github?
12:42bpsmmefesto_: http://github.com/ashafa/clutch ?
12:42mefesto_bpsm: ah thanks, i guess i had a bad link
12:59tomojusername changed
13:42savanniHi,all. I haven't been around in a while, but I ran into a question today.
13:43defnsavanni: shoot
13:43savanniIs it idiomatic to, when a function encounters an error that it needs to report back up, raise an exception?
13:43defni guess i don't see why not
13:43savanniand if so, how do I define new exceptions these days? The gen-and-load-class function that I see mentioned in a few places is not present in the clojure API documentation or in either version of clojure I have.
13:45defnthat's a good question
13:45savanniAlthough I am considering just saying (throw (proxy [Exception] ["my error message"])), but I'd prefer to pattern match on the class of the exception.
13:45ataggartwhy bother with a proxy at all?
13:45defn^^
13:45ataggart(throw (Exception. "my error message")) works fine
13:45savanniOh, in that case, you're right.
13:46savanniBut i'd still like to define my own exception classes.
13:46ataggartthen, you'll need to gen-class iirc
13:46ataggartbut usually custom exceptions are a waste
13:46savanniWhy is that?
13:46savannierr...
13:46savanniwhy are they a waste?
13:46Hodappugh
13:46HodappI got C++ all over me again
13:47RaynesWell, why would you need them?
13:47Hodapphow do I wash this off
13:47defnHodapp: have a pressure washer?
13:47RaynesI've never needed DudeYouGaveMeTheWrongInformationException before.
13:47Hodappdefn: nah
13:47Hodappdefn: that's only good for Lispy languages... the water gets underneath all the parens
13:48ataggartin almost every case an exception indicates an unrecoverable condition anyway, just throw a RuntimeException
13:48defnHodapp: as a service to the community ill hose you off, might sting a bit at 3000 PSI though
13:48Hodappdefn: wait till I get off work, I'm just gonna get covered in C++ again if I wash off
13:48savanniumm... no, I am working in cases where exceptions need to be handled. A runtime exception would not be nearly expressive enough. But I could possibly just match on the error string.
13:48defngood point.
13:48ataggartsvanni: example of where the need to be handled, pls
13:48defnHodapp: until then, enjoy the filth! :)
13:49ataggartI fail at typing today
13:49ataggartsavanni: can you give an example of where they need to be handled?
13:49ffaillahello, does anyone know if we can define our own constructor via defrecord
13:49ataggartffailla: no
13:50savanniOkay... user gets an object from a database, makes some modifications, then submits the object back. In the meantime, another user modified that same object and my code notices that the save would destroy something I don't want to destroy. So, I throw an exception which a high-level handler catches and provides a proper recovery interface to teh user.
13:51ffaillaataggart: thanks
13:52ataggartThere are other, possibly better, ways to handle such cases
13:53savanniperhaps. I'm thinking of returning results using something like Haskell's Either structure.
13:53savannifailing a sanity check isn't necessarily exceptional, at least not in the same way that total database failure or total disk failure would be exceptional.
13:54ataggartin the java world such exceptions would be checked (i.e., derived from Exception, not RuntimeException), and the caller would be forced to handle it. Clojure doesn't force such behavior, thus intervening levels between handler and thrower can break in unexpected ways
13:56ataggartusing typed, checked exceptions just isn't really a good fit
13:56savanniI'm much more experienced with Python than with Java, and we don't have checked exceptions there. But, again, the only way to return an expressive error is with an exception.
13:56ataggartyes, but "return[ing] an expressive error" is not your only option
13:57ataggartat least not from the code that detects a mid-air collision
14:00ataggartthat said, you can also use error-kit
14:00ataggarthttp://richhickey.github.com/clojure-contrib/error-kit-api.html
14:01savanniOkay, I'll study that for a while.
14:44mefesto_is there a way to simply download a jar from clojars instead of having to use leiningen/maven?
14:45savanniYeah. Hit the "browse" link on clojars.org and just delve down into the hierarchy until you find the jar files.
14:45mefesto_savanni: ahh thank you :)
14:55rsh is there a function to set a var's root binding without supplying a function? I really just want to set it to a value
14:59bultersGday all...
15:04raekthinking of it, we clojurians use maps pretty much everywhere
15:04raekit's indeed a powerful data structure
15:04technomancybut, but--alists are functionally equivalent!</common-lisper>
15:04programbleabloo
15:05programbleheh
15:05programblelispy has no maps, uses alists
15:05bultersSo I should consider myself lucky not having programmed in common lisp?
15:05raekI like how simple clojure makes usage of maps
15:06technomancybulters: depends; are you often nostalgic for the 80s?
15:06programble=>72 / 24
15:06ataggarttechnomancy: what OS do you use?
15:06programbleno?
15:06bulterstechnomancy: I'm from 1984
15:06technomancyataggart: ubuntu
15:06programble->72 / 24
15:06sexpbot=> 72
15:06programble:\
15:06programblelies
15:07bulterstechnomancy: So not too much to be nostalgic about...
15:07programblelololol
15:07programblewtf is wrong with me
15:07programble->(/ 72 24)
15:07sexpbot=> 3
15:07qbgCL pathnames are just so weird
15:07bultersAlthough, I still have a movie of a 3 year old bashing on a MSX2 ;-)
15:07qbgClojure makes CL look ugly
15:08programblelots of things do that
15:12ponzao____I have a small noob question, which is not from a real problem I am suffering, just something I stumbled onto and didn't quite grasp why it does what it does. I have defined a struct (defstruct Foo :a), I am trying to map with :a over a list of Foos (map :a '((struct Foo 10))) -> (nil), if I use (map :a (list (struct Foo 3))) I get (3). If I use a map instead of a struct in both cases I get (3), just wondering what is the reason for this.
15:13arohnerponzao____: ((struct Foo 10)) tries to call the struct
15:13arohnertry [(struct Foo 10)] instead
15:13AWizzArdwell, not that, because it is quoted.. but, it is (list (list foo))
15:14AWizzArdand (get '((100)) :a) ==> nil
15:14programblea quoted lists, nothing inside gets evaluated
15:14ataggart^
15:14programbleuse vectors
15:14arohneroh right
15:14arohner(:a struct) (:a Foo) (:a 10)
15:14arohnerno
15:15programble'((+ 1 2)) is literally ((+ 1 2)), not (3)
15:15ataggartI can't think of a case outside of macros where one needs to use literal lists in clojure
15:16ponzao____ataggart, I've seen them used in some examples, are they something that are not recommended?
15:16arohnerponzao____: quoting is annoying, so it's just more convenient to use vectors
15:16ataggartand is visually useful
15:17AWizzArdIt may help some newcomers to litterally write out quote from time to time, as in (map :a (quote ((struct foo 10))))
15:18bulters*makes a mental note to quote lists*
15:18programbleno, make a mental to note to always use vectors
15:18ataggartalternately, don't use lists.
15:18ataggartdamn my slow fingers
15:18ponzao____Why is the behavior different for maps and structs?
15:18bultersataggart: You're telling me not to use lists in a lisp?
15:19arohner(list (struct Foo 10)) is also more convenient that quoting
15:19programblevectors are lists... just... different...
15:19programblevector-ish
15:19ponzao____(map :a '({:a 10})) -> (10)
15:19arohnerponzao____: that map is a literal, while (struct Foo 10) is a function call (that needs to be evaluated) to produce a struct
15:20arohnerthe quote prevented evaluation
15:20ponzao____arohner, aaaah okay, well that explains it.
15:20ataggartbulters: yes, when simply constructing a literal datastructure.
15:21ponzao____arohner, That brings up another question I wondered at some point: How can I force the evaluation of quoted code?
15:21ataggarteval
15:21arohnerponzao____: eval, or backticks
15:21bultersataggart: I almost thought you were serious ;-)
15:22arohnerin this case `(~(struct Foo 10)) would work
15:22arohnerthat says, build a quoted list, but evaluate the things that start with squigglies
15:23arohnerponzao____: though 99% of the time, you don't need eval
15:23ataggartnot enough 9s
15:24ataggartI've used eval once in all the clojure I've written
15:25ponzao____arohner, Ok. As I said before my "problem" was not something I really ran into. Thanks for the help to you and everybody else. I think the biggest learning curve in Clojure (and other Lisps?) comes from understanding the evaluation and macros.
15:39raekbasically, functions and macros are very similar:
15:39raekfunctions: (apply f (map eval args))
15:39raekmacros: (eval (apply m args))
15:41AWizzArd,(doc apply)
15:41clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
15:41AWizzArdif m is a macro then apply won't work on it
15:42raekyes, that was just a rough scetch demonstrating the differences in evaluation of functions and macros
15:42raekI once made a lisp toy language
15:43raekI thought it'd be a good idea to be able to apply macros
15:43raek...and special forms
15:43raek(x true (do-foo) (do-bar))
15:44raekthat could do completely different things if x was a function, a macro, or a special form
15:45raeke.g. if x evaluated to the special form object 'if'
15:45somniumIm guessing this was an interpreter?
15:46raekyes
15:46raekcompiling this would not be very easy
15:46TimMcIt would certainly not be as optimizable.
15:47TimMc(You could not compile it to bytecode.)
15:47somnium[if (= (%typeof x) if) ...]
15:48somniummaybe if it was lazy you could compile it
15:50KirinDaveprogramble: Sorry you had to endure python
15:50raeki once began on a lisp with only parentheses
15:50raek() was 0
15:50TimMcHeh.
15:50raek(x) was (inc x)
15:50raek((())) = 2
15:51raekall functions had numbers
15:51programbleKirinDave: lol i use python all the time
15:51raeksay, 3 is +
15:51KirinDaveprogramble: My condolences.
15:51programblei like it, obv
15:51raek((((())))()(())) -> (+ 0 1) => 1
15:51TimMcKirinDave: Hey now, someone has to like it.
15:51programbleraek: im scared
15:52raekok, 4 is let
15:53raek(4 <binding> <body>)
15:53raekhrm
15:53programblelol
15:53raekI think I solved naming with a special lookup functoin
15:54raek(lets call it 5)
15:54raek(5 3) is lookup variable 3
15:54somniumraek: I think the only legal identifiers should be sequences of [{}]...
15:55KirinDaveTimMc: No. No one does.
15:55programblebrainfuck is a great language
15:55somniummaybe ()<><>() for complex numbers
15:55KirinDaveTimMc: Python is the first resort of the unimaginative. Knowing it is one thing. Liking it given the wealth of languages we have today that all do really well? Inexplicable.
15:55raek(let (var-6 (+ 1 2)) (+ 2 (lookup var-6)))
15:56programblei dont "like" it per se...
15:56programbleits more just... easy to use
15:56raek(4 (6 (3 1 2)) (3 2 (5 6)))
15:56ponzao____KirinDave, :D
15:56raek(((((()))))(((((((()))))))((((())))(())((()))))((((())))((()))((((((())))))((((((())))))))))
15:57raekI should pick up this project again...
15:57KirinDaveprogramble: Huh.
15:57ponzao____KirinDave, I think I'd like a t-shirt with that
15:57programblepythons works, and its not ugly...
15:57programblegood for scripts if you ask m
15:57programblee
15:57KirinDaveIt's pretty ugly.
15:58programblewell yeah
15:58programblenot as bad as some
15:58KirinDaveIt's not Erlang ugly.
15:58programbledoesn't shove oop down your throat
15:58programbleits easy to do things
15:58KirinDaveHah. There Is Only One Way To Do It.
15:59KirinDaveAnd It Is Not A Very Good Way But I Am Sure You Rubes Can Handle It. I'm GVR, I Don't Give A Fuck.
15:59TimMcraek: Ah, a lookup function.
15:59KirinDaveLong acronyms in the python community.
15:59TimMcI almost buy that.
15:59somniumI am still amazed that GVR is actively opposed to adding TCO
16:00somniumapparently on the grounds that people would use it do recursion
16:00TimMcKirinDave: Unfortunately, PHP and Python can be run interpreted just about everywhere. :-(
16:00KirinDaveSo can PLT Scheme.
16:00TimMcKirinDave: Not on any web host I've seen.
16:00programblewait wait
16:01programblewe are talking about how bad python is
16:01programbleand someone mentions PHP?
16:01TimMcprogramble: As an example of something that is easy to use.
16:01programblelolololololol
16:01TimMcNot comparing ugliness.
16:01programblePHP is not easy to use
16:02TimMcPHP is easy to start using, sure. Great docs, great HTML integration, pretty good library of simple data manipulation functions.
16:02TimMcIt's only hard to use once you try to make your project bigger or scure.
16:02TimMc*scure
16:02programblePHP is a preprocessor, not a language
16:03KirinDaveTimMc: PHP's inconsistent libraries are its biggest weakness last time I checked.
16:03TimMcKirinDave: Yes. But as a noob I had no trouble just looking up the syntax every few minutes.
16:03somniumKirinDave: have you seen Phuby?
16:04KirinDaveNo.
16:04programbleruby seems great and all
16:04programblebut the syntax makes me want to kill myself with a spoon
16:04somniumKirinDave: its on github, great stuff
16:04KirinDaveWait. Now I have.
16:04zkimHey all
16:04KirinDaveI wish I hadn't.
16:05KirinDaveMy last words will be, "My God, it's full of stars!"
16:05somniumKirinDave: theres a video where they run wordpress in rails
16:06KirinDavesomnium: I'm going to have nightmares for weeks now.
16:06somnium:D
16:06KirinDave“When I open my eyes it is still there!”
16:06programblelol
16:28zkimAnybody doing swing development with clojure?
16:30savanniNo, but i'm considering it, amongst other gui tools.
16:31zkimAh, was wondering if there was a lib or people just roll their own wrappers
16:31zkimWhat other gui tools are you looking at?
16:48dakronezkim: you could check out swing-utils in contrib: http://richhickey.github.com/clojure-contrib/swing-utils-api.html
16:51zkimdakrone: thanks, I'm starting to convert a java app of mine over to clojure, and was wondering if there was a consensus on swing dev
16:59ragnardzkim: have you read Stuart Sierras blog posts on clojure/Swing? can recommend them.
17:01zkimragnard: yeah, the heating up clojure & swing post? Definitely helped.
17:02ragnardyup, I think it starts with "First Steps With Clojure & Swing"
17:03zkimI only saw the one, I'll have to take a look for the others
17:03ragnardzkim: first one is at http://stuartsierra.com/2010/01/02/first-steps-with-clojure-swing
17:03zkimit looks like the choices are c.c.swing-utils, Licenser's lib, and roll your own
17:04Licenserif you want clj-swing feel free to ask questions
17:04zkimHey licenser
17:04zkimyeah definitely looking at your lib
17:05zkimGot two of your libs up on clojuredocs.org, having trouble with the other two
17:05Licenser:) yay
17:14Rayneszkim: Have you considered letting users add libraries themselves?
17:14RaynesSeems kind of tedious to do all that yourself.
17:15zkimYeah, definitely, there's some manual process around adding libs that I'm trying to get around
17:16zkimIt's basically pull source -> lein / mvn install -> add to the cd-analyzer deps -> run
17:16Raynes:)
17:16zkimSo I'm trying to automate the first 4 steps
17:17zkimThat'd be great, it's second or third down on the list after categories
17:18dakronezkim: coming to the meetup next wednesday?
17:18ataggartit'd be nice if the "namespaces" list omitted the common prefix
17:18ataggarte.g. http://clojuredocs.org/Clojure%20Contrib
17:18zkimdakrone: yeah, I'm looking forward to it
17:19dakronezkim: cool, will see you there then :)
17:19zkimataggert: good idea, I'll add it to the list
17:19zkimdakrone: cool, hope there's a good turnout
17:19dakroneyea
17:33robtpany ideas, anyone - java.lang.ClassNotFoundException: incanter.Matrix - like this, maybe: http://www.mail-archive.com/clojure@googlegroups.com/msg14941.html
17:36cschreinerzkim: ataggert: and remove the center alignment
17:37zkimcschreiner: center alignment for on the ns sidebar?
17:37zkim(minus for)
17:38cschreineron the namespaces column
17:38zkimIt's left aligned for me, which browser / os you on?
17:38cschreinermac/safari/ff
17:38zkimhrm
17:39ataggartleft for me om mac chrome, but looks like its not left due to the elipses
17:40cschreinerataggart: you're right :)
17:40zkimyeah, the ellipses were kind of a hack, prior to that the nss would wrap at odd places, or hang over the center
17:40cschreinerfooled myself
17:40cschreinermake them go away (the prefixes) and group them instead
17:41cschreinerno need to repeat clojure.contrib. 170 times on a page
17:41zkimagreed
17:41cschreinerreally love your initiative
17:41cschreinerzkim
17:41zkimgroupings a good idea, I'll play with it a bit
17:41cschreinerbut, you're no designer ;)
17:41zkimthanks, labor of love and all
17:41zkimhaha no kidding :)
17:42cschreinerbut I'll look through that for now
17:42zkimknow any designers that want to get their work out?
17:42zkimI'm trying to figure out where I would find somebody like that
17:43cschreinerI don't know
17:43cschreinerdepends on what you want
17:43cschreinerwould love to throw a css at it though
17:44zkimgo for it and I'll test it out
17:44cschreinerokay
17:44zkimhtml's kind of ugly, but you should have all the hooks you need
17:45cschreineryou should try and clean up the html, like make it more 5'ish
17:46zkimhavn't really looked at 5, they get rid of the div tag or something :)
19:29lpetithi
19:29lpetitdoes this macro already exist ? :
19:30lpetit(let [x #"baz\(" y "bar"] (interpol-regex #"(?:a|`x`|`y`)") => #"(?:a|baz\(|bar)"
19:33lpetitmore useful (and real!) example: (let [symbol-head #"[a-z|A-Z]" symbol-rest (interpol-regex #"`symbol-head`|[0-9]")] (interpol-regex #"`symbol-head``symbol-rest`*")
19:45lpetitnobody here ?
19:56arohnerwhat's the type hint for an array of Objects?
19:59defnWirth's law: Software is getting slower faster than hardware is getting faster
20:18ataggartarohner: ^objects
20:46slyruss/uses/wishes/
20:48dnolenClojure, Node.js and Concurrency Fail, http://dosync.posterous.com/clojure-nodejs-and-why-messaging-can-be-lame
20:49dnolenbound to stir up some controversy
20:50TeXnomancydnolen: "how Node.js might fair" should be fare
20:50dnolenTeXnomancy: thx
20:50ataggart"Node.js is not faster that Aleph" s/that/than
20:51dnolenattagart: thx
20:51ataggarton a less pedantic note, are there any good guide to getting code out on he Amazon Compute cluster?
20:52dnolenattagart: it's pretty simple, just use the CentOS image, install the latest JDK and yr pretty much good to go.
20:52ataggartcool
20:52ataggartthx
20:58dnolenfeel free to upvote on HN if you read that
21:15robtplogarithm?
21:15robtpi can't seem to find it
21:15rhudsonMath/log
21:15rhudson(from java.lang.Math)
21:15robtpoh
21:16robtp*slap*
21:31slyrusumm... how do I specify a default value for an optional arg for a function again?
21:32slyrusi.e. the clojure equivalent of (defun foo (&optional (moose 32)) (1+ moose))
21:32slyruswishes google translate would do cl -> clojure
21:36slyruswait, let me guess... you can't do that in clojure
21:39raekyou can do it like this:: (defn foo ([] (foo 32)) ([moose] (inc moose)))
21:40ericthorsen_Iit appears that after a I AOT a defprotocol and attempt to use it in an extend-type expression I get an error "java.lang.IllegalArgumentException: interface org.model.db.MyProtocol is not a protocol"
21:40slyrusah, so I don't need the &
21:40slyrusthanks raek
21:40slyrusoh, i see...
21:41slyrusit's like i thought. ok.
21:41ericthorsen_I also noticed that when AOTing defrecords the namespaces that get prepended are clojure style not java (so this-that does not turn into this_that) which surprised me
21:41ericthorsen_Anyone else playing with defprotocol and defrecord?
21:43raekor like this: (defn foo [a b & [moose]] (+ a b (or moose 32)))
21:44raeknot a very beautiful example, perhaps...
21:45raekI haven't played with defrecords and AOT at the same time
21:45slyrusraek: the (or moose 32) is hardly a default value for the parameter :) yes, I can add another let around the function body and check the value of the parameter, but I guess the whole &optional thing is at odds with clojure's multi-arity thing
21:46slyrusso the proper way to do this is as like what you had above
21:46raekthat's probably the most common way of doing it
21:47raekdestructuring with maps has support for :or which can provide default values
21:47raekthis does not exist for sequence destructuring, though
21:48raek(let [{a :a, b :b, :or {a 1, b 2}} some-map] (+ a b))
22:04mudgehello
22:05mudgei declared an atom in one namespace, and i required the namespace from another namespace, but how do I access the atom from the first namespace?
22:05mikemmudge: how did you require it?
22:06hiredmanmy guess would be with require
22:06mudgei used (:require in the ns declaration of the second namespace and said ":as pt-hook" so i could use pt-hook to reference the name space
22:07mikemmudge: then pt-hook/name-of-atom should do it
22:07mudgeso would I then do: @pt-hook/my-atom ?
22:07mudgeokay
22:09mudgehmm... my second namespace dosen't see pt-hook/my-atom, my first names space is actually using gen-class for AOT
22:10mudgei know that if you are going to use methods for a gen-class namespace you have to use :methods and declare your methods
22:10mudgebut i'm not making a method, just an atom
22:11mudgeso i guess the question is how do you expose definitions from within a gen-class namespace
22:13mudgei have this in one namespace: (def oh nil)
22:13mudgei want to refer to in another namespace, like so: pt-tools/oh
22:14mudgethe first namespace is gen-classed
22:20mikemmudge: i'm not sure how gen-class complicates things, sorry
22:22mudgeok
22:27mudgecan two namespaces require each other?
22:31rhudsonno
22:35mudgeno what?
22:36mudgehow do you make a global variable at runtime in clojure?
22:37rhudsonYou can't have two namespaces require each other.
22:37rhudsonrequire is a dependency relationship
22:38mudgerhudson, great, great to know
22:38mudgerhudson: yea, it would be like mutually recursive requiring
22:39mudgeor something
22:40rhudsonYeah, I learned this the first time I wrote a multi-ns program. I had to push some stuff into a different ns to break the loop.
22:42slyrusis there a good deftype example around?
22:42slyrusoh, nvm the circuitbreaker example...
22:43slyruswell, maybe not...
22:46mudgedef works at compile time, is there something like that, that works at runtime, but has module scope like def does?
22:46rhudson,(doc intern)
22:46clojurebotDENIED
22:47rhudsonmudge, look at clojure.core/intern
22:50slyruserm... how do I undef a type?
22:50mudgethanks rhudson
22:53Raynesmudge: http://clojuredocs.org/v/1779
23:03slyrusgrumble grumble... the defprotocol/deftype example in the clojure.core API docs doesn't work
23:04hugodslyrus: it is missing an explicit "this" argument in the deftype
23:05slyrusyes
23:05hugodyou might try ns-unmap for removing a definition
23:06slyrusyeah, that worked. thanks.
23:07slyrusoh, no, sorry, I did remove-ns
23:07slyrusand rebuilt the ns
23:07slyrusi'll try ns-unmap next time
23:10slyrusif i have (defrecord Foo [a b] ...) can I specify a default zero-arg constructor that will fill set a and b?
23:12hugodyou have to write a factory function at the moment, but I believe it is planned
23:12woobyslyrus: fyi, reify also requires explicit 'this' for methods (contrary to examples)
23:12woobyran into that myself
23:12slyrusfactory... bah... what is this java? :)
23:13hugodjust elide the word if it offends :)
23:14slyrusis used to (defclass ...) not DefaultAbstractFactoryGeneratorSingleton or whatever the java equivalent is :)
23:15slyrusand (make-instance ...), of course
23:18hugodode to a meta object protocol
23:18slyrusheh
23:19hugodthe doc-string thing is bug #340, but seems to have been relegated to the backlog
23:20hugodit even has a patch from fogus
23:27BahmanHi all!
23:40defnkisses
23:48Tekk_hey, my friend is too lazy to say why clojure is the best lisp and he sent me here >.>
23:49rhudsonTekk_: here's a good pitch: http://clojure.org/rationale
23:51tautologicois there any nice, built-in 2d matrix data structure available in clojure?
23:51zkimTekk_: it sounds like you have a background in lisp, that correct?
23:54Tekk_zkim: learning scheme :P
23:54zkimTekk_: background in any other languages?
23:55Tekk_zkim: also know python, some C, some C++, some perl, some ruby........
23:55Tekk_bit of everything :P
23:55RaynesWe don't really deal in "this language is better than x". I'm sure you'll find plenty singing the praises of Clojure, but whether or not it's "the best Lisp" is for you to decide. :D
23:55Tekk_I like how simple scheme is, but I havent done clojure yet so not sure how I'll like it ;D
23:55zkimTekk_: Video-wise http://blip.tv/file/982823 really helped when I was starting out
23:57zkimTrying to find that dzone video where rich talks about time, anybody got the link?
23:57zkimwhoops, meant infoq
23:59zkimTekk_: Prob my favorite: http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey
23:59Rayneszkim: http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey
23:59RaynesI think it's that one.
23:59zkimRaynes: Yeah, loved that one