#clojure logs

2011-06-10

00:22amalloymattb[]: the amount of code generated bymacros is stupendous
00:24amalloyfor example, see ##(macroexpand-all '(for [x xs y ys] [x y]))
00:24sexpbot⟹ (let* [iter__4063__auto__ (fn* iter__10212 ([s__10213] (new clojure.lang.LazySeq (fn* [] (loop* [s__10213 s__10213] (if (clojure.core/seq s__10213) (do (let* [x (clojure.core/first s__10213)] (let* [iterys__4059__auto__ (fn* iter__10214 ([s__10215] (new clojure.lang... http://gist.github.com/1018221
00:24mattb[]haha wtf
00:25dnolenmattb[]: pshaw! https://gist.github.com/1018223
00:26mattb[]wtf...
00:26brehautdnolen: win
00:27brehautmattb[]: macros ~= writing a little bit of the compiler yourself
00:27amalloymattb[]: the point is, it's nice to be able to build language features like this yourself instead of having them baked into eg gcc where you can't even understand them
00:27mattb[]sure
00:28mattb[]where are they located?
00:28amalloymattb[]: well, for is a builtin in clojure.core
00:28amalloy~source for
00:28amalloydnolen's is nonsense of his own imagining
00:28mattb[]haha
00:29dnolenhey!
00:29mattb[]how much of clojure is written in clojure?
00:29dnolenmattb[]: not much at the moment, but work is being done to have most of it done in itself. thus deftype/record
00:30mattb[]and there's a performance benefit to that?
00:30amalloydnolen: i think "not much" isn't accurate. clojure.core isn't as large as clojure.lang, but there's a lot of it
00:31mattb[]hah "and" is a macro
00:31dnolenmattb[]: no perf benefits, portability benefit.
00:31mattb[]ah
00:32dnolenin fact most certainly Clojure ports will be much slower than Clojure on the JVM for a very long time.
00:35mattb[]so a ref p is essentially a pointer, and alter changes the pointer rather than the pointee, correct?
00:38amalloyerrr?
00:38mattb[]lol
00:39amalloybut i think that's reasonably accurate
00:39mattb[]in reference to (again with the defunct demo) "(alter p assoc :ant a)"
00:39dnolenmattb[]: Clojure reference types aren't just pointers, they all have state management semantics. refs are designed to work with the STM, you can't change a ref outside of a transaction.
00:39mattb[]aye dnolen
00:40mattb[]but you never actually change the pointee, right?
00:40mattb[]you change the pointer in a transaction
00:40dnolenmattb[]: done properly there's no such thing as changing the pointee either, immutable data structures and all that.
00:40mattb[]aye
00:41amalloy&(let [r (ref 1) v1 @r] (dosync (alter r inc) [v1 @r])))
00:41sexpbot⟹ [1 2]
00:41amalloymattb[]: ^?
00:42mattb[]so @r is immutable still
00:42amalloyyep
00:43mattb[]so if I ran this 1000 times would I have 1000 separate memory locations for variations of @r?
00:43dnolenmattb[]: not necessarily from what I understand.
00:43amalloyuhhhh, if you actually collected the results, i think so? otherwise they'd be eligible for gc and migght disappear or be reused
00:44mattb[]I see
00:44mattb[]are there unboxed value types?
00:44dnolenmattb[]: 64bit primitives.
00:44dnolenlong & double
00:44mattb[]no unboxed integer?
00:44dnolenmattb[]: no.
00:45mattb[]heh
00:45dnolenmattb[]: well yes, but not fast path for it.
00:45mattb[]I don't know much about the JVM GC
00:45mattb[]but I hope it's good :)
00:45brehautits very good for a lot of uses cases (in particular if you tune it)
00:46dnolenmattb[]: it's very good, part of the reason Clojure is possible. but it's certainly true that Clojure is memory hungry.
00:48mattb[]http://shootout.alioth.debian.org/u64q/benchmark.php?test=all&lang=clojure&lang2=java
00:49mattb[]looks like clojure is 3-5x as memory intensive as plain java
00:52dnolenmattb[]: yup, tho those could probably be improved, only one person really works on those benchmarks. I think most of those could get whittled down to 1.5X-2X of Java and mostly on par w/ memory usage.
00:59mattb[]here's a weird question for you... how do you *read* lisp?
01:00mattb[]when you look at something like (< r (+ (slices i) sum)), how does it vocalize in your head? do you actually see it as "r is less than (slices i plus sum)"
01:01dnolen(-> (slices i) (+ sum) (< r)) if you don't like looking at nested code.
01:01amalloymattb[]: i don't usually vocalize when i'm reading, programming or otherwise
01:02dnolen,(-> 5 (+ 10) (< 20))
01:02clojurebottrue
01:02mattb[]I feel like it's worthwhile to try not translating from prefix notation and back again
01:03mattb[]I guess I've only been looking at it for like two days though, not surprised it feels totally unnatural
01:03amalloymattb[]: i still have trouble with (< x y). is x less than y, or y less than x?
01:04brehautamalloy: its (< x y z) that really messes with me
01:04dnolen,(< 1 2 3)
01:04clojurebottrue
01:04mattb[]I can't look at it without looking at "less than.. x.. is less than.. y"
01:05mattb[]eyes bouncing inside the parenthesis like a bingo ball
01:05brehauti think reading < as monotonically increasing is easier than 'less than'
01:05brehautmakes (< 1) make sense too
01:05mattb[]huh
01:05mattb[]that makes way more sense lol
01:05amalloybrehaut: funny. i read (< x y z) with no problems
01:06mattb[]well brehaut just solved all my problems
01:06mattb[]now I can't look at (< x y z) without seeing "increasing to the right"
01:07amalloymattb[]: careful. when brehaut solves all your problems you find yourself with another set of problems
01:07mattb[]haha
01:07brehauthaha
01:07brehautits true!
01:07mattb[]hopefully vastly more interesting problems
01:07brehautmostly just regexp + monad soup
01:08mattb[]oh god
01:08brehauti like to call it a parser
01:08mattb[]what have I stumbled into
01:08mattb[]where am I
01:08mattb[]I quit perl two years ago
01:08brehautperl has a monads lib?
01:09technomancyelisp does
01:09mattb[]I wrote a small novel worth of regexp a while back
01:09mattb[]I believe I have multiple sclerosis now
01:09technomancyhttp://dorophone.blogspot.com/2011/04/deep-emacs-part-1.html
01:09brehauttechnomancy: i am frightened
01:10brehautdynamic scopes ftw i guess?
01:11brehauthttp://ubuntuone.com/p/vtn/ even though i understand bind, that doesnt make much sense to me
01:21brehautoh i think i got terms wrong. < is strictly increasing, <= is monotonically increasing
01:23mattb[]erm I believe you were right
01:24mattb[]monotonically just means not decreasing
01:24mattb[]not only strictly increasing
01:24brehautexactly
01:24mattb[]< is not decreasing
01:24mattb[]er no
01:24mattb[]you were right the second time :)
01:24brehautthats what i mean
01:25mattb[]haha
01:25mattb[]it's late
01:25brehautcommunication fails; clearly its friday evening
01:25brehaut(down here in the future anyway)
01:25mattb[]let me know if anything bad happens in the future so I can prepare
01:26brehautits raining pretty heavily so dont go out without an umbrella
01:32mattb[]aha
01:33mattb[]first class functions make me happy
01:35amalloy$findfn 4 5 6 15
01:35sexpbot[clojure.core/+]
01:35amalloymattb[]: ^ is available for you, btw
01:36mattb[]^ is what?
01:37amalloya pointer upwards to the previous message
01:37amalloyi guess i need to stop including it in sentences
01:38mattb[]OH lol I didn't realize you had said something before
01:51mattb[]so in (import '(java.awt Color Graphics Dimension)), how would it try to interpret that without the apostrophe?
01:51hiredmanimport may be a macro these days
01:51brehautbad example, import doesnt need a '
01:51hiredman(meta #'import)
01:52hiredman,(meta #'import)
01:52clojurebot{:macro true, :ns #<Namespace clojure.core>, :name import, :file "clojure/core.clj", :line 2617, :arglists ([& import-symbols-or-lists]), :added "1.0", :doc "import-list => (package-symbol class-name-symbols*)\n\n For each name in class-name-symbols, adds a mapping from name to the\n class named by package.name to the current namespace. Use :import in the ns\n macro in preference to calling thi...
01:52mattb[]fair enough
01:52hiredmanit used to need a quote, in the before time
01:52mattb[]this sample is really old
01:52brehautextremely
01:52brehauti first read it back in 08
01:52brehautits pre clojure 1.0
01:52mattb[]oh crap, it IS from 08
01:53brehautback when rhickey would occasionally release a datestamp snapshot or you followed SVN
01:53mattb[]is the book worth reading?
01:53brehautwhat book?
01:53mattb[]the joy of clojure I believe
01:53brehautdepends how familiar you are with one of Java or Lisp
01:54brehaut(or failing that, some other dynamic or functional languages)
01:54brehautJava?
01:54clojurebot
01:54brehautthanks clojurebot
01:54mattb[]I'm most comfortable with C#/java
01:54mattb[]lol
01:54brehautits a very good book
01:54brehautbut its not a beginner book
01:55brehautbeing comfortable with the java ecosystem or a lisp is advisable
01:55brehautdoesnt need to be both though
01:55brehautits very much the 'why' book rather than the 'how' book
01:55mattb[]it doesn't presume lisp knowledge though?
01:55brehautno
01:55mattb[]good
01:55brehautbut its introduction is lightening fast
01:56brehauti think its called 'drinking from the firehose'
01:56mattb[]haha
02:03amalloymy favorite thing about that book is that there's a chapter called "being lazy and set in your ways", about laziness and immutability
02:04mattb[]haha
02:40void_good morning everyone ;)
02:58Dranikhi all!
02:58Dranikis there a way to get the current name space except *ns* ?
02:59opqdonutwhy would you want another way?
03:00DranikI want just a pure name space string in order to use it as a symbol.
03:00Dranikbut *ns* generates something like #<Namespace user> -- I have to parse that
03:01opqdonutwell you shouldn't parse it
03:01opqdonutbut use, for example (.getName *ns*)
03:02opqdonutthe value of *ns* isn't a string "#<Namespace user>", it's a Namespace object
03:03Dranikopqdonut: thanks!
03:11void_Dranik: next time just say (type *ns*) and then find docs for that type
03:14opqdonutsolid advice
03:15void_that's so great about clojure - you have repl all the time, you can inspect everything
03:23Dranikvoid_: thanks, but actually I didn't found that .getName() method while going your way (with (type *ns*) and find-doc)
03:25void_yeah you're right
03:26void_my point was, when you have the type you can find out more about it
03:26opqdonutunfortunately the Java interfaces of clojure things are badly documented
03:26void_&(.getMethods (type *ns*))
03:26sexpbotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Namespace is bad!
03:26Dranikbtw, is there an easy way to get all the methods of the current object?
03:26void_Dranik: .getMethods
03:26opqdonutit would be neat if (doc) could access javadoc
03:26void_&(.getMethods *ns*)
03:26sexpbotjava.lang.SecurityException: You tripped the alarm! class clojure.lang.Namespace is bad!
03:26Draniklet me try..
03:27opqdonutah, repl-utils has (javadoc class)
03:27void_oh
03:50DranikOk, repl-utils solved most of my problems, thanks :-)
04:59Dranikhow to join two vectors?
04:59opqdonut,(into [1 2 3] [4 5 6])
04:59clojurebot[1 2 3 4 5 6]
05:00Dranikthanks!
05:00opqdonutthough that kinda works "by accident"
05:00opqdonutsince what into does is repeated conjs, and the conj for vector appends
05:00opqdonut,(vector (concat [1 2 3] [4 5 6]))
05:00clojurebot[(1 2 3 4 5 6)]
05:00opqdonuterr
05:00opqdonut,(vec (concat [1 2 3] [4 5 6]))
05:00clojurebot[1 2 3 4 5 6]
05:00opqdonut:)
05:01Dranik:-)
05:19Fossi,(into '(1 2 3) [4 5 6])
05:19clojurebot(6 5 4 1 2 3)
05:19Fossiso, yeah ;)
05:20opqdonutand ##(into [1 2 3] '(4 5 6))
05:20sexpbot⟹ [1 2 3 4 5 6]
05:20opqdonutvec could take multiple arguments like str
07:51void_&(.getInstance java.utilCalendar.)
07:51sexpbotjava.lang.ClassNotFoundException: java.utilCalendar.
07:51void_(.getInstance java.util.Calendar.)
07:51void_&(.getInstance java.util.Calendar.)
07:51sexpbotjava.lang.ClassNotFoundException: java.util.Calendar.
07:51void_&(.getInstance java.util.Calendar)
07:51sexpbotjava.lang.IllegalArgumentException: No matching field found: getInstance for class java.lang.Class
07:52void_Why doesn't this work?
07:52void_I used (import '[java.util Calendar]) in my code
07:53teromI think getInstance is a static method. Try Calendar/getInstance
07:54terom&(java.util.Calendar/getInstance)
07:54sexpbot⟹ #<GregorianCalendar java.util.GregorianCalendar[time=1307706793147,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="US/Pacific",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZ... http://gist.github.com/1018696
07:54clgv&*clojure-version*
07:54sexpbot⟹ {:major 1, :minor 2, :incremental 0, :qualifier ""}
08:00void_so you can't call static methods with (.method object) ?
08:01void_&(let [cal (java.util.Calendar/getInstance)])
08:01sexpbot⟹ nil
08:01void_&(let [cal (java.util.Calendar/getInstance)] (println cal))
08:01sexpbot⟹ #<GregorianCalendar java.util.GregorianCalendar[time=1307707232071,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="US/Pacific",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZ... http://gist.github.com/1018703
08:01manutter,(macroexpand-1 '(.method object))
08:01clojurebot(. object method)
08:01rostayobWhat's the best resource to learn clojure if I'm a haskell programmer? possibly something that I can read nicely on a kindle
08:02rostayobconsidering that clojure would be my first lisp
08:02void_thanks guys
08:02manutterrostayob: I really liked the Clojure In Action book from manning press
08:03manutterNot sure if it's available in a kindle format yet
08:03DranikPractical Clojure was best for me
08:03rostayobmanutter: the problem is that the three books that seem to be most reccomended (the joy of clojure, clojure programming and the one you mentioned) seem so be available only in paper
08:03Dranikand The Joy of Clojure after it
08:03manutterLand of Lisp is also a good lisp intro
08:03rostayobDranik: practical clojure is available for kindle mhm
08:04Dranikrostayob: no, all the books about clojure have their digital versions
08:04manutteralso just as a general resource, the 4clojure.org web site has about a hundred exercises from elementary to advanced, great resource for practicing and getting hand-son
08:04rostayobDranik: digital as in ebook? because pdf is not nice
08:05manutter*hands-on
08:05void_pdf is nice on iPad :)
08:05rostayobvoid_: no ipad for me eheh
08:05rostayobDranik: you are right, programming clojure is available in some ebook format
08:05rostayobmobi
08:06Dranikrostayob: well, I meant pdfs of course
08:06rostayobDranik: no but they have it in mobi, so it's good
08:06manutterrostayob: http://www.manning.com/rathore/
08:07manuttero wait, August release date
08:07manutterI read it thru the MEAP program, but I think the MEAP is pdf's
08:08void_Q: What are my options with MEAP?
08:08void_A: With MEAP books, you get Early Access to electronic chapters for no extra charge. You choose the format of the final product: PDF ebook only, or you can also receive the paper book when it ships.
08:08void_so it's only PDF
08:11rostayobok, I think I'll go for practical clojure
08:11Fossithat's so sane
08:11Fossiebook formats stink so much
08:11Fossiwell, pdf does as well
08:12void_yeah practical clojure looks nice
08:12teromJoy of Clojure is a good book (even I've not yet completely read it yet). You'll get ebook for free if you buy paperback version. Or at least I did.
08:13Dranikcan't wait for Clojure Programming
08:14void_why?
08:14clojurebotwhy not?
08:14Dranikit looks like a very practical book focused on some every-day tasks
08:14Draniknot just on language usage
08:14void_that sounds nice
08:14void_I'm thinking of pre-ordering that
08:14void_http://www.bookdepository.com/Clojure-Programming-Chas-Emerick/9781449394707
08:15manutterI got the rough cuts version from O'Reilly, it's looking good
08:15void_huh
08:15Dranikyep that's what I'm talking about
08:16Dranikmanutter: could you please share you rouhg cuts to have a first glance at a book?
08:16void_&(. Integer valueOf "42")
08:16sexpbot⟹ 42
08:16void_&(. Calendar getInstance)
08:16sexpbotjava.lang.Exception: Unable to resolve symbol: Calendar in this context
08:16void_&(. java.util.Calendar getInstance)
08:16sexpbot⟹ #<GregorianCalendar java.util.GregorianCalendar[time=1307708155283,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="US/Pacific",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZ... http://gist.github.com/1018726
08:17void_&(.getInstance java.util.Calendar)
08:17sexpbotjava.lang.IllegalArgumentException: No matching field found: getInstance for class java.lang.Class
08:17void_why
08:17manutterwow, that's surprising
08:17manutter,(macroexpand-1 '(.getInstance java.util.Calendar))
08:17clojurebot(. (clojure.core/identity java.util.Calendar) getInstance)
08:18clgvvoid: static methods are callled like that: ##(java.util.Calendar/getInstance))
08:18sexpbot⟹ #<GregorianCalendar java.util.GregorianCalendar[time=1307708218870,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="US/Pacific",offset=-28800000,dstSavings=3600000,useDaylight=true,transitions=185,lastRule=java.util.SimpleTimeZ... http://gist.github.com/1018728
08:18manuttero
08:18void_clgv: yes, it just doesn't make much sense to me right now! :)
08:19clgvvoid: in this case (.getInstance java.util.Calendar) Calender resolves to a Class object and the class Class has not .getInstance method
08:19manuttervoid_: check out the macroexpand--something funky is happening with the reference to the java class
08:19clgv&(type java.util.Calendar)
08:19sexpbot⟹ java.lang.Class
08:19void_oh
08:19clgv&(type java.util.Calendar/getInstance)
08:19sexpbotjava.lang.Exception: Unable to find static field: getInstance in class java.util.Calendar
08:19void_so speaking OOP, java.util.Calendar in this case is an instance of java.lang.Class
08:20manutter,(.getInstance (java.util.Calendar.))
08:20clojurebotjava.lang.IllegalArgumentException: No matching ctor found for class java.util.Calendar
08:20manutterheh, so much for being clever
08:20clgvvoid: the symbol "java.util.Calendar" you specify is resolved to an object of type java.lang.Class
08:21void_ok thanks ;)
08:21void_for now I'll just remember to call static methods with /
08:21clgvright ;)
08:21clgvit is the same syntax as if you only required a clojure namespace where you have to provide the namespace of the function as well
08:22void_I really like this way of learning: for each topic: read something, hack, read something. Reading with having that experience of hacking is much different.
08:23void_most people just read, and then hack.
08:23clgvvoid: but I suggest to read one of the introductory books for a start. that'll get you started much faster
08:24void_clgv: I'm reading Joy of Clojure, I'm at around half, and I feel the need to try the simple things before reading about complicated. (threading and stuff)
08:25clgvvoid_: trying the examples that seem not so clear at first glance is always a good idea ^^
09:40void_in compojure, where should I put my db connection code?
09:43manutterI'd put it in its own namespace
09:43manutterthen call/require it from the same code that launches your app
09:43manutterI'm trying to remember how I did it, but I *think* it auto-connects just from pulling in the require
09:45void_ok so this is my handler
09:45void_:ring {:handler theboots.core/app}
09:46Dranikvoid_: isn't compojure just a routing framework?
09:46void_Dranik: yeah I guess
09:46void_but to me compojure = rails
09:46void_so when I say "how do I do it in compojure" I mean "what is the best practise for web development in clojure" :)
09:47Dranikvoid_: I have implemented a rails-like blogging engine with posts, comments and simple authentication
09:47Dranikwould you like to have a look?
09:47void_of course
09:48void_is it open-source?
09:48Dranikid havn't published it yet
09:48DranikI can send you via e-mail
09:48redingerDranik: What framework did you use?
09:49Dranikring/compojure, clojure-soy, clojure-sql
09:50DranikI like rails very much too so I've tried to emulate the rails-style in my application
09:50redingerclj-soy?
09:50Dranikyep
09:50void_Dranik: that's exactly what I would like to do
09:50Dranikbut its a very hard work for a single person. that's why I have stopped my experiment
09:51redingerI'm very curious how people are doing this in the wild, I'd love to take a look if you don't mind. :)
09:51DranikI can show you a couple of snippets
09:51redingerAs a recovering Rails-ist, current Clojurian.
09:51DranikI haven't published it, so just send my your email
09:53void_redinger: do you use clojure to build web applications too?
09:53redingerYes
10:01void_Dranik: it's very nice code
10:01Dranikthanks! :-)
10:03timvisherhey all
10:04timvisheri just started getting weird errors with slime. for example https://gist.github.com/1018881
10:06timvisherI can do basic things like (+ 1 1)
10:06nickik@Dranik I want to implment a a blogging engine to would you mind sending it to me too?
10:06timvisherand i can C-c C-k on the namespace and switch to it
10:06timvisherbut the moment I try to use any of the functions, it starts throwing errors
10:06Draniknickik: no problem, just send me your mail
10:07manuttertimvisher: maybe you need a lein clean ; lein deps ?
10:09timvisheractually, i take that back. i can use in memory functions. it's when I reference my library ref that it seems to screw up. https://gist.github.com/1018890
10:09timvishermanutter: haven't tried lein clean...
10:09Dranikalso I have documented the project on my blog (my-clojure.blogspot.com) but it's in russian. if interested -- try translate.google.com, it reads my articles fine
10:12timvishermanutter: `lein clean` changed the error message at least. seems to be the same sort of issue though. https://gist.github.com/1018899
10:13redingerDranik: Between the code base and the blog post, you are building a good tutorial. I hope you release the code publicly.
10:13Dranikredinger: you mean the blog or the code itself?
10:14redingerThe code
10:14Dranikdo you really think it looks fine as a tutorial?
10:15Dranikif so, I can comment it and publish on github
10:15VinzentDranik, hey, maybe we should restore the #clojure-ru channel?
10:15DranikVinzent: no way, I don't wanna talk apart from clojure/core guys! :-)
10:20VinzentDranik, well, I just have readed your comment (about frameworks) and want to talk to you, but I think russian would be more convenient
10:20redingerDranik: yes, I think it would be useful for the Rails people googling for how to do that
10:21DranikVinzent: my encoding is utf8. what's yours?
10:21timvisheri can run my tests and such via `lein test`
10:21timvisherso it seems to be something with slime, not with lein
10:22VinzentDranik, latin/unicode
10:22Dranikredinger: Ok then, I'll publish the code with a tutorial. Probably anyone will help me to finish the project as a small framework
10:22timvisherand the project runs fine
10:23timvisherit's just that i can't work on it in slime at the repl
10:33CozeyHi! What's the recommented form / validation library for Compojure?
10:34VinzentCozey, checkout https://github.com/dnaumov/jaco/blob/master/test/jaco/test/core/actions.clj
10:34Cozeywhat about validation-clj, clj-decline etc?
10:35CozeyVinzent: what the heck is that?
10:38VinzentCozey, web-framework built on top of compojure. I see you didn't like it
10:39Cozeyno - not at all
10:39Cozeybut i'm trying to aunderstand something that looks to me like prolog
10:39Cozeywhy wouldn't i like it? I just woder how could i validate an e-mail form field with that
10:46timvisheranyone know why slime might throw an error like this? https://gist.github.com/1018899
10:47VinzentCozey, oh, my english is very bad, probably I've misunderstood you. To validate e-mail, you can write somethig like this: https://gist.github.com/1018974
10:47pdk,(name :test)
10:47clojurebot"test"
10:47pdk,(keyword "test")
10:47clojurebot:test
10:47VinzentMany common predicates can be found in pretzel: https://github.com/joodie/pretzel
10:50CozeyVinzent: mhmm . thanks, I will look into that
10:53cemerickcurious mention of "jigsaw + clojure" here: http://openjdk.java.net/projects/mlvm/jvmlangsummit/agenda.html
10:57Vinzenttimvisher, jpeg, strange... Same thing for new projects?
10:57timvisherVinzent: you mean can I create a new project and reference the thing I'm trying to reference in the current project?
11:01timvisherVinzent: or are you talking about the use of the jpeg extension?
11:05Vinzenttimvisher, i thought slime throwing this error for all projects
11:05timvisheri can only trigger it through the project that is referencing the library ref
11:05timvisherwhich right now is only 1
11:05timvisherit was working up until about an hour ago.
11:05timvisherbut I can see anything wrong with the seq in the file that i'm loading it from
11:06timvisherand clojure's using it fine
11:06timvisherit seems to be when slime tries to print it to the repl
11:08timvisheri can also run all my tests from within slime (via clojure-test)
11:08timvisherit's only when I try to utilize library from the repl
11:10timvisherand hurray!
11:10timvisherit magically started working again
11:11timvisherand i immediately eat my own words
11:14timvisheri can indeed use that reference. it's when i try to print the entire thing that it barfs
11:19gfrloganybody know anything about clojure & Jenkins?
11:29cemerickgfrlog: such as?
11:31gfrlogcemerick: well googling tells me that there is not a "leiningen plugin for jenkins"
11:31cemerickyeah, that's correct, last I knew
11:32gfrlogI'm not familiar with jenkins though, and reading through things is starting to make me think that it can probably do arbitrary things
11:32cemerickSomeone tried to ante up a bounty for one, I think.
11:32gfrlogI was just hoping that I can get it to run my tests without having to learn maven :)
11:32cemerickyeah, you can set up a job to run arbitrary scripts
11:32gfrlogthat's the realization I was coming to. Good to hear it confirmed. Thanks.
11:33cemerickThe real pain will be that you're going to need to drop down into a console in order to do certain things that you'd be able to do from the UI if you were using ant or maven, etc.
11:33gfrlogcemerick: what sort of things?
11:35cemerickinstalling/upgrading lein, using different JVMs, probably things like repository deployment
11:36gfrlogokay. I can live with that.
11:36cemerickyeah, there are definitely people using lein with hudson/jenkins
11:37gfrlogcool
11:37timvisheranyone know why slime would do something like this? https://gist.github.com/1018899
11:40cemerickgfrlog: hell, there are people using hudson with custom shell script builds :-P
11:42gfrlog"If you can not able solve it with few than 10 Apache rewrite rule, is probable not worth solve."
11:42pjstadigmaybe no surprise, but we use hudson/jenkins with lein at Sonian
11:42pjstadigsetup a build with to run a shell script
12:00technomancysomebody's working on a leiningen plugin for hudson too so you don't have to shell out
12:01technomancynot sure how much that actually buys you though
12:01technomancydeployment is easy to configure from project.clj and/or ~/.lein/init.clj
12:02technomancyoffby1: triple meaning if you count Ninja Turtles
12:02cemericktechnomancy: clicky-clicky is always more pleasant than testing shell invocations via hudson :-)
12:03technomancycemerick: depends... I just set up all our ci jobs via chef, so it all had to be based around config files anyway
12:03technomancyit's more work up front, but it's way more repeatable
12:04technomancyit's a cultural thing I guess
12:05cemerickI've never quite grokked the use of automation tools for hudson envs, actually. I don't start up new hudsons more than once every ~5 years, it seems.
12:05technomancycemerick: we're probably going to be investing in a master/slave scenario down the road
12:06technomancybecause our recipes need testing too, and different environments are mutually exclusive for a given host
12:07gfrlogyour automated-test-running-scripts need to be automatically tested?
12:07cemerickThat makes more sense to me; but, there's a plugin already for build slaves, no?
12:07technomancycemerick: right, but the build slaves will need to be torn down and rebuilt from scratch, otherwise the recipes aren't actually being tested.
12:08technomancygfrlog: STACK OVERFLOW
12:08nickikdoes jenkins/hudson work with leiningen? (never used any think like CI)
12:08gfrlog:)
12:08technomancynickik: you can call out to any command from jenkins. as long as it returns a sensible exit code it will work.
12:09gfrlogman programmers never stop building their tower of abstractions
12:09hiredman~problem
12:09clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
12:09hiredman~problem
12:09clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
12:09hiredmanclojurebot: you jerk
12:09clojurebotIt's greek to me.
12:09hiredman~abstractions
12:10clojurebotHuh?
12:10gfrlogsomeday it will take 15 experts to describe everything between the transistor and the website
12:10hiredmansomeday?
12:10gfrlog45?
12:10gfrloghow high do I need to go?
12:10TimMcI think I can already pretty much explain it.
12:10TimMcgfrlog: It depends on the level of detail that is required.
12:11gfrlogIf I had piles of money I would commision a cool animated educational video outlining it
12:11gfrlogit would be bookended by a grandma clicking "Add friend" on facebook or something like that
12:11hiredmanTimMc: I doubt you can explain the various optimizations the jvm does, or the inner workings of a recent intel chip
12:11nickikhow many will it take until a noob can start from nothing build his computer and make it a webserver?
12:11gfrlog"good" and "caches"
12:12technomancycemerick: do you use any of the fancy test output tracking in hudson?
12:12TimMchiredman: That's what I mean by detail.
12:12cemerickgfrlog: like those nifty videos of protein synthesis that floated around a while back
12:12gfrlogcemerick: I know not of what you speak, but I wish I did.
12:12cemericktechnomancy: Nope. It's all broken/notbroken for me.
12:13technomancyapparently clojure.test can output junit xml, which hudson can consume... I'm curious as to what it does with the data.
12:13gfrlogtechnomancy: digests it?
12:13cemerickSo I've heard. I've never gone very deeply into test tooling tho.
12:13gfrlogextracts proteins and minerals?
12:14hiredmantechnomancy: graphs
12:14cemerickI think that's technically expectoration, not digestion.
12:14gfrlog:)
12:16gfrlogI wish there was a conference dedicated to broadening your computing knowledge base. I would go to an hour-long talk about how file systems work.
12:16technomancyhiredman: so it comes down to whether it's easier to tweak clojure.test to emit junit output or graph the output yourself =)
12:16gfrlogtechnomancy: so it CAN output the xml, but not without tweaking?
12:18technomancygfrlog: well... actually it looks like only "lein test" would need tweaking
12:19gfrlogtechnomancy: ah ha. Well if I end up needing it, I'll dive in and take a look then.
12:19technomancygfrlog: the problem is we already monkeypatch the hell out of clojure.test, likely in a number of ways that are likely to not be orthogonal to clojure.test.junit
12:20gfrlogoh dear
12:20technomancyI should probably come up with some patches to just make clojure.test more flexible
12:21cemerickgfrlog: not quite the one I remembered, but not bad, either: http://www.youtube.com/watch?v=41_Ne5mS2ls&amp;feature=related
12:21cemerickMore "pop" than "science", but…
12:21gfrlogdoes "monkeypatching" refer to something other than rebinding vars pre-1.3-style?
12:22technomancygfrlog: mostly robert.hooke
12:22gfrlogcemerick: this is the best thing that has happened to me today.
12:22technomancythough Emacs clojure-test-mode just redefines clojure.test/report after saving it off into another var since it was written long before hooke
12:23technomancyhooke is slightly more composable than redef/binding
12:23gfrlogI apparently am woefully underinformed about the capabilities of robert.hooke.
12:24technomancyit's basically a functional implementation of elisp's defadvice
12:24gfrlogI always wonder how a DNA-reader knows which strand to read
12:24technomancyit probably has a PushbackReader
12:25gfrlogit's like if you had two binary files where one was the bitwise-complement of the other
12:30cemerickgfrlog: Here's a more complete one; the first segment (on replication) was the most interesting IMO http://www.youtube.com/watch?v=4PKjF7OumYo
12:31gfrlogcemerick: cool, thanks
12:34timvisheranyone know why slime would do something like this? https://gist.github.com/1018899
12:40technomancycemerick: so are you turning fogus and chouser's attribute-your-book-to-the-other-coauthors policy into a tradition? =)
12:41cemericktechnomancy: it seems way too gentlemanly to do otherwise!
12:41technomancycongrats
12:41cemerickChristophe and Brian aren't big twitterers though, so people may just think I'm a stalker or something.
12:41cemerickthanks
12:41cemericklong time coming
12:42cemerickI really just want to get what we have done *now* out there. I botched things a bit, so what's there is stale. That'll be fixed pronto, tho.
12:43technomancyplanning on timing it with the next release like stu did?
12:44cemerickHardly a plan, but it's worked out well. I really didn't want to walk the 1.2/1.3 line like chouser and fogus had to (at least to some extent)
12:44cemerickThe real objective is to have it in print for the Conj.
12:44clojurebotRoger.
12:45cemerickclojurebot: you'll pass the Turing test yet.
12:45clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an")) )] (testar 10 25))
12:52timvisheranyone know why slime would do something like this? https://gist.github.com/1018899
13:00manuttertimvisher: Sorry, I got called away
13:00manutterSo it looks like something is interrupting the network connection between swank server and your slime repl
13:02manutterThis started happening when you changed your lib?
13:02[mattb](doto (JFrame.) (.add (JLabel. "Hello")) .pack .show) <-- is the period in the function names part of the name? why would )) pack show) be invalid?
13:02manutterHave you got conflicting jar files in your local repo perhaps?
13:02manuttermattb: the leading period means you're calling a Java method
13:03[mattb]is that a macro to the (. xxx) form?
13:03manutterright
13:03[mattb]gotcha
13:03manutter,(macroexpand-1 '(.method object))
13:03clojurebot(. object method)
13:03[mattb]heh, cool
13:04manuttertimvisher: see if you have multiple copies of your lib in the .m2 directory in your home directory
13:05manuttertimvisher: what OS are you on, btw?
13:56redingercemerick: Having it in print for the Conj is an awesome goal!
13:56redingerEveryone should strive to have more stuff ready for the Conj
13:56Raynesredinger: Unfortunately, my book's soft deadline *is* November, so there isn't really any chance of it being in print by then.
13:57cemerickredinger: it's either that or have it in print three weeks _after_ the conj (or whatever), so we'll just get it done before. ;-)
13:58redingerRaynes: Print your own early release copy? :)
13:58cemerickredinger: Good point.
13:58RaynesThe book will probably be finished by the Conj though, so yes, I could probably do something.
13:58RaynesAnd since I'm actually free to do whatever I want with my own version of the book, I could actually do that.
13:59cemerickRaynes: Nifty; I'll roll you into my authors roundtable proposal then (unless you're not interested).
13:59RaynesGo for it. :)
14:02Raynescemerick: What is that proposal?
14:03cemerickRaynes: I thought it'd be fun to have an author's roundtable at the Conj. Get all the authors "up there", be asked questions from attendees, debate random topics, whatever.
14:03cemerickMight be a good thing for the end of the day, start passing around the drinks, etc.
14:03RaynesSounds like a fun idea.
14:04cemerickStu set that precedent last time, so I'm expecting a sidebar in the conference room this time around. ;-)
14:10gfrlogquestion for author's panel: which clojure book is the best?
14:11gkoMannings?
14:11gkonewer
14:12bartjis there a diff b/w Sequential and ISeq ?
14:12bartj,(doc seq?)
14:12clojurebot"([x]); Return true if x implements ISeq"
14:12bartj,(doc sequential?)
14:12clojurebot"([coll]); Returns true if coll implements Sequential"
14:12gfrlog,(seq? #{})
14:12clojurebotfalse
14:13gfrlog,(seq? [])
14:13clojurebotfalse
14:13gfrlog,(sequential? [])
14:13clojurebottrue
14:13bartjfor eg: (sequential? [1 2]) returns true
14:13bartjbut, (seq? [1 2]) returns false
14:13amalloy&(map (juxt seq? sequential?) [[] () {} #{}])
14:13sexpbot⟹ ([false true] [true true] [false false] [false false])
14:13bartjgfrlog, you type fast
14:13hiredmanright a vector is not a seq
14:13gfrlogseqable? would return a third set of things
14:14hiredmanbut it is a sequential datastructure
14:14hiredmanbut maps are not
14:14technomancysequential means seqable and ordered, I think
14:14gfrlogso seq /subset sequential /subset seqable
14:14gfrlogis that fair?
14:14hiredmantechnomancy: just ordered, I believe
14:14hiredmannotation is not clear
14:15technomancyI guess everything ordered is seqable, so maybe that's not a real distinction
14:15Raynesgfrlog: Well shit, I'll answer that one: The Joy of Clojure.
14:15RaynesMy plan is perfect: I'm not trying to beat The Joy of Clojure, but agument it.
14:16RaynesOr compliment it. Whichever is appropriate.
14:16gfrlogI just realized I don't know who the target audiences of the various books are
14:16Raynesmeetclj.raynes.me
14:16RaynesThat wall of text might be helpful.
14:16cgay_Raynes I think you mean complement.
14:17Raynescgay_: So do i.
14:17RaynesI*
14:17cgay_Although complimenting it would be nice too.
14:17gfrlogcompl[ie]ment?
14:18gfrlogRaynes: what are the beginning and end of clojure?
14:20manutter,((juxt first last) "clojure")
14:20clojurebot[\c \e]
14:20gfrlogC is for clojure, that's good enough for me; OH, ...
14:21gfrlog,((juxt first last) "cookie")
14:21clojurebot[\c \e]
14:21Raynesgfrlog: Well, the book begins with an overview and then an introduction to functional programming and ends with actual development and interactive development techniques, if that's helpful.
14:22fliebelcat /usr/share/dict/words | grep ^c.*e$
14:23gfrlogfliebel: :)
14:25fliebelQuite a few interesting words that are the same as Clojure, start [and] end.
14:26fliebelThis is where it gets interesting, for finding project names: cat /usr/share/dict/words | grep ^c.*j.*e$
14:26gfrlogI did not know that cloture is a word
14:26manuttergfrlog: not into politics eh? :)
14:27gfrlogfliebel: or ^c.*ure$
14:27gfrlogmanutter: Not that level of detail I guess
14:27gko,(repeat 6 " ")
14:27clojurebot(" " " " " " " " " " " ")
14:27gko,(str (repeat 6 " "))
14:27clojurebot"clojure.lang.LazySeq@6d534741"
14:27Raynes&(apply str (repeat 6 " "))
14:27sexpbot⟹ " "
14:27gfrlog,(pr-str (repeat 6 " "))
14:27clojurebot"(\" \" \" \" \" \" \" \" \" \" \" \")"
14:27fliebel&(doc prstr)
14:27sexpbotjava.lang.Exception: Unable to resolve var: prstr in this context
14:27fliebelhm
14:28manutter"Cloture: when a group of politicians gets together and votes on whether or not the govt would run more smoothly if it used functional programming techniques."
14:28pjstadigplease. for the love of your fellow man, do not name anymore projects with a clojure pun.
14:28pjstadigi beg you
14:28pjstadigit must stop
14:28gfrlogpjure?
14:28Raynespjstadig: People still do that?
14:28gfrlogerujolc?
14:29fliebel&(pr-str (repeat 6 " "))
14:29sexpbot⟹ "(\" \" \" \" \" \" \" \" \" \" \" \")"
14:29gfrlogmanutter: or not that level of vocabulary at least
14:30gfrlogOn a completely unrelated note, is there an elegant way to generate a finite list with iterate?
14:30gfrlog,(iterate #(if (neg? %) (inc %)) -10)
14:30clojurebot(-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 ...)
14:30fliebelpjstadig: Hm, I agree the *jure thing is silly, but more far-fetched things like cajole are okay by me.
14:31gfrlog,(iterate #(if (neg? %) (inc %)) -3)
14:31clojurebotjava.lang.NullPointerException
14:31gfrlogI wonder how rare the cloJure consonant is in english
14:32gfrlog,(take-while identity (iterate #(if (neg? %) (inc %)) -3))
14:32clojurebot(-3 -2 -1 0)
14:32gfrlogthat's what I end up with and that feels awkward
14:33redingerWe joked around with the Cloture name for the clj-soy stuff, to see how many times we reference the homophones
14:33redingeror rather, could reference
14:34manutter,(into [] (iterate #(if (neg? %) (inc %)) 3)
14:34clojurebotEOF while reading
14:35manutter,(into [] (iterate #(if (neg? %) (inc %)) 3))
14:35clojurebotjava.lang.RuntimeException: java.lang.NullPointerException
14:35gfrlogmanutter: use -3?
14:35manuttersilly me, can't type
14:35manutter,(into [] (iterate #(if (neg? %) (inc %)) -3))
14:35clojurebotjava.lang.RuntimeException: java.lang.NullPointerException
14:35manutterwell, that's obviously not it
14:35gfrlogyeah, (into []) is going to consume as far as it can
14:36manutterThere was some function I was just using that accumulated only the non-nil values into a seq
14:36gfrlogI feel like even (take-while identity) might fail sometimes? At least it still feels shakey to have an underlying dangerous seq
14:36manutteroh, keep
14:36gfrlogyeah, keep is (filter identity (map f coll)) right?
14:36manutter,(keep (iterate #(if (neg? %) (inc %)) -3))
14:36clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$keep
14:36gfrlogif the underlying seq is still dangerous, most seq functions won't help
14:37manutterburf, what was it then
14:37gfrlogmanutter: it needs a map fn as well, so I'm not sure it applies here
14:38manutteryeah, it wasn't keep I was thinking of
14:38manutterI'm sure I just used it tho, whatever it was
14:38gfrlogI'd be surprised if it exists, since it'd just be sugar for (filter identity ...)
14:39gfrlogat least in core
14:39manutter,(doc some)
14:39clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
14:40technomancythere's talk of a one-arity version of filter that uses identity as its predicate
14:40technomancyseems like a pretty clear win to me
14:40gfrlogtechnomancy: I love it
14:41technomancygfrlog: http://dev.clojure.org/jira/browse/CLJ-450
14:42gfrloghmm. I like every? as well.
14:42manutter,(keep (fn [x] (iterate #(if (neg? %) (inc %))) -3)
14:42clojurebotEOF while reading
14:42manutter,(keep (fn [x] (iterate #(if (neg? %) (inc %))) -3))
14:42clojurebotjava.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$keep
14:43manutter,(keep (fn [x] (iterate #(if (neg? %) (inc %)))) -3)
14:43clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
14:43gfrlogmanutter: I don't think that's how keep works. you gotta give it a seq as 2nd arg
14:43gfrloglike I said, I don't think you can bend keep to be applicable here :)
14:43amalloy&(take-while #(< % 10) (iterate inc 1))
14:43sexpbot⟹ (1 2 3 4 5 6 7 8 9)
14:44amalloykeep and filter ain't ever gonna work for you
14:44manutteryeah, trying to work in 2 windows at once, not really concentrating on either, I gotta get back to work...
14:45gfrlogamalloy: the original question deals with using iterate when the fn will eventually return nil
14:45joegallohttp://clojure-log.n01se.net/date/2008-12-02.html
14:45gfrlogand calling (f nil) will break
14:45joegallooops, wrong channel, ignore me
14:45amalloyso, take-while (complement nil?)
14:45gfrlogamalloy: right, that's how I do it. 1) it seems awkward, and 2) it seems dangerous
14:46gfrlogsince the underlying lazy-seq is only not exploding because of laziness
14:46gfrlogi.e., can I be 100% sure that it won't try to compute one extra value?
14:46amalloyuhh…when you write a for loop in java, it only stops at the end because you tell it to
14:47gfrlogyes.
14:51bartjgfrlog, I thought keep was (remove nil? (map f coll))
14:51amalloyit is
14:52gfrlogbartj: what'd I say? filter identity? almost the same thing :)
15:19Moominpapa'(+ 1 1)
15:19Moominpapa,(+ 1 1)
15:19clojurebot2
15:28amalloyMoominpapa: (inc 1) is much more efficient
15:29fliebel$source inc
15:29sexpbotinc is http://is.gd/7yWaho
15:32[mattb]what's the most idiomatic way to get the keys of all elements of a hashmap where the value is greater than x? so far I have:
15:32[mattb](map first (filter #(> (last %) 1) {"foo" 1 "bar" 2 "baz" 4}))
15:33[mattb]seems like excessive mapping though
15:33fliebelamalloy: Care to explain why inc is faster?
15:33amalloy[mattb]: looks good to me. i'd write second instead of last
15:33amalloyfliebel: it's not afaik. i assumed that my suggestion of a way to optimize 1+1 would be taken as a joke
15:34amalloyor you could be a little clearer, and use key/val instead of first/second
15:34fliebelamalloy: Hm, I was thinking it might be doing something more close to the metal, since it's not written in Clojure.
15:35amalloyfliebel: sure, it might be
15:36amalloylike i said, i don't really know anything here. it just seemed like a good opportunity for some poorly-considered optimization
15:37amalloy[mattb]: actually what i like least about your example is the use of strings instead of keywords as map keys
15:38[mattb]oh?
15:38amalloyi mean, if your map happens to have strings for some reason, sure whatever
15:38amalloybut if you're building a map yourself or for an example, {:foo 1 :bar 2 :baz 4} is nicer
15:38[mattb]prefer :foo :bar?
15:38[mattb]gotcha
15:39amalloy[mattb]: the thing keywords get used for most often is map keys
15:39[mattb]ahh
15:39amalloyand they're very efficient at it, as well as being convenient for some other reasons
15:40amalloybut, lunchtime. more self-important nonsense about keywords when we return
15:40[mattb]:p
15:44gfrlogmattb: did you just make a pun with a colon?
15:49[mattb]haha
15:49[mattb]why would (.in System) be invalid?
15:49[mattb]e.g. (Scanner. (.in System)) compared to (Scanner. System/in)
15:51gfrlogmattb: (System/in) I think
15:51gfrlogor rather w/o the parens
15:51gfrlogoh wait
15:51[mattb]yeah System/in is correct, but not sure why .in System is wrong
15:52gfrlogclearly I only read the left half of your statement :)
15:52[mattb]haha
15:52gfrlog.in is for methods I believe
15:52gfrlogSystem/in is a public field
15:52[mattb]k
15:52[mattb]access vs message sending
15:52gfrlogmore or less
15:52gfrlogif you're used to ruby it's a new distinction
15:54[mattb]print apparently doesn't flush while println does, hmph
15:54stuartsierraThe System/in form is preferred for static fields.
15:55TimMc,(. System in)
15:55clojurebot#<BufferedInputStream java.io.BufferedInputStream@bdc6a3>
15:55gfrlog,(class (. System in))
15:55clojurebotjava.io.BufferedInputStream
15:55TimMc,(.in System)
15:55clojurebotjava.lang.IllegalArgumentException: No matching field found: in for class java.lang.Class
15:55gfrlog,(class (.in System))
15:55clojurebotjava.lang.IllegalArgumentException: No matching field found: in for class java.lang.Class
15:56TimMcFascinating.
15:56TimMcDoesn't the invalid form macroexpand to the valid form? :-/
15:56gfrlogalways something else to know...
15:57kephalehrm… #<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: >
15:57gfrlog.in is a macro? can't be a normal macro I guess...maybe it could be called a "macro schema"
15:57TimMc,(macroexpand-1 '(.foo Bar))
15:57clojurebot(. Bar foo)
15:58gfrlog(defmacro #".(\S+)" ...)
15:58TimMcNo, . is a macro-y thing.
15:58TimMchaha
16:00Chousuke,(macroexpand '[(System/in) (.in System)])
16:00Chousukehm
16:00Chousukeno reaction :(
16:00Chousuke&(macroexpand '[(System/in) (.in System)])
16:00sexpbot⟹ [(System/in) (.in System)]
16:00clojurebot[(System/in) (.in System)]
16:00Chousukewow
16:00Chousukelag
16:00gfrlogclojurebot's roommate is using bittorrent?
16:02ohpauleezhaha
16:07[mattb]is there a better way to repeat an argument for mapping than (cycle [:x])?
16:08gfrlog,(take 20 (repeat :x))
16:08clojurebot(:x :x :x :x :x :x :x :x :x :x ...)
16:08[mattb]repeat, thanks
16:08gfrlogno probalo
16:08TimMc,(find-doc #"repeat")
16:08clojurebot-------------------------
16:08clojurebotclojure.contrib.seq/fill-queue
16:08clojurebot([filler-func & optseq])
16:08clojurebot filler-func will be called in another thread with a single arg
16:08clojurebot 'fill'. filler-func may call fill repeatedly with one arg each
16:08clojurebot time which will be pushed onto a queue, blocking if needed until
16:08clojurebot this is possible. fill-queue will return a lazy seq of the values
16:08TimMcoh shit
16:08clojurebot filler-func has pushed onto the queue, blocking i...
16:08[mattb]haha
16:08TimMcGood, it has a line limit.
16:08[mattb]should probably make that pm
16:09TimMcyeah
16:09TimMcI forgot how verbose find-doc tends to be.
16:25tufflaxHow do I use an Enum in a Java class? VertexBuffer.Type is the enum, and I will have to pass VertexBuffer.Type.Position for example to a method
16:25[mattb]how can I have map ignore nil values? e.g. (map match-val all-vals (repeat val)), where match-val returns nil if it doesn't match
16:26gfrlogmattb: if I understand correctly, you'll have to wrap that in (remove nil? ...)
16:27[mattb]no better way to do it? I figure map may not be the best way to apply a comparator to a collection
16:27gfrlogmattb: but there's probably a cleaner way to do what you're doing anyhow
16:27[mattb]yeah
16:27gfrlogare you trying to transform AND filter your collection, or just filter it?
16:28[mattb]FILTER
16:28[mattb]that's the name of the function :D
16:28[mattb]still not remembering my functional idioms
16:28gfrlog:)
16:29stuartsierra`keep` removes nils too
16:29gfrlogyeah, if you're going to transform as well, then keep is a good shortcut
16:29lostpassis it possible to view the grpah of issues until 1.3 in jira?
16:29[mattb]Usage: (filter pred coll) <-- how can I curry pred so it calls it with an argument?
16:29gfrlogmattb: ##(doc partial)
16:29sexpbot⟹ "([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & more]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args."
16:30[mattb]sweet thanks
16:30lostpassnvm i found it
16:30gfrlogif you need to partially apply some argument other than the first one[s], then you'll probably just have to make a fn-literal
16:31MoominpapaStupid question, if you create a lazy-sequence and evaluate the first element, does "rest" remain unevaluated or can chunking evaluation occur?
16:32[mattb]filter + partial worked beautifully
16:32stuartsierraMoominpapa: chunks will get evaluated as chunks.
16:33stuartsierrae.g. (first (map foo (range))) evaluates foo 32 times.
16:34tufflaxdid anyone know the answer to my question? :)
16:34Moominpapaok, so I need to be careful putting blocking io into a sequence...
16:34stuartsierratufflax: enums are normal Java classes.
16:35stuartsierraNested classes are represented by their binary names, OuterClass$InnerClass
16:36stuartsierraMoominpapa: Sequences you create yourself with lazy-seq and cons are not chunked, but map/range/filter etc. all do chunking by default.
16:36technomancyI thought map was orthogonal to chunking
16:37MoominpapaLooking at the code...
16:38MoominpapaLooks like map respects chunks if they're there, but doesn't chunk something unchunked.
16:41gfrlogI wonder what makes chunking faster for things like (range)
16:41MoominpapaActually, this appears to be generally true: you don't need to worry about chunking if you don't do something likely to create a chunk.
16:41[mattb]oh fark
16:43[mattb]alright, I'm trying to filter a hashmap for keys that match some match function, return only those that do, then modify those values in the original hashmap
16:44gfrlogtracking so far
16:44[mattb]so far I'm using (filter (partial match-fun search-val) thehashmap), where match-fun returns the item that matches the search-val
16:45[mattb]but filter/partial passes the entire hash map to the match-fun
16:45[mattb]rather than mapping the function to it
16:45gfrlogmattb: I would expect it would pass key-val-pairs to the match-fn
16:46[mattb]it apparently passes a list of them
16:46gfrloga list of pairs?
16:46[mattb]yeah
16:46gfrlogthat don't sound right
16:47gfrlog,(filter (comp pos? first) {0 3 -4 5 12 4 484 832})
16:47clojurebot([12 4] [484 832])
16:47[mattb]http://pastebin.com/WuC5uvYr
16:48[mattb]I would expect match-ant to receive [ant key-val-pair], match ant to the key, and return the key if equal
16:48[mattb]but it returns the entire key value pair
16:49gfrlogyou're never separating the key-val-pair
16:49gfrlogitem will be bound to the pair
16:49gfrlogoh wait
16:49gfrlogyes you are :-|
16:49[mattb]:p
16:49gfrlogokay anyhow
16:50gfrlogthe part you've left out is your all-ants object
16:50[mattb](def all-ants {:ppyy 1 :pygp 2})
16:51gfrlogI don't see any problem with it. Maybe your repl has stale functions lying around?
16:52[mattb]user=> (find-ant :ppyy)
16:52[mattb]([:ppyy 1])
16:52gfrlogthat there is what I would expect
16:52[mattb]hrmph
16:53gfrlogbut you wouldn't?
16:53gfrlogI think I know what you're misunderstanding
16:53[mattb](when (= (first item) ant)
16:53[mattb] (first item))) <-- I thought this would return only the :ppyy
16:53gfrlogit does
16:53gfrlogbut filter does not give you the result of match-ant
16:53gfrlogit gives you the original value
16:53[mattb]............
16:53[mattb]OH.
16:53[mattb]hahaha crap
16:53gfrlog:)
16:54[mattb]duh, the doc for filter just says "return true"
16:54[mattb]brilliant
16:54[mattb]so all of that aside, is the a more concise way to do what my original statement was?
16:54gfrlogyes
16:54gfrlogyour code has a few fun refactoring opportunities
16:55gfrlogfirst of all, it looks like you don't care about the values of all-ants, right?
16:55gfrlogfor that matter, it seems like (find-ant :foo) is either going to return :foo or return nil, is that correct?
16:55[mattb]I do; after I find matching keys (which will match a more elaborate pattern than just =), I need to modify their values
16:55[mattb]and maintain the rest of all-ants
16:58gfrlogmattb: so if you have a key and you're just interested in whether the all-ants map has the key, you can use ##(doc contains?)
16:58sexpbot⟹ "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or... http://gist.github.com/1019761
16:58gfrlogyou can do that without looping through the whole hashmap-seq
16:59gfrlogI think that's what the code you have boils down to
17:02raek[mattb]: another approach to update some of the entries of a map: (into (empty m) (for [[k v] m] (if (pred? k) [k (update v)] [k v])))
17:04gfrlograek: do you think reduce might be more efficient? particularly if the to-be-updated values are sparse?
17:05[mattb]gfrlog: mattb: so if you have a key and you're just interested in whether the all-ants map has the key, you can use ##(doc contains?) <-- the key is actually a pattern, and there could be multiple keys that match it
17:05sexpbot⟹ "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or... http://gist.github.com/1019774
17:06[mattb]shutup sexpbot
17:06raekgfrlog: reduce instead of what? into is just reduce with conj...
17:07gfrlogmattb: okay; in that case (filter) is good, but I think filtering over the keys would be simpler than the pairs, if you don't need the values to do the filtering
17:07[mattb]you can do that? :(
17:07gfrlogmattb: (filter pred (keys all-ants))
17:07[mattb]haha
17:08[mattb]geeze that's too easy
17:08gfrlogsometimes it is
17:09gfrlograek: I mean from the perspective of memory allocation
17:09gfrlogusing (into {}) will reassemble the map from a seq
17:09raekgfrlog: ah, you mean to only assoc when the thing is to be changed?
17:10zakwilsonI've been using Compojure for a couple projects, but I'm starting to get the feeling I'm missing out on something by using that instead of Moustache. Can someone with experience using both comment?
17:10gfrlogexactly
17:10raekyeah, the number of allocations will definitely be fewer
17:10gfrlognot something to bother a beginner about of course, so I don't know why I brought it up :-/
17:19amalloy[mattb]: if you didn't want sexpbot to eval the doc form, don't put ## in front of it :P
17:19[mattb]lol
17:19gfrlogamalloy: he was quoting me
17:19gfrlog##(println "Shutup self")
17:19sexpbot⟹ Shutup self nil
17:22gfrlogin my terminal client, all of sexpbot's responses begin with "M-W"
17:23[mattb]best way to check if a string contains a character?
17:23hiredmanhttp://www.thelastcitadel.com/images/rhickey.png ripe for tshirting
17:23[mattb]I only see contains? for maps
17:24gfrlog,(contains? (set "hooha") \h)
17:24clojurebottrue
17:24hiredman~jdoc String
17:24clojurebotCool story bro.
17:25gfrloganother option would involve one of the substring functions
17:25hiredmanclojurebot: you suck
17:25clojurebotI don't understand.
17:25hiredmanhttp://download.oracle.com/javase/1,5.0/docs/api/java/lang/String.html
17:25hiredman^- please read
17:25gfrlogclojurebot: I think you make valuable contributions
17:25clojurebotNo entiendo
17:25[mattb]and for a keyword, (set (str :hooha))?
17:26gfrlogyou can use name instead of str to omit the leading colon
17:26gfrlogbut otherwise yeah
17:26gfrlogwe should also say that if you're testing a keyword for containing a character, you're doing weird stuff :)
17:26[mattb]haha
17:26[mattb]wildcard matching keys
17:27arohnerI have some code that walks a tree, and sometimes adds metadata to nodes. It works perfectly if I use clojure.walk/postwalk, but I get no metadata if I use clojure.walk/prewalk. Anyone know why?
17:27[mattb]e.g. p?yy should match ppyy and pgyy
17:27[mattb]:ppyy :pgyy rather
17:27CozeyGood evening. is there a smarter way to write: (map #(do [%1 %2]) (range 1 (count lst)) lst)
17:27[mattb]probably still a way better way to do this
17:27hiredmanarohner: walk sucks, I think, but that is not really a useful answer
17:27Cozeyor in general to iterate over a seq with a variable bound to current index ?
17:28raek[mattb]: then strings and regexes might be a plausible alternative
17:28gfrlogmattb: I think if you're keeping that much info in your keywords, you should use a different data structure that more naturally represents the data
17:28[mattb]it's just a search function
17:28arohnerhiredman: why does walk suck?
17:28raekkeys don't have to be keywords. they can be of any type
17:28[mattb]aye
17:28technomancyarohner: it's been publicly disowned by its author
17:28gfrlogmattb: yes, but normally keywords are used like enums -- human-meaningful values
17:29[mattb]ah
17:29amalloyCozey: (map-indexed vector lst)?
17:29hiredmanarohner: it is slow and not really maintained and has bugs
17:29gfrlogmattb: if you explain what your keywords mean, we might be able to suggest something simpler
17:29Cozeyamalloy: thank You!
17:31[mattb]I'm mapping a four letter code to a scalar; the user types the four letter code, substituting ? for any unknown letters, and then specifies the scalar to update the collection with
17:31[mattb]if the wildcarded code matches more than one key then it lists which ones match
17:32raekI would use strings as keys here
17:32gfrlogyeah. If you have to work with the codes like that, strings make sense to me
17:32[mattb]k
17:32raekand keywords for named values that only programmers see
17:32[mattb]I figured as well, but someone said to prefer keywords :(
17:32gfrloghiredman: you were suggesting String#indexOf?
17:33amalloyString.contains
17:33gfrlogmattb: yeah, that's the initial advice
17:33gfrlogoh right
17:33gfrlogI got sidetracked thinking he had a Character
17:34gfrlogbut indexOf isn't any better in that case anyhow
17:34raek[mattb]: if the keys are just named values without meaningful internal structure (which seems to be the most common case), then keywords are preferred
17:48tufflaxI have made an array of Vector3fs, and printing that array in the repl shows that it is an Object array. But I'm trying to pass it to a method that takes a Vector3f array, and I get an error. Can the type be the problem? How do I cast/hint that it is actually a Vector3f array?
17:49amalloy(into-array Vector3f (…some seq of vectors))
17:49tufflaxok, thanks
17:49amalloyeg, ##(into-array ["test" "thing"])
17:49sexpbot⟹ #<String[] [Ljava.lang.String;@38d6bc>
17:52[mattb]user=> (find-ant "py?p")
17:52[mattb]("pygp") <-- win
17:52[mattb]thanks for the help gfrlog
17:52[mattb]clojure is awesome!
17:58technomancyit is true
17:58amalloy&(= '(clojure awesome))
17:58sexpbot⟹ true
17:58[mattb]haha
17:58seancorfieldQ about duck-stream/slurp*
17:59seancorfieldit looks like the only difference between that and core/slurp is the former uses a BufferedReader?
17:59amalloymy understanding is that duck-streams are about as old as cobol. is that accurate?
17:59seancorfieldlol... yeah, looks that way
17:59amalloyprobably best to stay away then
17:59seancorfieldso is there a modern equivalent to slurp* ?
17:59hiredmanI have a "Teach Yourself COBOL in 21 DAYS" book holding up my monitor
18:00amalloyseancorfield: what's wrong with core/slurp?
18:00hiredman,(doc slurp)
18:00clojurebot"([f & opts]); Reads the file named by f using the encoding enc into a string and returns it."
18:00seancorfieldi found contrib.io/slurp* as well which seems identical to contrib.duck-streams/slurp*
18:01seancorfieldis there any specific reason to not use core/slurp when this code (congomongo) specifically uses slurp* ?
18:02seancorfieldbasically i'm trying to get congomongo running on clojure 1.3.0 so i'm modernizing the code...
18:02raekseancorfield: strange... duck-streams/slurp* uses a buffered reader too...
18:02seancorfieldraek: yeah, duck-streams/slurp* and io/slurp* seem identical
18:02raekmaybe the docstring reflects what used to be the case before clojure.java.io was introduced
18:03raekseancorfield: clojure.java.io replaces both clojure.contrib.duck-streams and clojure.contrib.io
18:03technomancyactually I think that one even got applied
18:03technomancyanyway, it's misleading in 1.2.0, which is what clojurebot is running
18:04raekI think clojure.core/slurp was improved when clojure.java.io was added
18:04seancorfieldhmm, let me look at clojure.java.io then...
18:04amalloyclojure.java.io is pretty sweet
18:06raekseancorfield: clojure.core/slurp passes its argument to clojure.java.io/reader, so the options that are specified in the docs for the io namespace can be used for slurp too
18:07seancorfieldah...
18:07raek(so you can pass it anything "streamish", and library authors can extend the IOFactory to other types too)
18:08seancorfieldlooks like the default is a BufferedReader anyway which is what the congomongo test needs...
18:08seancorfieldor at least what slurp* actually used to do :)
18:08raeksomeone said something about "when clojure.java.io was introduced slurp got superpowers" :-)
18:08seancorfieldok, congomongo no longer depends on contrib 1.2.0 - yay!
18:09seancorfieldtests still pass too which is encouraging...
18:09raekcool!
18:16amalloyseancorfield: nice
18:16seancorfieldand it runs on clojure 1.3.0 now... sweet!
18:17seancorfieldawesomeness... now i can get back to work and actually _use_ the blasted library!
18:20seancorfieldhmm, still some 1.3.0 incompatibilities in the unit tests :( my work is apparently not yet done
18:20raekwhat is a typical usage for a document-oriented database (like MongoDB, if I understood this correctly)?
18:26seancorfieldraek: well, we plan to use it for storing events (event sourcing), member profiles and probably logging
18:27seancorfieldthose three types of data in our system have rather 'flexible' schemas, to say the least so it's a pita to use rbdms with them
18:45seancorfieldit seems clojure 1.3.0 pays much more attention to arglists metadata than 1.2.x!
18:45seancorfieldcongomongo had ^{:arglists '(arg1 arg2)} which is fine on 1.2.x but needs to be ^{:arglists '([arg1 arg2])} on 1.3.0
18:46SomelauwHi, is there any way to add a docstring to a var without metatags. So something like (def "this var handles shizzle" handle 5)?
18:47SomelauwRight now it is (def #^{:doc "my documentation} varname value)
18:47Somelauwwhich looks a bit verbose
18:49seancorfieldin 1.3.0 you can just do (def "docstring" varname value)
18:50Somelauw,(def "bye" v 5)(doc v)
18:50clojurebotDENIED
18:51raekI thought it was (def name "docstring" value)
18:52raekSomelauw: another alternative is to use defvar from contrib (http://clojuredocs.org/clojure_contrib/clojure.contrib.def)
18:54SomelauwIt seems like I am using 1.2.0. I am using cake.
18:57SomelauwBut maybe I can tell cake to upgrade to 1.3 or something.
18:59raekSomelauw: if you work in a project, you set that in your project.clj
19:00raekSomelauw: control over the versions and libraries to be used is the reason you eventually need to develop in a project
19:01SomelauwI am working in a project. I will try what you said. Preferably I want it to always take the latest clojure version whenever I start a new project.
19:02raek1.3.0 is still under development
19:03raekthe most recent release is 1.2.1
19:03SomelauwAh, I see they are alpha releases.
19:03pdkwhat exactly has 1.2.1 changed while we're at it
19:04SomelauwOkay, thanks. I think I will stick to 1.2.1 and use the metadata method for now.
19:05raekpdk: https://github.com/clojure/clojure/blob/1.2.x/changes.txt
23:58technomancyever wish you could destructure in catch? https://github.com/technomancy/data-conveying-exception