#clojure logs

2011-03-29

00:05dnoleninteresting (set key) is nearly twice as fast as (contains? set key)
00:06amalloydnolen: contains? has to do several typechecks
00:07amalloy(i suspect)
00:07amalloy$source contains?
00:07sexpbotcontains? is http://is.gd/AXAj4p
00:09amalloydnolen: yeah. it checks to see what kind of collection it is in order to decide how to look it up with contains?. for a set, it just calls .invoke
00:36mecJoy of Clojure or Portal 2, such a difficult decision :x
00:39amalloymec: wait, is portal 2 out yet? or are you making a financial decision?
00:39mecfinancial, portal is out in a couple weeks but I dont think Joy has been released at a couple places either
00:40amalloymec: my copy went into the mail today
00:40amalloyas did a lot of people's, to judge from the twitterverse
00:41pdkp2 is available for preorder
00:41pdkfeels good getting tjoc with the preorder code
00:42mecamazon says march 31
01:15amalloyanyone know a good way to sneak a for- or doseq-like construct into a ->/doto form? eg, (let [sizes (range 10)] (-> obj .getSizeList (doto (.add 0) (.add 1) ...))), except looping through sizes? i know i could do it by breaking out of the ->doto tree with a let/doseq, but it'd be nice if i could keep everything in this form-rewriting macro i'm already in the heart of
01:19devn_mec: Joy of Clojure, no contest
01:20devn_it's a fantastic book. the chapter on multimethods is worth the price alone
01:23amalloydevn_: you sound like someone who didn't play portal 1. it's a tough choice if you can only afford one of them :)
01:25devn_i played all of portal 1 twice
01:25devn_it's not a tough choice at all IMHO
01:25devn_one of them contains knowledge about something useful
01:25devn_and the other is a video game
01:26devn_no offense -- im all for entertainment, but if you have to choose between plato and NBA Jam, there is a clear objective winner
01:26amalloydevn_: *shrug*. i liked JoC when i read it, and obviously it's more "useful", but the internet is already full of knowledge
01:27amalloybut mostly i was exaggerating for entertainment value
01:27devn_amalloy: fair enough -- IDK, i just think the chapters from like 8-N of JoC were absolutely fantastic
01:28devn_the whole get/put/beget yegge reference and prototypal inheritance sprinkled over multimethods was a brilliant way to demonstrate the power
01:29devnin any event -- im just being opinionated
01:30amalloydevn: that's the nice thing about the internet: you're entitled to be opinionated
01:30devni just dont see a video game anywhere on par with a book in terms of value
01:30devnamalloy: id say the same if you were sitting in front of me :)
01:31devnI just re-read Practical Clojure. Also worth more than a Sega Genesis in the long run. :)
01:31amalloyJoC is the only clojure book i've read
01:31devnanyway i should get to bed -- i get to hack on some clojure tomorrow at work. woo!
01:31devncheers alan
01:32amalloynight
02:08amalloypaul graham is a bad influence on me. i've been reading On Lisp, and now i'm seeing all kinds of places where it would be useful to introduce symbol capture into my macros
02:17hoeckamalloy: where else does one need that except in anaphoric macros?
02:17amalloyhoeck: well yes, so far that's it :P
02:18amalloyit's just something i remember having been terrified of when i was learning CL, and clojure too. i'm still glad it's hard in clojure, though
02:19hoeckoh well, I did it once in some implementation, capturing a context of 3 vars or so because I did interface with some java lib and the macro did set up some boilerplate to create arguments for class ctors
02:20hoeckyeah, cl has a more brutal approach to that
02:21amalloyhoeck: tonight specifically i realized i often wrote ((fn foo* [args] (lazy-seq (...something... (foo* new-args)))) starting-args)
02:21hoeckbut I could live with symbol capture if there would be some metadata on the macros identifying the captured symbols so that my IDE and tools of choice highlight them
02:22amalloygood case for a macro, except it needs the symbol foo* for no particular reason; i decided to call my macro lazy-loop and have it anaphorically bind lazy-recur
02:23amalloyspeaking of which, since i've got your attention: https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils/seq.clj - comments?
02:27hoeckamalloy: what is unfold for? seems to be like iterate?
02:27amalloyhoeck: it's the opposite of reduce. borrowed from haskell
02:27hoeckcan you give me some example usage?
02:27amalloyi implemented unfold on top of iterate a while ago, and it turns out to be a lot cleaner to just use lazy-seq directly
02:27amalloyhttps://gist.github.com/805583
02:28amalloybasically (defn fibs []  (unfold (fn [[a b]] [a [b (+ a b)]]) (constantly false) [0 1]))
02:28hoeckmaybe you should call it "unreduce" then or mention that in the docstring :)
02:29amalloyhoeck: unfold is the traditional name for it. reduce is a synonym for fold
02:29amalloybut sure, i suppose i could put that in
02:30hoeckI know, I just barely use the term fold, only spending little time inside my xmonad.hs config and more time on the clojure repl
02:30amalloy*chuckle*
02:30amalloywell, i don't know any haskell at all tbh. got through chapter one or two of LYAH
02:30amalloyjust that brehaut is always telling me about haskell, and plenty of resources online about FP are in terms of haskell
02:32hoeckHaskell was my first exposure to functional languages in university some years ago,
02:33hoeckI always miss pattern matching and algebraic datatypes in clojure
02:34amalloyhoeck: dnolen (i think?) has a pattern-matching library, and someone tweeted about algebraic data types just the other day
02:35amalloyhttp://spin.atomicobject.com/2010/04/25/matchure-serious-clojure-pattern-matching - i guess not dnolen
02:35hoeckand of course I don't want them to be much slower than using defrecords and plain ifs :)
02:37hoeckamalloy: thanks, looking at it
02:37DeranderI'm still struggling to wrap my head around haskell
02:37Deranderit's fun though
02:40hoeckwhat I miss in Haskell is reloading code at runtime
02:53thorwilhoeck: maybe this could help, re pattern matching: http://www.brool.com/index.php/pattern-matching-in-clojure
02:59hoeckamalloy: I like that lazy-loop macro
02:59amalloyhoeck: feel free to steal; that's what amalloy-utils is for
03:00hoeckamalloy: thanks, I have yet to built and maintain my own collection of utils
03:01amalloyhoeck: you should! the jvm makes it really easy to distribute/share libraries, even with yourself
03:04hoeckthorwil: thanks, that looks really promising
03:06hoeckamalloy: I had one some time ago, and lots of things I wrote myself appeared in core, so I stopped using my stuff and instead used the proper function from core
03:07hoeckand then I'm always afraid of maintaining such a collection, other than that you're right, it is very easy to share and distribute stuff :)
03:07amalloywhat do you mean by maintaining?
03:08hoeckkeeping that private util collection working across clojure releases and so on
03:09amalloyi wouldn't have thought that'd be so hard, but i guess mine is only a month old or so
03:11hoeckit's not hard just boring once it reaches a certain size
03:15amalloyit's true, ninjudd's clojure-useful doesn't look like it's fun to maintain
03:21hoeckwhen I really need some utilities, I often write them per project, and try to keep them rather small
03:23kumarshantanuhi, anybody with Leiningen plugin-development experience here?
03:24amalloyhoeck: per-project is seductive but evil, it seems like
03:24amalloyif something language-level is handy once, it'll be handy again, and i don't want to decide between writing it twice and doing without
03:25raek(I've a hello world plugin, but I've used robert.hooke in other projects)
03:25hoeckamalloy: yeah, there is no clean solution to it, everything has its drawbacks, but so far I only work on one project :)
03:25raekkumarshantanu: go ahead and ask your question... :-)
03:26kumarshantanuI put up my questions here (sorry, 4 questions): http://groups.google.com/group/leiningen/t/fbec0e9ef37a9111
03:32raekkumarshantanu: note that I'm not expert on this, but this is what I know so far:
03:33raekplugins run in the leiningen clojure instance and have :dev-dependencies on their classpath
03:34raekI made a test plugin that printed the entries of the classpath, and only :dev-deps showed up
03:34kumarshantanuraek: thanks, yeah I know that...and not :deps ?
03:34raekdoesn't seem like it
03:35kumarshantanuraek: okay, go on
03:35raekI added an ordinary :dep, but it didn't show up in the plugin's classpath
03:35raek(but src/ was there)
03:36kumarshantanuraek: src was in classpath?
03:36raekyes
03:37raek(note that I put the plugin in src/leiningen/foo.clj)
03:37kumarshantanuand how did you retrieve a list of entries/vars from classpath? (that might come in handy for me)
03:37raekit seems like you shouldn't try to run project code in the plugin directly
03:37raekbut I know that leiningen has a eval-in-project thing
03:38kumarshantanuraek: okay, let me elaborate a bit
03:38raekkumarshantanu: https://gist.github.com/891945
03:39kumarshantanuactually I am trying to write a Lein plugin for Clj-Liquibase (RDBMS migrations, change management etc), so I need access to classpath and need to put configuration code apart from "src" (like Rails)
03:39raekdoesn't look like resources/ is on the classpath (even if I created it)
03:39raekbut that will be on the classpath if the plugin is in its own project
03:40kumarshantanuraek: could it be because you were picking up *only* the system classpath?
03:40raeksystem classpath?
03:40kumarshantanuraek: reference - by looking at the gist
03:41kumarshantanus/by/am/
03:41sexpbot<kumarshantanu> raek: reference - am looking at the gist
03:41raekanyway, you can use (require '[clojure.java.io :as io]) (io/reader (io/resource "com/example/foo.txt")) to open something on the classpath
03:42raekleiningen does not use a "system classpath"
03:42raekI don't think the SystemClassloader is just the standard implementation of a classloader or something
03:42raeks/don't//
03:42sexpbot<raek> I think the SystemClassloader is just the standard implementation of a classloader or something
03:43amalloyraek: i think the system classloader gets some special treatment by the security manager in a sandbox context
03:43raekhrm. I would kind of expect lein plugins to have resources/ on their classpaths
03:43bartj&(clojure.xml/parse "<root/>")
03:43sexpbotjava.security.AccessControlException: access denied (java.io.FilePermission /<root/> read)
03:44bartjhow can I specify that "<root/>" is a string to clojure.xml/parse ?
03:44kumarshantanuraek: hmm, I think my question is boiling down to "whether I can have access to `phase` in Leiningen" -- I want access to post-compile phase with classpath and the compiled sources (like in maven, which may not be available in Lein)
03:44amalloybart. don't. put it into a reader
03:45kumarshantanuany idea if post-compile stuff is accessible to a Lein plugin?
03:45bartjamalloy, documentation mentions that parse takes in a string
03:46amalloybartj: if it *only* wants a string you'll have to pass it some kind of file
03:46amalloy&(doc clojure.xml/parse)
03:46sexpbot⟹ "([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be ... http://gist.github.com/891954
03:46brehautbart: i use the follow monstrosity in necessary-evil to achieve this (-> "<root/>" java.io.StringReader. org.xml.sax.InputSource. stream clojure.xml/parse)
03:46raekyou can of course make a hook that runs after compilation, but I don't know how to eval something in the project with the newly generated classes in place
03:46raekmaybe eval-in-project could work
03:46brehautoh wait, remove that stream thing
03:46bartjthat seems arrgh :)
03:47amalloy&(with-in-string "<root/>" (clojure.xml/parse *in*))
03:47sexpbotjava.lang.Exception: Unable to resolve symbol: with-in-string in this context
03:47raekkumarshantanu: I'm afraid I'm stepping into unknown territory now... :-)
03:47amalloy&(with-in-str "<root/>" (clojure.xml/parse *in*))
03:47sexpbotjava.lang.IllegalArgumentException: No matching method found: parse for class com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl
03:48brehautbartj: https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/xml_utils.clj#L13-22
03:48amalloyugh, that makes a stringreader too
03:48brehautbartj: i wouldnt consider that idiomatic code but it does what i need ;)
03:48kumarshantanuraek: thanks, `eval-in-project` sounds interesting
03:50amalloyi'm a bit surprised that parse won't take a reader. xml is *supposed* to work with character streams, not byte streams
03:50amalloybut i guess it wants to be allowed to parse the character encoding itself?
03:51brehautamalloy: clojure's xml needs a bit of love in all regards
03:51amalloyyeah
03:51amalloyor a little bit of hate, to convince people it needs love
03:51TobiasRaederMorning
03:52brehauti dont think you need to convince anyone
03:53brehautamalloy: http://dev.clojure.org/display/DXML
03:53amalloybrehaut: what i do need is some sleep. ta-ta
03:53brehautamalloy: night
03:54bartjamalloy, thanks!
03:55brehautbartj: if you are just getting started with clojure's xml stuff, i recommend checking out clojure.contrib.zip-filter.xml/xml->
03:57bartjbrehaut, sure thanks!
03:57brehautno problem
04:00kumarshantanu,(clojure.xml/parse (java.io.StringBufferInputStream. "<root/>"))
04:00clojurebot{:tag :root, :attrs nil, :content nil}
04:01brehautkumarshantanu: cool, thanks :)
04:01kumarshantanubrehaut: but StringBufferInputStream is deprecated
04:01brehautoh
04:02kumarshantanuso, you may have to use ByteArrayInputStream and a wrapper over that
04:02brehauti'll stick with my monstrositiy for now then
04:02kumarshantanubrehaut: let me look up and tell you
04:05kumarshantanu(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<root>XML content here<root/>" "UTF-8")))
04:05kumarshantanu,(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<root>XML content here<root/>" "UTF-8")))
04:05clojurebotorg.xml.sax.SAXParseException: XML document structures must start and end within the same entity.
04:05kumarshantanu,(clojure.xml/parse (java.io.ByteArrayInputStream. (.getBytes "<root>XML content here</root>" "UTF-8")))
04:05clojurebot{:tag :root, :attrs nil, :content ["XML content here"]}
04:06kumarshantanubrehaut: this version is recommended over the StringBufferInputStream one
04:06brehautkumarshantanu: thanks!
04:11bartjhurray parse takes in a InputStream
04:12bartjI was unnecessary converting it into a String and then reconverting everything back (if that makes sense)
04:12bartjthanks everyone who helped
05:40kumarshantanu,(.getClassLoader String)
05:40clojurebotnil
05:40kumarshantanuwhy does .getClassLoader return nil?
05:41Fossii think it only does with the bot
05:42Fossiah, no
05:43Fossikumarshantanu: "Returns the class loader for the class. Some implementations may use null to represent the bootstrap class loader. This method will return null in such implementations if this class was loaded by the bootstrap class loader." Maybe this?
05:46kumarshantanu,(.getClassLoader (class (constantly 10)))
05:46clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
05:46kumarshantanuFossi: got it, thanks!
05:52no_mindI have an application which has multiple modules. Each module has its own name space. I am looking for a way to 1) automatically create a list of all namespaces. 2) Call a specific function in all name spaces. The function call will build the menu items and menu paths for the application/modules.
05:58AWizzArdno_mind: to do 1) you can write a macro that replaces "ns" and maintains that list.
05:59AWizzArdAnd 2) can be done by your own fn "ns-call" which accesses that list and calls those fns.
06:17Dantaswhere can i find the bot commands ?
06:20fmwI'm building a web crawler and want to work with data in two/three steps (first, collect the raw documents and store them locally, afterwards I want to scrape them with Enlive to extract the data I'm interested in and store that data and the third step is optional data analysis, e.g. using Apache Mahout)
06:22fmwHadoop with HBase seems like a good fit for this (maybe also Riak, but Hadoop works well with stuff like Mahout), but there seems to be a lot of fragmentation as to how to interface with it: cascading, raw map/reduce, pig and hive.
06:22fmwwhat are you guys using? I seem Cascading has some mindshare in the Clojure community?
06:25fmwthe easy option would be to store everything in CouchDB and not worry about scaling specifics for now, as I'm already using CouchDB pretty heavily for smaller datasets, but Hadoop/HBase just seems like a better fit for longterm scaling and in combination with other Apache projects I'm (planning on) using (i.e. Lucene/Solr, Mahout).
06:27powr-tocwhat unit-test frameworks are people here using? I've been using clojure.test, but suspect there are better options out there now
06:27powr-toce.g. midje or lazy-test
06:27fmwpowr-toc: clojure.test
06:29powr-tocis anyone using anything for mocking? Right now I'm just rebinding and using atoms/futures to assert callbacks are called etc
06:30powr-tocit works ok, but it's a little crufty
06:32fmwpowr-toc: The Joy of Clojure describes a nice with-redefs function for stubbing
06:35fmwpowr-toc: that macro is going to be in Clojure 1.3 (check the release note of alpha 3)
06:37powr-tocfmw: cool I'll check it out
06:39fmwpowr-toc: http://notesonclojure.blogspot.com/2010/06/mocking-with-clojurecontribmock.html
06:41fmwanyway, any hadoop people around to have a look at my earlier question? I'm sure there must be someone, as Clojure seems to be the ideal approach to use the fantastic Apache ecosystem from a sane language (i.e. not Java) ;)
06:43powr-tocahh cool... I'd forgotten about clojure.contrib.mock
06:46thorwili once again have the problem that i would like to feed a macro with a symbol that needs to be expanded. is there such a thing as a runtime macro?
06:47thorwilor any other as-general-as-possible solution to that problem?
06:55Chousuke"runtime macro" doesn't really make sense
06:55Chousukeunless you're using eval, I guess.
06:57Chousukethorwil: anyway, I don't quite understand your problem
06:57hoeckthorwil: do you know that symbol at compiletime?
07:00thorwilhttp://paste.pocoo.org/show/361992/
07:01thorwili can of course write a macro, taking a keys-vector as argument, bu then i need to have that vector right in the call
07:03ChousukeThat's probably the best approach to be honest. Or at least the least tricky
07:05thorwilChousuke: but it's almost useless, as that list is needed in several places; thus i would like to put it behind a symbol
07:05Chousukehttp://paste.pocoo.org/show/361995/
07:05thorwili mean, yes that list is short and copy-pasting it not too painful, but that approach doesn't scale
07:06clgvCan I find out in which macrocall a nested macrocall is?
07:06clgvvia &env or something?
07:07Chousukethorwil: if you really need to, you can define a macro that defines a macro. :)
07:07hoeckthorwil: or write a macro which binds some var at runtime
07:07thorwilChousuke: i tried. i end up shooting own foot ;)
07:08thorwilok, ty now i got things to try
07:08Chousukethen you could do something like (defsnippetmacro foo [keys-here]) (defsnippetfoo ...)
07:09thorwilbtw, macro expansion happens before compilation and is a plain replacement operation? as i wonder what happens with a macro call inside a macro call
07:10Chousukethorwil: the macro call gets replaced by the code it expands to, and that is then expanded again, until there are no changes
07:10ChousukeIf you actually call a macro in a macro (instead of its expansion) then that's expanded when the macro you're defining is compiled
07:14ChousukeKeep in mind that macros are just functions. They just have a special purpose; that is, to generate code.
07:18hoeckthorwil: and that you can create endless recursive expansions which result in a stackoverflow at compiletime
07:24thorwilthe global variable approach doesn't seem to work
07:25thorwilin other variations, i run into "Can't take value of a macro"
08:44bartjhi is there any maintainer of the clojars website here ?
08:48sandGorgoni imported a pure Java class file into clojure. This class has a "private static final String". Can I access this String somehow - even maybe through ns-resolve trickery ?
08:50hoecksandGorgon: maybe using wall-hack-field or writing your own for static fields
08:51raeksandGorgon: since it is public, you should not rely on that it exists. iirc, it is possible to circumvent the access control using java.lang.reflect or maybe something in contrib
08:51raeks/public/private/
08:51sexpbot<raek> sandGorgon: since it is private, you should not rely on that it exists. iirc, it is possible to circumvent the access control using java.lang.reflect or maybe something in contrib
08:53sandGorgonhoeck, thanks for the wall-hack-field pointer. i can get started from there. thanks raek
08:53@chouserit has a more innocuous name in more recent versions of clojure
08:54hoeckchouser: oh, which name?
08:55@chouserIt's less memorable too
08:55raekhttp://clojuredocs.org/clojure_contrib/clojure.contrib.reflect/call-method
08:57@chouserraek: thanks. it always eludes me.
08:58sandGorgonraek, thanks!
08:59@chouserIt's the namespace I can never remember. I always end up digging around in clojure.reflect.java and being disappointed.
08:59clgvIf I have a symbol at runtime. How can I define a variable for it in the current namespace?
08:59@chouser(doc intern)
08:59clojurebotDENIED
09:00@chouser&(doc intern)
09:00sexpbotjava.lang.SecurityException: You tripped the alarm! intern is bad!
09:00@chousersheesh. stupid bots.
09:00clgvconfig
09:00clgvclojure.core/intern
09:00clgv([ns name] [ns name val])
09:00clgv Finds or creates a var named by the symbol name in the namespace
09:00clgv ns (which can be a symbol or a namespace), setting its root binding
09:00clgv to val if supplied. The namespace must exist. The var will adopt any
09:00clgv metadata from the name symbol. Returns the var.
09:00@chouserclgv: that's the one
09:00clgvok thx :)
09:01clgvwhen I want to check for existance "resolve" should work?
09:01clgvs/existance/existence/
09:01sexpbot<clgv> when I want to check for existence "resolve" should work?
09:01@chouserclgv: yep
09:07raekbtw, is there a clojure fn for making a namespace qualified symbol from a (potentially) non-qualified one? (like syntax-quote does)
09:09raeksomething like ##(symbol (name (ns-name *ns*)) (name 'foo))
09:09sexpbot⟹ sandbox10597/foo
09:14clgv##(symbol (name (ns-name *ns*)) (name 'foo))
09:14sexpbot⟹ sandbox10597/foo
09:20fliebelthrush in Python: http://dev-tricks.net/pipe-infix-syntax-for-python ;)
09:24Kjellski1fliebel: Saw that from ycombinator this morning, looks pretty clean =)
09:24fliebelNow, if someone would be so kind to write some immutable datastructures…
09:39clgvfliebel: why? so that you can do immutable single-thread-programming in python? :P
09:46@chouserpersistent collections are a win even in single-threaded code
09:46powr-tocclgv: immutable datastructures are still handy in single threaded programs as they make things easier to reason about
09:46@chouserha
10:12ejacksonoh yeah ! Manning has gotten around to shipping JoC to the foreigners too :D
10:39TobiasRaeder:D i just got a notificatio ntoday aswell
10:43ejacksoni hope mine comes with one of chouser's delicious cookies....
10:48powr-tocRaynes: Nice! ... what's going to make it different from the existing clojure books?
10:48TobiasRaedergogo Raynes! :D
10:48duncanmis there a reason why 0xff works as a literal, but not 0b11?
10:49cemerickduncanm: 0x indicates hex; you want 2r11
10:50cemerick,(= 0xff 16rff)
10:50clojurebottrue
10:50Raynespowr-toc: There will be a free copy available online, for one. Furthermore, it should be 1.3 compatible unless No Starch pushes me into publishing it before then, but even then, it'll have notes about 1.2.
10:50RaynesIt's also more Learn You a Haskellish. More lighthearted than the books already around.
10:51duncanmcemerick: ah.. but the java lang spec says 0b11 is valid also, why isn't that format also supported?
10:52duncanmooh
10:52duncanmmaybe that's a java 7 feature
10:52cemerickyeah, those extended literals are java 7-only
10:52duncanm"The integral types (byte, short, int, and long) can be expressed using decimal, octal, hexadecimal, or binary number systems. (You can create binary literals in Java SE 7 and later.)"
10:52duncanmahh
10:53duncanm0b1010 looks a bit nicer than 2r1010 to me
10:53powr-tocRaynes: cool... if its light hearted are the projects going to be more fun orientated than industry orientated?
10:53duncanmbut i'll have to wait till java 7 ships, then
10:53cemerickduncanm: the literals supported by clojure have nothing to do with java literals, except perhaps the shared legacy
10:53Raynespowr-toc: You'll find no industry oriented material in this book.
10:54duncanmcemerick: well, it says "Numbers - as per Java, plus indefinitely long integers are supported, as well as ratios, e.g. 22/7."
10:54duncanmi'd hope that when Java 7 adds binary literals in the form of 0b...., that Clojure adds the same support
10:54powr-tocyay!
10:55cemerickduncanm: *shrug* The generality of RrXX is an improvement over the legacy notations IMO.
10:55powr-toccemerick, what does the r stand for?
10:55cemerickradix
10:55powr-tocradix?
10:55powr-toclol
10:55cemerick,4r34
10:55clojurebotFor input string: "34"
10:55powr-tocI should really engage my brain before asking
10:56cemerickwhoops
10:56cemerick,4r33
10:56clojurebot15
10:56cemerickIt's sometimes handy to have literals for odd bases
10:57cemerickI've never liked the zero prefix for octals. It takes me a number of extra cycles to parse "043" as octal-43, and not decimal 43.
10:59powr-toccemerick, yeah, that's cool... I'd not known about the radix syntax...
11:00duncanmcemerick: there's something to be said for that too, i suppose
11:03powr-tocw00t unit tests passing again!
11:04Raynespowr-toc: http://blog.raynes.me/?p=94 Shouldn't be all that out of date except for the publishing stuff.
11:34naeuhey there, any cake-heads in here?
11:35naeutasty cake
11:36naeuninjudd: ping
11:38jcromartieI'm still using rake
11:38jcromartienot that they have much to do with one another
11:38naeu:-)
11:38jcromartieexcept that cake is a rubygem
11:39jcromartieI mean, is Ruby the new Perl or what
11:39naeuRuby is the new Cobol :D
11:39naeubut, for sure, Ruby has a fine sweet spot doing shell-like stuff
11:39jcromartieyeah, that's where it's useful for me
11:39jcromartieCake's persistent JVM might convince me though
11:40naeuit's the native library handling that convinced me
11:40naeubut i'm struggling configuring the classpath
11:40naeuit doesn't seem to recognise my cake config
11:40naeuI must be doing something silly
11:42Raynesnaeu: We actually have a channel for cake #cake.clj. However, ninjudd and lancepantz have been very busy with work lately, so it's largely inactive at the moment. If you post your question to the mailing list, you'll probably get an answer within 24 hours or less.
11:42naeuRaynes: thanks, although may I quickly run through what I'm trying to do so you can see if it's sane or not?
11:43RaynesSure. Hop over to #cake.clj
11:57nickikis there something like pprint for strings?
11:58nickiki mean if I have a string with html in it "<h1> <a herf="/"> home </a></h1>" and i would like to see that pritty printed
11:59ephconyou mean printing with indentation?
12:08Licensergood god jain-sip is one horrible librarie :( it is like a prime example of why I hate jave
12:10fliebelWhen exactly is a watcher fn called? Before or after the actual commit? I think I'm having a problem because the watcher fn set some java in motion that runs before the actual thing is committed, and the java code hapily starts using the old value.
12:11ejacksonfliebel: i don't know, but the watcher returns both old and new values, so you might be able to solve your issue this way.
12:11faust45hi guy's
12:12faust45i try make jar for clojure-contrib-1.1.0 but fail can any one help me? http://friendpaste.com/3KbXeP7bPqRb5k2jZutVjy
12:14fliebelejackson: Not really, I do not call the code directly. It's the paintComponent of a JPanel, so there is no way I can get my new value in there.
12:16fliebelejackson: I could try to use another type of shared data that does commit before calling the watcher.
12:16faust45can any one help me with clojure-contrib?
12:16ejacksonthat seems wise
12:16raekfliebel: it should be called when the value has for sure been committed
12:17raekbut when the watch fn is called, the atom/ref/agent value might have changed again
12:17ejacksonfaust45: its not finding any source.
12:17technomancyfaust45: you shouldn't build clojure-contrib; you should get it from build.clojure.org/releases
12:19faust45ejackson: "not finding any source" but why? i just download package from http://code.google.com/p/clojure-contrib/downloads and run "mvn package -Dclojure.jar=../1.3.0-alpha6/clojure.jar"
12:20faust45what's i am doing wrong?
12:20ejacksonfaust45: technomancy is correct. You don't want to build this.
12:20fliebelraek: That does not correspond to my observations. The agent contains objects to be painted, and when changed, the watcher marks these regions dirty. The problem is that when it redraws, it still shows the image in the old location. This makes me think the repainting is done before the agent has actually updated.
12:21ejacksonthe reason is that maven needs specific instructions to know how to build clojure source, using the maven-clojure plugin (or something like this). Its more complex than I understand, sorry.
12:21faust45technomancy: but what i need to download from http://build.clojure.org/releases/org/clojure/ i see many folders here
12:21raekhrm. that might be true for agents
12:22ejacksonfaust45: it used to build with ant I think, dunno anymore
12:22fliebelraek: So using a ref would solve it?
12:22raeksince their updates will never be retried...
12:23raekhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Atom.java#L81
12:24faust45technomancy: did you know http://build.clojure.org/releases/org/clojure/clojure-contrib/1.0.0/ is suitable with clojure 1.3.0-alpha6?
12:24raekan atom will only notify its watchers when the value has been swapped sucessfully
12:24technomancyfaust45: no, that's too old. look in http://build.clojure.org/snapshots instead if you want 1.3-compatible stuff
12:24raekfaust45: most probably not. clojure-contrib contains precompiled code and such code is not binary compatible between versions
12:25fliebelraek: Okay, I'll try atom to see if it's really what it is I think it is… is is...
12:25faust45raek: but how i can build package for clojure 1.3.0-alpha6?
12:26raekfliebel: looks like agents set the state before notifying too: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Agent.java#L118
12:26raekfaust45: what package?
12:26faust45raek: .jar
12:26raekalso, since 1.3, clojure has been split up into modules
12:27raekfaust45: how you make a jar for you own project? someone else's project?
12:27raek*clojure-contrib has been split up into modules
12:28waxrosecavemanHow do you actually connect clojure-contrib with clojure?
12:28ejacksonwaxrose: you list it as a dependency in the project.clj or pom.xml file.
12:29technomancyfaust45: in general building your own jars for things like this is unnecessary; you should just pull in packages others have created with build tools
12:29ejacksonthen (use [coljrue.contrib...] ...) it in your source
12:29waxroseejackson, Thanks. What about for the REPL?
12:29ejacksonwaxrose: it still needs to be on the classpath, leiningen puts it there for you.
12:30waxroseOkay, cool.
12:30raekwaxrose: you do that step, and then run "lein repl" or "cake repl" depending on what build tool you use
12:30ejacksonat the repl you can type (use 'clojure.contrib.repl-utils), and if it works, then you have it on the classpath
12:30faust45raek: so i need setup dependency xml file with reference to http://build.clojure.org/snapshots/org/clojure/contrib/
12:30waxroseThanks guys. Helpful as always. :D
12:31fliebelraek: Okay, the problem lies somewhere else, it persist with atoms.
12:31raekfaust45: what build tool are you using?
12:31faust45raek: mvn
12:32waxrosetechnomancy, You mentioned to me a REPL for Android that is far from development. I actually installed a REPL from the market that is using 1.2 yesterday and it seems to work very well on my phone.
12:33raekfaust45: I haven't used maven for clojure myself, but maybe this is useful: http://dev.clojure.org/display/doc/Getting+Started+with+Maven
12:33fliebelraek: Weird eh? http://yfrog.com/h8zqrp
12:33raekit has an example pom.xml file
12:34raekfliebel: funky.
12:36technomancywaxrose: it's "usable" but not usable to build regular applications with.
12:36fliebelraek: Those squares are just to signify there has been a redraw, but the black stuff (only Y!) is leftover image.
12:37waxroseTrue, but it's nice to at least mess around with while in class so I don't have to actually pay attention to my professors.
12:37faust45raek: but what you using for run clojure?
12:37raekleiningen
12:37raekfaust45: https://github.com/technomancy/leiningen
12:38faust45raek: thanks for help
12:38raekit has a nice tutorial too: https://github.com/technomancy/leiningen/blob/stable/TUTORIAL.md
12:39waxroseDoes anybody know what the deal with The Joy of Clojure? They seem to have pushed the date back of it's print release or B&N must have used an incorrect date.
12:39waxrose:/
12:40Licenserwaxrose: I think it was just shipped
12:40Rayneswaxrose: AFAIK, a lot of people have confirmed that it has already been shipped to them.
12:40RaynesOver the past few days.
12:40waxroseIs that just from purchases from manning though?
12:41RaynesI suppose.
12:41Licenseraloa Raynes :) long time no see
12:41RaynesHi there.
12:41waxroseBecause I work at B&N and there seems to be some issue at B&N.
12:41Rayneswaxrose: You could just wait for another 10 months or so and buy my book! :>
12:41waxroseRaynes, Which is? :P
12:42RaynesI've only been to a B&N twice in my life. I don't live near one.
12:42RaynesMeet Clojure
12:42waxroseOh, I didn't hear about that one yet. Will it be on manning as well?
12:43RaynesNope. No Starch. I haven't actually signed the contract yet, so the only real announcement was on my blog a while back.
12:43waxroseOh, I like No Starch. I'll most def buy it when it comes out!
12:44Raynes<3
12:44HavvyMy Inferior Lisp program: java -cp C:/clojure/clojure.jar;C:/clojure/clojure-contrib.jar;C:/Havvy/Code/src clojure.main
12:44HavvyI've a file at C:/Havvy/Code/src/com/havvy/converter.clj
12:44waxroseRaynes, Best of with it. :D
12:44Havvy(load "com.havvy.converter") fails with the error java.io.FileNotFoundException: Could not locate com.havvy.converter__init.class or com.havvy.converter.clj on classpath: (NO_SOURCE_FILE:0)
12:45HavvySo how can I load the file C:/Havvy/Code/src/com/havvy/converter.clj ?
12:45hiredman,(doc load-file)
12:45clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
12:46waxroseRaynes, Opps, I meant best of luck with the book.
12:46nickikRaynes, do some more. How do you think your book will compair the others. I mean there are a lot of books coming out. Stu just signed for 2. Edition.
12:47RaynesI think the biggest difference will be the tone of my book. If you've read Learn You a Haskell, you can expect a similar tone in my book.
12:48RaynesIt's true, I have a lot of competition, but I think variety is good, and No Starch doesn't seem to be worried at this point.
12:48waxroseCompetition usually brings out the best of people. That or suicide. >.<
12:48RaynesHeh
12:49raekHavvy: 'load' expects slashes instead of dots and underscores instead of dashes
12:49raek(it's a lower-level operation)
12:50waxroseRaynes, Maybe similar to also maybe Land of Lisp?
12:50Havvyhiredman, raek: Thanks so far.
12:50Rayneswaxrose: I suppose, but probably not as intense or as wild as Land of Lisp.
12:51raekHavvy: also, I'd recommend to use slime, leiningen and swank-clojure
12:51waxroseNot sure if anything can be as wild as _why's poignant guide to Ruby, but nice to know.
12:51nickikis Meet ... a naming convention to (like joy of ....., ... in action from manning)
12:51Havvyraek: Yeah, I see that everywhere. >_>
12:52raek(it simplifies interactive development and handles the classpath for you)
12:55HavvyI wish to understand how classpath works before I regalate it to another app.
12:57raeka very good thing to do... I just wanted to make you aware of the more convenient options :-)
12:59Raynesnickik: Meet Clojure was just a random working title when I started the book. I planned on coming up with a more clever name, but that didn't end up happening and everybody seems to like Meet Clojure.
13:00nickikYeah its a nice name, better then programming clojure or clojure programming :)
13:00ejacksoni find that i'm being programmed by clojure...
13:01waxroseejackson, Clojure Matrix
13:23fliebelHuh? Updating :x in a record in a set cause the watcher to be called, updating :x does not!
13:23mattmitchellI'm getting a result set back which has this: {:count(*) 5} -- how do i access the value of :count(*) ?
13:24fliebel(make that last one :y)
13:28amalloy&(keyword "count(*)")
13:28sexpbot⟹ :count(*)
13:29amalloymattmitchell: though a nicer solution is to modify your sql to be like SELECT COUNT(*) AS cnt ...
13:29mattmitchellamalloy: ahh good point :)
13:29fliebelThis seems to be a bug, or a feature in PersistentTreeSet. When I sort on both :x and :y, it does update!
13:38BleadofIf I have a _ in defmacros parameter list, what does it mean?
13:39hiredman_ is a normal symbol, but by convention it means whatever it is bound to is not used
13:41BleadofSo it's there for readability?
13:41BleadofIndeed
13:41BleadofNow it makes sense
13:43Bleadofhiredman, thanks :)
13:49amalloy&((fn [a a] a) 1 2)
13:49sexpbot⟹ 2
13:52__name__o_O
13:52amalloy__name__: it makes sense if you remember that arglists are just the first half of a let binding
13:52amalloy&(let [a 1, a 2] a)
13:52sexpbot⟹ 2
13:53__name__yeah, but it seems somewhat counterintuitive for function declarations.
13:54amalloy__name__: (fn [_ _ data-i-actually-want] ...)
13:54fliebelIs this expected behavior? ##(sorted-set-by #(compare (:x %1) (:x %2)) {:x 1 :y 2} {:x 1 :y 3} {:x 2 :y 2})
13:54sexpbot⟹ #{{:x 1, :y 2} {:x 2, :y 2}}
13:54amalloyfliebel: yes, sadly
13:55amalloyif your comparator says that two keys are equal, they can't both be in the set
13:55fliebelamalloy: Oh, okay. I solved it by sorting on all the keys I need, but it's weird.
13:56amalloyfliebel: it actually couldn't work the other way, i think
13:56HavvyUhg, this client is so unreable.
13:56Havvy*unreadable
13:56amalloybecause if someone asked you to look up {:x 1 :y 3}, and you (the computer) got to the {:x 1 :y 2} node, which direction would you go down the tree to keep looking?
13:57amalloyit can't be left or right of the current node cause the comparator returns 0, and it's not the current node, so...
13:57__name__amalloy: Yeah, makes sense :)
13:58fliebelamalloy: I see… Well, I guess you could make the leaf nodes seqs of items, and do hashCode stuff there. I expected it to work like ##(sort [3 2 1 2])
13:58sexpbot⟹ (1 2 2 3)
13:59amalloyfliebel: hashcode and equals have to correspond: if two items compare as equal, they are required to have the same hashcode
13:59amalloybecause, after all, they're equal :P
14:00fliebelBut on the other hand, I kind of like this. I am having "unstable" Java stuff in the other keys, so this way, I know for sure it only compares on :x and :y
14:00amalloyof course that's not true when you pass in a separate comparator, so maybe that could be made to work. but there's no reason that the duplicated keys would be leaves
14:33Havvyhttp://pastebin.com/d98tnXKW << I get :no-test when I do (test com.havvy.converter/arr)
14:40amalloyHavvy: i don't know the clojure test apis very well. where's the doc for the test function you're calling?
14:41raek,(doc clojure.core/test)
14:41clojurebot"([v]); test [v] finds fn at key :test in var metadata and calls it, presuming failure will throw exception"
14:41vitahi everyone...I have a problem with java interloop... my function is receiving list of arguments to call some java method on java object...basically I want to do something like (. "abc" substring '(1 2))
14:41raekit follows the convention of clojure.test
14:41vitabut apply can't be used
14:42vitais there any way to expand list and to call java method?
14:42raekvita: yes: (apply #(.substring "abc" %1 %2) [1 2])
14:42amalloy$source test
14:42sexpbottest is http://is.gd/88CJC9
14:42raekyou have to wrap the method in a function
14:43amalloyyou probably need to call (test #'arr), not (test arr)
14:43raeksince jvm methods are not first class (without reflection)
14:43Havvyamalloy: That does it. But why?
14:44vitathanks!! but is there any way to dynamically do that for function with n args? sometimes it is passed 2 sometimes more...i am passing java method and arg list of variable size
14:44amalloyHavvy: ##(map meta [first #'first])
14:44sexpbot⟹ ({:line 53} {:ns #<Namespace clojure.core>, :name first, :file "clojure/core.clj", :line 48, :arglists ([coll]), :doc "Returns the first item in the collection. Calls seq on its\n argument. If coll is nil, returns nil.", :added "1.0"})
14:44amalloythe function itself rarely has much useful meta; most of it is on the var object
14:45raekvita: java methods that are variadic actually take an array as its last arg on the jvm level
14:45raek,(String/format "%d%d%d" (into-array [1 2 3]))
14:45clojurebot"123"
14:46HavvySo (test arr) looks at the actual function while (test #'arr) looks at the var holding the function?
14:46amalloyHavvy: indeed. ##(macroexpand '#'arr)
14:46sexpbot⟹ (var arr)
14:46raekbut for only a fre fixed arities, you'd need to do something like (fn ([o] (.foo o)) ([o x] (.foo o x)) ([o x y] (.foo o x y)))
14:47HavvySo is it possible to put metadata on the function itself and not the var holding the function?
14:47amalloyHavvy: sure, but you probably don't want to for this
14:47HavvyMetadata as a language feature is very interesting none-the-less.
14:48vitai know that...bu methods that I call are not variadic... i'm constructing clojure api for some java library...and creating some utility methods to do that.. so i receive the java method name as paramether and list of arguments for that method..and I want to call that method. thanks a lot for help...this idea with anonimous fn is great
14:48amalloyHavvy: yeah, i've found a couple uses but it seems to require a lot of experience to recognize when it might be useful
14:48raekit is possible to make a macro that uses reflection to build that anonymous fn... :-)
14:49HavvyThank you very much for the help with that. Now I can write unit tests easily.
14:49amalloy&(meta (with-meta {:type :awesome} (constantly 1)))
14:49sexpbotjava.lang.ClassCastException: clojure.core$constantly$fn__3551 cannot be cast to clojure.lang.IPersistentMap
14:49amalloydang it, i always get those backwards: ##(meta (with-meta (constantly 1) {:type :awesome}))
14:49sexpbot⟹ {:type :awesome}
14:51dakroneb
14:53Havvyamalloy: Try thinking "With meta 'meta' apply to 'form'."
14:54amalloyHavvy: that's the wrong order :P.
14:54HavvyOh. :P Everything looks the same in this client. X.X
14:56vitaok...i have found another way.to solve this......idea with anonimous fns was good:)
14:56vitathanks ;)
14:57mattmitchellWhat's the best way to remove specific items from a vector?
14:58gigamonkeyWhat's the relationship between defprotocol and defmulti?
14:58gigamonkeyI.e. does defprotocol implicitly do a bunch of defmulti's?
14:59raekgigamonkey: no implicit relashionships
14:59amalloymattmitchell: by not using vectors :P
14:59amalloyor, ##(remove #{1 5 7} (vec (range 10)))
14:59sexpbot⟹ (0 2 3 4 6 8 9)
15:00amalloygigamonkey: defprotocol uses java inheritance
15:00raekmattmitchell: you can use subvec to pick out the parts to the left and right of the element, and the 'into' the right one into the left one, but that runs in linear time
15:00amalloymaking it a more limited, faster version of defmulti
15:00gigamonkeyAh, I see, so protocols are single-dispatch only.
15:00raekprotocols have some additional stuff outside the regular java stuff to make them more dynamic, though
15:01cemerickgigamonkey: yes, and only on the concrete type of the first arg; no dispatch fn anywhere
15:01mattmitchellamalloy: thanks!
15:01thorwilhmm, how to escape an &nbsp; (that will be passed as string to a enlive transformation)?
15:01sritchie&(reduce + (map (fn [x] (* x x)) (range 10)))
15:01sexpbotjava.lang.NullPointerException
15:01sritchiewhy does that give a nullpointerexception?
15:02raekgigamonkey: stuarthalloway explains this very good in this video: http://vimeo.com/11236603
15:02amalloysritchie: does it give an NPE outside of sexpbot?
15:02amalloyoh i bet i know
15:02sritchieit gives 285
15:02sritchiein the repl
15:02amalloysomeone used findfn and accidentally deleted +
15:03raekthorwil: enlive should do html escaping automatically
15:03amalloy$login
15:03sexpbotYou've been logged in.
15:03amalloy$reload
15:03sexpbotReloaded successfully.
15:03amalloy&(reduce + (map (fn [x] (* x x)) (range 10)))
15:03sexpbotjava.lang.NullPointerException
15:03amalloysigh
15:03sritchie&(reduce * (map (fn [x] (* x x)) (range 5)))
15:03sexpbot⟹ 0
15:03sritchiehaha, oh yeah, whoops
15:03sritchie&(reduce + (map (fn [x] (* x x)) (range 1 10)))
15:03sexpbotjava.lang.NullPointerException
15:03sritchie&(reduce * (map (fn [x] (* x x)) (range 1 5)))
15:03sexpbot⟹ 576
15:03sritchie&(reduce + 1 (map (fn [x] (* x x)) (range 1 5)))
15:03sexpbotjava.lang.NullPointerException
15:04raekthorwil: ...by using 'content' instead of 'html-content', which does not do escaping
15:04amalloy&(reduce + 1 (map (fn [x] (* x x)) (range 1 5)))
15:04sexpbot⟹ 31
15:05thorwilraek: i found that it will write out "&nbsp;", but using "/240" seems to work to get a space into the html
15:05mattmitchellhow can i compare two hash-maps, where if all keys are present in both maps, with the same paired values, the result would be true...
15:05thorwilraek: oh well, i'm using content already
15:05raekthorwil: in addtion, you can type that character in your strings with "\u00a0"
15:05amalloymattmitchell: that sounds like = to me
15:06mattmitchell,(= {:id 1 :name "sam"} {:name "sam" :id 1})
15:06clojurebottrue
15:06mattmitchellahh :)
15:06mattmitchellok
15:06thorwilraek: thanks!
15:07sritchie$botsnack
15:07sexpbotsritchie: Thanks! Om nom nom!!
15:07sritchieamalloy: cool, thanks
15:08cgrayhi, is there any way to have the same name for two different functions in two different namespaces?
15:08cemerickcgray: that's what namespaces are all about :-)
15:09cgraycemerick: that's what I thought :)
15:09cgraybut I have (ns foo.bar) and (ns foo.baz (:require [foo.bar :as bar]))... both have quux as a function, and I get problems compiling
15:10cemerickcgray: you'll have to be more specific
15:10amalloycgray: restart your repl and/or swank?
15:11amalloyit's not unlikely that you had a broken require/use earlier that's still in the way
15:11HavvyThe REPL is awesome BTW.
15:11cgrayerror: java.lang.IllegalStateException: quux already refers to: #'foo.bar/quux in namespace: foo.baz
15:11HavvyHow do you end it without closing the buffer?
15:12cgrayamalloy: i'll try that
15:13cemerickcgray: assuming a REPL restart fixes your issue, you could have gotten there without a restart using ns-unmap
15:14cgrayno, restarting the repl just made the problem different :)
15:14Havvy,doc ns-unmap
15:14clojurebotjava.lang.Exception: Can't take value of a macro: #'clojure.core/doc
15:14amalloy(doc ns-unmap)
15:14clojurebot"([ns sym]); Removes the mappings for the symbol from the namespace."
15:15cgrayoh, I see the problem now, I had circular requires
15:15HavvyCan that be used to remove a dynamically created var?
15:16amalloyHavvy: the answer to your question is yes, but i don't actually understand the question
15:18HavvyMy "Learn LISP" program is a program that dynamically creates functions that converts data from one type to another so that if you have a converter a=>b and b=>c, it will create a=>c automatically. For testing purposes, I'll need to unbind the created functions.
15:18raekns-unmap and remove-ns can be used to remove (accidentally) introduced vars and namespaces
15:18Havvy(doc remove-ns)
15:18clojurebot"([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace."
15:20fliebelI thought sets where seqs to? UnsupportedOperationException nth not supported on this type: PersistentTreeSet
15:21raekneither maps, vector not sets are seq
15:21raeks
15:22raek,(map seq? (list 1 2 3) [1 2 3] #{1 2 3} {:a 1, :b 2})
15:22clojurebotjava.lang.IllegalArgumentException: Wrong number of args (4) passed to: core$seq-QMARK-
15:22raek,(map seq? [(list 1 2 3) [1 2 3] #{1 2 3} {:a 1, :b 2}])
15:22clojurebot(true false false false)
15:22Havvy,(seq #{1 2 3})
15:23clojurebot(1 2 3)
15:23amalloyfliebel: they're seqable, but not seqs
15:24fliebelwell, of course… I should know these things by now… I thought the data structures page said so, but looking at it, it just says "Sets are collections"
15:24raeksets are not sequential collections, so therefore they don't support nth
15:24amalloy&(let [[a b] (seq #{1 2 3 4})] b)
15:24sexpbot⟹ 2
15:24raek,(map sequential? [(list 1 2 3) [1 2 3] #{1 2 3} {:a 1, :b 2}])
15:24clojurebot(true true false false)
15:25raekhrm
15:25amalloyraek: eh?
15:25fliebelraek: What about sorted-set?
15:25raek,(nth {:a 1, :b 2} 0)
15:25clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
15:25amalloyfliebel: no
15:25fliebel&(sequantial? (sorted-set 1 2 3))
15:25sexpbotjava.lang.Exception: Unable to resolve symbol: sequantial? in this context
15:25fliebel&(sequential? (sorted-set 1 2 3))
15:25sexpbot⟹ false
15:26amalloyarguably they *could* be marked as sequential, because there is a clear order, but that would have some bad side effects elsewhere i suspect
15:26fliebelamalloy: Like what?
15:27raekI think this has been discussed on the clojure-dev list recently
15:27amalloyfliebel: code that assumes (conj foo bar) will make foo longer if it's sequential, for example
15:28fliebelhm
15:29fliebelUh, is there any wait to make iterate behave? I mean, make it stop sometime. Or do I really need to wrap it in take?
15:29amalloyfliebel: take-while is about it
15:29raekreminds me of unfold
15:29amalloyi do have an "iterations": https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils.clj#L20
15:30amalloyraek: yeah, they're pretty closely related
15:37amalloyfliebel: is the above close to what you wanted?
15:45cgrayis there a way to have something run at the beginning of the program, but not when being compiled?
15:46fliebelamalloy: Exactly what I needed, just get all the restses.
15:46raekcgray: it can be a good idea to keep that code in a (defn -main [...] ...)
15:47cgrayraek: ok, thanks
15:48raekthen you can use it with "lein run", generate a main class, etc
15:48cgrayraek: it's a servlet... will it still be run?
15:49fliebelSweet! Detecting collisions for 50 objects in 5ms
15:50cgrayraek: well, it compiles, so I'll give it a try :)
15:53raekcgray: it will not run automatically by compiling it, nor bt loading it
15:54cgrayahh, so is there something that will run automatically when it is loaded, but not when it is compiled?
15:55raekno, loading and compiling is mostly the same thing
15:55raek(unless you do Ahead Of Time compilation)
15:55raekcgray: if you have a repl, start the servlet by running the -main function
15:55cgraythat's what i'm doing
15:56cgrayi'm running on google app engine
15:56raekah, you're generating a jar file?
15:56cgrayyeah
16:08fliebelWeee! http://yfrog.com/h4i2zjp
16:21@chouserfliebel: colliding ... satellites?
16:22fliebelchouser: Yea, aren't they pretty? haha, I just made collision detection for my Clojure game(engine)
16:23powr-tocDoes anyone here know how to adjust emacs layout rules for clojure? Indentation seems to indent to the first function arg, which is often too much (especially if the function name is long)
16:23powr-toc?
16:24hiredman((partial some-fn first-arg) arg2 arg3) is a indentation hack I am not above using
16:24hiredman(for which I will burn)
16:24@chouserha!
16:25@chouserhiredman: I had to read that at least 3 times to understand what your point, but that is, indeed, worthy of a burning.
16:26@chouserfliebel: snake!
16:26fliebelchouser: Where? *googles*
16:27fliebelhttp://java.ociweb.com/mark/programming/ClojureSnake.html
16:27dnolenfliebel: somebody had built a fairly fleshed out strategy game in Clojure, I recall 7K LOC or something.
16:27dnolenfliebel: Penumbra has several games in it Tetris, Asteroids, Pong
16:27fliebeldnolen: Name?
16:28dnolenall deliciously short
16:28dnolenfliebel: check the ML, don't recall.
16:28brehautfliebel: brian carper was working on a little rpg at one point
16:28hiredmanspeaking of the ml http://groups.google.com/group/clojure-dev/browse_thread/thread/317dcc7e41549579
16:28fliebeldnolen: I'm using Swing, for which I shall burn together with hiredman
16:29@chouserfliebel: epic snake thread from yesteryear: http://groups.google.com/group/clojure/browse_thread/thread/2a23a95bf22938a3/5873af042715e59d
16:29brehautfliebel: http://briancarper.net/blog/520/making-an-rpg-in-clojure-part-one-of-many
16:38fliebelbrehaut: Thanks for that. Very good to know I'm not alone. But in fact, I *am* using agents and all. Hopefully cemerick was right in his comment.
16:45amalloydnolen, fliebel: i think that strategy game had the word iron in the name
16:46b6nHi, is there a way to get a list of functions loaded by a load-file call?
16:46amalloyhttp://groups.google.com/group/clojure/browse_thread/thread/ff18795390b5960b
16:46amalloyironclad
16:47fliebelamalloy: thanks :)
16:52mec_How do i get java to use the jdk instead of the jre?
16:53technomancyb6n: no, but you can list all the top-level vars in a namespace, which is a higher-level version of that
16:57mec_Or rather, when I install the jdk, why does it also install and use the JRE instead
17:01b6ntechnomancy: my intention is to load a .clj file from somewhere and call some of its functions which have some special meta data. So I maybe don't know the namespace defined there. Do I have a chance to do that?
17:01technomancyb6n: load-file is very low-level; it's much better to work in terms of namespaces with use and require.
17:02technomancyI'm not sure if that's doable with just load-file
17:07amalloytechnomancy: maybe (let [forms (read the file) vars (doall (filter var? (map eval forms)))] ...now vars is all the vars defined...)
17:08b6nI thought about filtering what (all-ns) would provide me
17:15b6ntechnomancy, amalloy: thanks guys I think I'll try my luck with a mixture of your answers. :-)
17:15technomancyb6n: are you ben black?
17:16jolyYay, Manning shipped my JoC copy this morning!
17:17b6ntechnomancy: no I'm not ben black
17:17technomancyah ok, different b6n
17:21b6nAnd I thought it would be innovative… ;-)
17:43powr-toctechnomancy: I'm using clojure-test-mode and find its recommendations for C-t working a little odd... i.e. to put the files in test/foo/bar/test/baz.clj ... why not put the test first in the package name and be done?
17:44powr-tocs/for/to get/
17:44sexpbot<powr> technomancy: I'm using clojure-test-mode and find its recommendations to get C-t working a little odd... i.e. to put the files in test/foo/bar/test/baz.clj ... why not put the test first in the package name and be done?
17:44powr-tocha cute! :-_
17:45powr-tocs/:-_/:-)/
17:45sexpbot<powr> ha cute! :-)
17:52@chouseris there something like clojure's constantly in ruby?
17:58technomancychouser: I doubt it. try explaining why you would want such a thing to a rubyist and see what kind of reaction you get. =)
17:58technomancypowr-toc: I'm not all that satisfied with the C-t behaviour myself, but you can adjust where it inserts the "test" segment
17:59technomancyclojurebot: why can't you do things like (describe-variable clojure-test-ns-segment-position) ?
17:59clojurebotNo entiendo
18:00technomancyhiredman: when is clojurebot going to learn about elisp?
18:02hiredmantechnomancy: later
18:09raekhrm, does the JVM enforce that methods only throw checked exceptions if has declared so, or is this just Java?
18:09hiredmanjust java
18:16powr-toctechnomancy: cool... how do you do that?
18:16amalloyhiredman: really? so you could write some jvm assembly to throw an IOException from a method that doesn't declare it, and it would verify?
18:16powr-tocI couldn't see anything in customize
18:17hiredmanamalloy: yes
18:17hiredmanamalloy: rich just yanked all declared exceptions out of clojure for 1.3
18:17amalloyhiredman: i think he did that by wrapping them in runtime exceptions though
18:17hiredmannope
18:17hiredmanhe did that to stop someone else from wrapping them in runtime exceptions
18:18hiredmanwrapping is bad, no way rich would do that unless force to
18:20powr-tocamalloy, I heard about that change, but don't really understand what it means or refers to... Clojure doesn't have checked exceptions anyway... so I'm guessing its something else...
18:23hiredmansome exceptions are generated in java source code, so they had to be changed to be runtime exceptions, but clojure code can do either
18:27powr-tochiredman: so what's the difference for day-to-day use? You can no longer catch a specific exception type?
18:29technomancypowr-toc: I don't usually use customize; you can setq it
18:29hiredmanpowr-toc: you can do whatever you want, you just can't depend on not getting checked exceptions
18:31powr-tochiredman: can't depend on getting, or cant depend on not getting?
18:33powr-tocsorry ... being dumb
18:44duncanmraek: is that a book?
18:45duncanmthis must be an FAQ, is there a reason why the clojure compiler requires everything be forward referenced?
18:46duncanmit always bothered me some that i had to order my functions in the order that they're used
18:46duncanmoh, i found it
18:46duncanmthe explanation
18:46brehautduncanm: link?
18:47raekftp://ftp.dina.kvl.dk/pub/Staff/Peter.Bertelsen/jvm-semantics.ps.gz
18:48raekduncanm: I'm curious, what did you find?
18:49duncanmhttps://groups.google.com/d/msg/clojure/Xv5jJmKzGBI/oaUcFEL2EcIJ
18:50duncanmraek: that guy is worth reading? the info is solid?
18:50duncanmhmm
18:50duncanmi see, it's that sort of 'semantics'
18:50duncanmit's not really my cup of tea ;-P
18:53brehauthuh, i dont recall ever seeing an *exports* declaration in a clojure library (mentioned in the post duncanm linked); what happened to that convention?
18:54duncanmbrehaut: most likely it's put on hold
18:54duncanmi suppose you can use defn- for all the 'private' members, right?
18:54brehautyeah or ^:private
18:54duncanmany Scala programmers here?
18:55duncanmi started looking into Scala, particularly for their Scala Swing package
18:55duncanmit'd be fun to see if there's anyone else interested in doing some hacking to get a nicer API for writing Swing in Clojure
18:56duncanmit's a simple one, but having (defaction ...) could be nice
18:56duncanmi dunno if it makes sense to do defjcomponent
18:58brehautduncanm: perhaps have a browse through http://stuartsierra.com/tag/swing. in particular 'agents of swing'
18:59duncanmbrehaut: yeah, that's from a while ago
19:00duncanmbrehaut: i think it'd be interesting to have a defaction that returns an instance that implements both Swing's Action and Clojure's IFn
19:02duncanmi suggested SAM-conversion on IRC before, and Rich responded and shot it down
19:02duncanmbut now that it's planned for Java 7, or 8, maybe clojure should have it also
19:03brehautthats a dubious logic to follow ;)
19:03amalloyduncanm: Raynes is just in the middle of starting to do a swing library
19:03Raynesamalloy: Oh man, that thing isn't going to see the light of day for months probably.
19:03duncanmRaynes: let's do it!
19:03amalloyor i guess he's just in the beginning of starting. can't really be in the middle of the beginning
19:04RaynesDon't go getting peoples hopes up yet. Now that I have to get my ass in gear on this book, I'm not going to have much time for projects.
19:04RaynesEspecially new ones.
19:04duncanmRaynes: maybe we should talk sometime, i'd like to get some ideas
19:05RaynesSounds like fun. :>
19:05duncanmRaynes: i've been wanting to write something to make swing hacking nicer for a while
19:05duncanmseeing the Scala Swing stuff really got me excited
19:05duncanmi even bought the Scala to learn Scala, mostly just because I want to use Scala Swing
19:05duncanmthe Scala Book
19:05RaynesHeh.
19:05duncanmbut man, that's a complicated language
19:06duncanmi'm too lazy to learn where all the implicit blocks are allowed
19:06duncanmand that's only syntax
19:06duncanmi dunno, maybe someone else here could set me on the right path
19:06duncanmRaynes: i like this (def-action ...) idea a lot
19:07amalloyRaynes: dude, you were the one who tweeted it, and claimed i was helping you with it, before you had any ideas or code. no complaining that *i'm* promoting it too soon
19:07duncanmi realized that defaction looks a lot like defecation
19:07__name__defaction could be de-faction, the opposite of faction!
19:09duncanmRaynes: oh, this shoes thing could be interesting
19:15duncanmboo
19:16duncanmi had hoped that (inspect clojure.lang.IFn) would give me a nice swing dialog with all the members
19:18duncanmla la la
19:20sritchie_there we go
19:20sritchie_whoops, sorry, wrong group :)
19:26hiredmanIFn is a pretty sparse interface
19:27hiredmanmostly just invoke in a billion arities
19:31euguchouser: with Enumerators in ruby 1.9 it's possible to emulate lazy sequences in ruby, see my take at constantly http://pastie.org/1733176
19:32duncanmhmm, my copy of Joy of Clojure will arrive tomorrow
19:32duncanmi was reading a bit of it on my nook
19:40duncanmwhoa
19:40duncanmpdlogan = patrick logan?
20:06joshua__&find_fn "123" "1" true
20:06sexpbotjava.lang.Exception: Unable to resolve symbol: find_fn in this context
20:06joshua__find_fn "123" "1" true
20:06joshua__$find_fn "123" "1" true
20:06brehaut$findfn "123" 1 true
20:06sexpbot[clojure.core/not= clojure.core/distinct? clojure.core/contains?]
20:07joshua__brehaut, .. the sad thing is that I'm the one who wrote that plugin...
20:07brehautjoshua__: haha :)
20:08joshua__(def in? contains?) good idea/bad idea?
20:10amalloyjoshua__: evil
20:10joshua__amalloy, but it is more concise and expresses the same concept =/
20:10amalloy(says the guy who has (defalias ! complement))
20:11amalloyi mean, i guess it's fine. as long as you're doing it to save typing, and not because the name contains? is confusing
20:11pdk(doc defalias)
20:11clojurebotNo entiendo
20:12joshua__Guys, I'm learning Spanish.
20:12joshua__The bot said he doesn't understand.
20:12joshua__That is all.
20:13Deranderjoegallo: muy bien
20:13pdkohhh que pena es esto
20:13amalloyDerander: ¿quieres decir joshua?
20:14Deranderamalloy: ¿Decirte que?
20:14Deranderoh
20:14Derander
20:14Deranderjoshua__: see above for random spanish response
20:14Deranderjoegallo: sorry for random spanish
20:30joegalloDerander: I was so excited that my name was mentioned in here, but now I'm muy disappointed.
20:30joegallo:)
20:33Deranderjoegallo: lo siento señor
20:34RaynesIs there a 1.3 changelog lying around anywhere?
20:39mechttps://github.com/clojure/clojure/blob/master/changes.txt
20:39joshua__$findfn "123" "1" true
20:39sexpbot[clojure.core/not= clojure.core/distinct?]
20:40Raynesmec: Duh. Thanks.
20:44amalloy$findfn "123" \1 true
20:44sexpbot[clojure.core/not= clojure.core/distinct?]
20:44amalloybmph
21:17mecany chance 1.3 will have unsigned bit shift?
21:22brehautmec: the jvm has no unsigned types, so it seems unlikely
21:28amalloyit's not hard to write an unsigned shift, but as brehaut says there are no unsigned primitives, so it wouldn't be fast
21:37joegallojava has a >>> for unsigned shift right, which doesn't seem to have a clojure equivalent
21:37joegallothat is, it shifts a zero into the leftmost position
21:39joegalloi don't see why it wouldn't be fast to just call through to that
21:49joegallo>>> seems to be supported by the iushr and lushr opcodes at the jvm level
22:00RaynesLicenser: You wouldn't happen to be around, would you?
22:10amalloyjoegallo: i didn't know java had >>>; i suppose i've never needed it
22:11joegalloYou and most of the rest of the world. ;)
22:11joegalloI've never needed it either.
22:11joegalloJust one of those little trivial edges out there.
22:18amalloyi just wish java would go ahead and get unsigned types
22:18joegallothat would be awesome
22:38joegalloQuick implementation of unsigned-bit-shift-right, passed the lamest of manual tests https://github.com/joegallo/clojure/tree/unsigned-bit-shift-right
22:38joegalloalmost certainly wrong in some way
22:40joegallothe interesting thing to this is that BigIntegers don't support unsigned shift right, as there is no fixed register size for their abstraction, my implementation just make unsigned-bit-shift-right behave as bit-shift-right for BigIntegers. alternatively, you could get more clever by doing something else.
22:59amalloyjoegallo: not clear what would be more clever. 0, followed by infinite ones?