#clojure logs

2010-01-26

00:35scottjIs there a shorter way to write (apply str (apply concat '((\1 \0) "," (\0 \0 \0))))?
00:36hiredmanugh
00:37hiredman,flatten
00:37clojurebotjava.lang.Exception: Unable to resolve symbol: flatten in this context
00:37hiredman,(use 'clojure.contrib.seq-utils)
00:37clojurebotnil
00:37hiredman,(reduce str (flatten '((\1 \0) \, (\0 \0 \0))))
00:37clojurebot"10,000"
00:39hiredmanconcat, I hate the function, as I hate hell, mutable state, and shellfish
00:41hiredmanoh lord, what if flatten uses concat, :(
00:42scottjit seems like there should be a way to say do apply with this seq of functions
01:39RaynesIs there a map for functions with side effects?
01:39RaynesSomething along the lines of (map println ..)
01:40RaynesI could use doseq, but I was wondering if there is a better way.
01:40hiredmanside-effects + keeping the return value?
01:41RaynesIndeed. Like println.
01:41hiredmanuh
01:41hiredmanthe result of println is nil
01:41hiredmanalways, why would you keep that?
01:41RaynesI guess I misunderstood you.
01:41hiredmanfor stuff that is completely side-effects doseq is best
01:41RaynesIn Haskell, we have mapM_ to map a side-effecty function to a list.
01:41RaynesAll I needed to know.
01:41RaynesThank you.
01:42hiredmanif you want to keep a return value, (comp vec map) is pretty good
01:43RaynesI didn't intend to keep the value of println. I simply intended to map println to a list of values.
01:43Raynes:)
01:43Raynes(Just to clarify)
01:45arbschtfwiw, there is also dorun. but doseq is nicer imo
01:48hiredmanfor purely side-effect stuff, without a doubt doseq is nicer
01:48chousershould have been named dofor
01:48chouserhm. or maybe not
01:53qedchouser: i like dofor, but i think it would encourage familiar for-like usage
01:53qedwhich is probably not the best idea
01:55qedscreen -r
01:55Raynesqed: Heh heh. I have a habit of tying "cd channelname".
01:56qed:)
01:56qedi will sometimes throw an ls
01:56qedscreen -r is a new problem
01:56RaynesLikewise.
01:57replacascottj: if you're still here - if the goal is to interpose ","s in numbers, cl-format can do that for you
01:57qedi often use screen -aASU
01:58qedscreen -aASU irc irssi
01:58hiredmanSU are new to me
01:59hiredmanoh
01:59hiredmanno I know S
01:59qed -S sessionname
01:59qed When creating a new session, this option can be used to specify a meaningful name for the session. This name
01:59qed identifies the session for "screen -list" and "screen -r" actions. It substitutes the default [tty.host]
01:59hiredmanwait, I know U too
01:59qed suffix.
01:59qed -U Run screen in UTF-8 mode. This option tells screen that your terminal sends and understands UTF-8 encoded
01:59qedwhoa.
01:59hiredmaninfact I have screen aliased to 'screen -U'
01:59hiredmanand forgot about it I guess
01:59qedyeah i aliased 'sn' to screen -aASU
02:00qedsr to 'screen -r'
02:00hiredman♥ screen
02:00qedsame
02:00qedat work it is the reason im like 40% faster than everyone else
02:01qedi just have open screen sessions everywhere and resume them at will
02:01hiredmanheh
02:02qedwhenever i log into a box it sames "do you want a screen session?" if i hit Y it nests one for me
02:02hiredmanwow
02:02qedand names according to host
02:03greghhas anybody tried tmux (a BSD screen workalike)?
02:03greghI tried it for a while but it's hard to undo 10+ years of screen muscle memory
02:03qednever tried it
02:03hiredmangregh: it's on my radar (since there has been talking of including it in the base FreeBSd system) but I tried it yet
02:04greghit's got some different ideas about sessions and moving them between clients, but I didn't really explore that much
02:04hiredmanapparently you can get configs that set it up screen like
02:04greghI fired it up with the screen compatibility key bindings and it was close but not quite right
02:04qedthe majority of boxes i touch are SuSE, RH, AIX, or Ubunru
02:05qedUbuntu
02:05qedso i stick with screen
02:05qedhiredman: ever AIX?
02:06hiredmanhmmm, no
02:06qedgood. it sucks.
02:06hiredmanvery small amounts of hp-ux
02:06hiredmanalso sucks
02:06qedAIX is based on System V
02:06qedneed I say more
02:07chouseranyone ever use Tru64 a.k.a. Digital Unix?
02:08qedno
02:08qedive used Inferno-OS
02:08qedthat's as exotic as I've gotten
02:08chouserthat's probably more esoteric than Tru64
02:08replacaall this screen talk: http://xkcd.com/686/
02:08qedchouser: have you played with inferno?
02:09qedinferno..sigh..Limbo could have been Java
02:09chouserI was really interested in limbo, once upon a time, but couldn't get my hands on any way to try it out.
02:09qedhttp://en.wikipedia.org/wiki/Limbo_(programming_language)
02:09qedchouser: you're the first person I've *ever* met to have an interest in Limbo
02:10qedwell, outside of that community anyhow
02:10chouserI don't remember how I heard about it, or what alternatives I was aware of at that point.
02:10qedchouser: the ceremony makes it really tedious
02:10hiredmanobviously someone needs to target the dis vm with a lisp
02:11qedhiredman: google summer of code 2010
02:11qedlet's do this
02:12hiredmanhaha
02:12qedthat's how i learned about p9 and inferno actually
02:12qedGSoC 2007
02:12clojurebotwith style and grace
02:12hiredmanclojurebot: indeed
02:12clojurebotGabh mo leithscéal?
02:12qedclojurebot: love
02:12clojurebotI don't understand.
02:12chouseroh, I must have heard about limbo circa 1996
02:12qedexactly.
02:13qedchouser: i'd wager i'm a fair bit younger
02:13qed24
02:13RaceConditionhow much does Clojure differ from Erlang?
02:13qedRaceCondition: a lot...
02:13chouserqed: not quite a decade, then. :-)
02:13qedchouser: :)
02:14RaceConditionqed: it's also incredibly similar, so I'd just like to get a better picture of how these two solve the same problems
02:14RaceConditionErlang apparently doens't allow changing anything and Clojure does... like refs and atoms... so I assume that dosync/transactions thing makes up for that?
02:14qedRaceCondition: their concurrency models are way different, but chouser will probably correct me
02:15hiredmanclojure is targeted at same process multi-core concurrency, erlang is for distributed concurrency
02:15qed(or hiredman)
02:15qed;)
02:15hiredmanI haven't actually written any erlang
02:15hiredmanwiat
02:15hiredmanI did
02:15qedhaha hiredman
02:15hiredmanI did a hello world tutorial years ago
02:16qed"wait...wait...there is directory here which says erlang..."
02:16qed"okay...i've written erlang"
02:16RaceConditionme neither, but I know you can only assign stuff once and in order to change something, you basically make a tail-recursive call with new state built in that swaps out the old function
02:16hiredmanyeah
02:16hiredmanclojurebot: oo sucks?
02:16clojurebothttp://www.sics.se/~joe/bluetail/vol1/v1_oo.html
02:16qedno tail recursion in clojure
02:16hiredmanarmstrong seems like a cool guy
02:17qedhiredman: have you read coders at work?
02:17hiredmanof course!
02:17qedthat's one of my favorite interviews in there
02:17RaceConditionhiredman: btw I just saw a nice presentation about Clojure and funprog/concurrentprog and I have to admit I was surprised by the slight bashing of OO since OO is not just about objects changing state -- its about polymorphism mostly
02:17qed(armstrong's)
02:18RaceConditionHaskell has nice OO and you can't argue Haskell isn't pure functional
02:18qedRaceCondition: it's about time
02:18qed"time"
02:18qedthat's where the bashing of OO comes from
02:19RaceConditionqed: so STATEFUL OO should be bashed, not OO in general, because polymorphism, which is what distinguishes OO from procedural, is orthogonal
02:19RaceCondition...to statefulness
02:19hiredmanRaceCondition: sure, but polymorphism is not only in OO, and OO general brings all this imperative junk
02:19qedthe general OO philosophy includes stateful OO
02:19qedit's how most OO languages operate
02:20hiredmanRaceCondition: have you read the rationale?
02:20qedRaceCondition: http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey
02:20qedRaceCondition: read the rationale or watch that video
02:21RaceConditionqed: I just watched one of that guys presentations
02:21qed"that guy" is Rich Hickey
02:21RaceConditionI know
02:21qedlol
02:21chouserI think it's the "orientation" rather than the "object" that is the problem.
02:21qedjust making sure
02:21hiredmanthe rationale has set of points on polymorphism
02:22RaceConditionand he did cover state and time management in that other demo as well and I completely understand the rationale behind that
02:22qedchouser: what do you mean by orientation
02:22hiredman~rationale
02:22clojurebotrationale is http://clojure.org/rationale
02:23hiredmanit's basically rhickey's N theses
02:23qedwhat really made me stop in my tracks
02:23qedwas the river quote
02:23qed"No man can cross the same river twice."
02:24chouserOO is Object Orientation. Clojure has objects but isn't oriented around them.
02:24hiredmanhttp://clojure.org/state has some stuff about why rhickey didn't use erlang type actors for clojure
02:25chouserpretty much every good and useful feature of OO is available in some form in Clojure, usually a form that is simpler and more cleanly decoupled than standard OO
02:26qedthe abstract ideas about how a cloud, if you watch it, can become three clouds, or disappear
02:26qedthat stuff really resonated with me
02:26chousersounds like nice subject to include in a book. Maybe in Chapter two...
02:26dnolenis ~(symbol (str sym)) the only way to make anaphoric macros work? (I feel like I've learned this like 20x times)
02:27chouserdnolen: ~'foo
02:27dnolenchouser: I get a complaint from compiler if I use that (not the macro, but when I use it later)
02:28dnolenchouser: oh yeah, because it gets qualified
02:28dnolenhow to avoid that again?
02:28hiredmanthen you aren't doing it right :P
02:28dnolenhiredman: i'm not sure what other where there is it do it with anaphora sir.
02:29chouser(defmacro foo [] `(list ~'bar)) (let [bar 5] (foo)) ; returns (5)
02:29qedi still dont get macros
02:29qedbut i havent tried too hard admittedly
02:30unfo-qed, i can recommend Programming Clojure - it has a nice chapter on macros
02:30chouseras long as you're using a language that has them, you'll hardly ever have to write them.
02:30dnolenchouser: huh I swear that is working for me I tried that.
02:30dnolenthat isn't working i mean
02:30qedunfo-: i got sort of sidetracked on programming clojure at about 125p in
02:30hiredmanI see macros on lists of why clojure is great a lot
02:31unfo-qed, p. 211 :)
02:31unfo-qed, read from there on for the macro chapter
02:31qedunfo-: will check it out, thanks
02:32hiredmanI mean, they are neat, but there are so many other features I use more
02:32dnolenmacros: you almost never use them but when you really need one, oooh boy.
02:32qedi dont totally get multimethods yet either
02:32qedwhich seem even more useful
02:32hiredmanmultimethods, java interop, immutable values, sequences
02:32hiredman~multimethods
02:32clojurebotmultimethods seperate the 20% from the 80%
02:33qedhiredman: really, mmethods are 80%?
02:33RaceConditionbtw that {} and [] thing is a read-macro thing?
02:33dnolenchouser: or anyone really, see anything suspicious here? http://paste.lisp.org/display/93916
02:35dnolenwhen I use ~'sym the usage of the macro throws: unable to resolve sym in this context
02:35hiredmanqed: 20% who get it, and 80% that don't, I think is what is implied
02:35hiredmandnolen: you should look at the macro expansion
02:36hiredmanthat exception means there is no binding for sym in the expansion
02:36scottjreplaca: yeah, that was the goal, after writing myself I just ended up wrapping (. (DecimalFormat/getNumberInstance) format 1000.00)
02:36dnolenbah ~(symbol (str sym)) is what I want, ~'sym just puts sym there :)
02:36hiredman
02:36hiredmanisn't that what ~(symbol (str sym)) does?
02:37dnolenno
02:37hiredmanyou want 'sym not sym
02:37hiredmanlike the unevaluated symbol sym
02:37hiredman'~'sym
02:37scottjLearning Clojure wikibook says . is never a valid symbol. What does that mean? :. seems to be, and obviously . itself isn't because symbols start with :
02:37hiredmanscottj: no
02:38scottjs/valid symbol/valid keyword
02:38scottjs/because symbols/because keywords
02:38dnolenhiredman nope, that produces 'sym in the expansion
02:38hiredmanright
02:38hiredmanwhich is what you want
02:38dnolenno
02:39hiredmanyes!
02:39hiredmanyou want the unevaluated symbol sym
02:39dnolenI'll paste the difference to illustrate
02:39hiredmanthat is what '~'sym gets you
02:40hiredmanI understand the difference
02:40hiredmanor not
02:40dnolenthe macro expansion looks different
02:40hiredmanlets see it
02:41dnolen'~'sym: http://paste.lisp.org/display/93917
02:42hiredmanlets see with the (symbol ...)
02:42dnolen~(symbol (str sym)): http://paste.lisp.org/display/93918
02:42clojurebot"if you never learnt Lisp, then you never learned to program" -- some rant on some blog somewhere
02:43hiredmanyou know, I don't think you want a capture
02:43hiredmanyou want the sym that is the argument macro right?
02:43hiredmaner
02:43hiredmanthe macro argument
02:43dnolenhiredman: yeah
02:43hiredmanthat is not capturing that is unquote
02:43hiredman~sym
02:43clojurebotTitim gan éirí ort.
02:44qedall: thanks for the great talk -- have a good night
02:45dnolenhaha: the danger of not writing making in too long a time. you forget even the most basic rules. sheesh
02:45dnolennot writing macros in too long a time
02:45dnolenhiredman: thx
02:45hiredmansure
02:54G0SUBany clojure list admins here?
02:54hiredmanrhickey may be the only one who is an admin
02:55G0SUBhmm
02:55hiredmanmaybe chouser
02:55G0SUBI want to change my email address... but since I am using Google Apps, I can't find any way to do so.
02:56G0SUBSo I thought may be they can...
02:56G0SUBhiredman: btw, is there any way to use the released version of c.c (1.1.0) with lein?
02:57hiredmanyou should be able to add it to the dependencies
02:57qed[clojure "1.1.0"]
02:57G0SUBqed: clojure.contrib
02:57qedoh sorry
02:57qedive been using 1.0
02:57qedi dont know
02:58hiredmanG0SUB: same
02:58hiredmanthe contrib builds are up in the build.clojure.org maven repo
02:58G0SUBhiredman: I get this -- Unable to resolve artifact: Missing:
02:58hiredmanhmmm
02:59hiredmanI think the seperate "release" repo is new, so you might need to add it
02:59G0SUBhiredman: is there any way to add repos?
02:59hiredmanyes
02:59hiredmanit's in the readme, I don't recall off hand
03:00hiredmanI do remember it takes a map of names (Strings) to urls (Strings)
03:02G0SUBhiredman: can't find it/
03:15hiredman:repositories
03:35RaceConditionI have to admit I really enjoy those two of Hickey's presentations on InfoQ
03:35RaceConditionreally enlightening and refreshing
03:35RaceCondition(I hope I won't become a Clojure worshipper after them)
03:37G0SUBhiredman: yep. thanks.
03:50cgrandG0SUB: pushed a new enlive.jar to clojars
03:50G0SUBcgrand: cool. many thanks.
03:50G0SUBcgrand: the version id is the same?
03:52cgrandyup
03:55G0SUBcgrand: works. great.
04:03esjcgrand: quick question - in your kata solution for devlinsf yesterday you called (sift ...) explicitly to recur, why not use recur ? Is it just because for a small solution you don't need to worry about the stack ?
04:06cgrandesj: let me check but I believe it was in a lazy-seq
04:06esjit was
04:07esjso that takes care of it for you
04:07esjyeah, I'm being stupid
04:07esjthanks
04:07esjthe road to understanding, long it is.
04:08cgrandyou can' t call recur through a lzy-seq because the lazy-seq macro wraps its body into a fn
04:10RaynesLazy-seqs make me feel all warm and fuzzy inside.
04:11esjthanks
04:19RaynesI wrote some Python earlier. One function and I still want to hang myself. :|
04:20greghthat's odd
04:29hiredman~python
04:29clojurebotpython is ugly
04:30RaynesI concur.
04:32G0SUBlol
04:37spariev_clojurebot is sure opinionated
04:38esjlol
04:38esj~ruby
04:38clojurebotChunky bacon!
04:38esjnot to taunt or anything
04:39spariev_~java
04:39clojurebot
04:39spariev_lol
04:39esj~clojure
04:39clojurebotclojure is far closer to perfection then python
04:40hiredman:O
04:40Raynes~hiredman
04:40clojurebothiredman is lazy
04:40hiredman~clojure
04:40clojurebotclojure is the bestest programming language available.
04:41hiredman~clojure
04:41clojurebotclojure is the brand
04:43G0SUB~java
04:43clojurebot
04:44Raynes~factor
04:44clojurebotHuh?
04:44Raynes:\
04:46cypher23~scala
04:46hiredmanclojurebot: please tell us about scala
04:46clojurebotUnfortunately the standard idiom of consuming an infinite/unbounded resource as a stream can be problematic unless you're really careful -- seen in #scala
04:47hiredman~scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
04:47clojurebotAny = 1
04:47hiredman ~scala work because clojurebot tries to run scala
04:47hiredmaner
04:47hiredmandoesn't
04:48cypher23ah, ok
05:13esjcgrand: ok, here's another silly question. If (drop-while ...) returns a lazy sequence, why wrap yours in a (seq ...) ? I notice that it nukes destructuring (to the point of killing the code) if you remove it, but can't understand why. What lorry sized hole is this in my understanding ?
05:14esjis is to force the lazy seq to realise ?
05:15Chousukeseq returns nil if the lazy seq is empty
05:16esj,(lazy-seq nil)
05:16clojurebot()
05:16esj,(seq nil)
05:16clojurebotnil
05:16esjfunky
05:16cgrandesj: it has nothing to do with the "-let" (destructuring) part of the when-let but with the "when" part
05:16cgrand,(seq (lazy-seq nil))
05:16clojurebotnil
05:16esjgotcha
05:16esjglad I asked, thanks.
05:27lypanovwell. took a while. but my insanity is over.
05:27lypanovclojure via gwt is the stupidest idea i had in a long time
05:27esj:)
05:28esji love those
05:28lypanovporting clojure itself to js is the only way
05:28lypanovlong showers++
05:29esj(inc long-showers), no ?
05:29esj;)
05:29lypanovno clue, i haven't yet written a single line of clojure :P
05:30esjthen your insanity is far from over !
05:32lypanovthe moment i can slime connect to a clojure instance running in chrome in order to fix a random bug in my webpages layout code
05:33lypanovthats when the insanity is over :)
05:53ivan_chernetskyHi. I've just seen that clojure-contrib moved on to using maven exclusively, so I am curious what's behind this decision? As far as I know using clojure-ant-tasks it is gainable to have a small ant build file. I worry of it because use of maven's complicating the life of distro (at least source-based) package mantainers .
06:03jlris your concern then packaging clojure-contrib projects for e.g. debian or gentoo?
06:10angermancool
06:19ivan_chernetskyjlr: Gentoo.
06:20alexottangerman: there is also #clojure.de channel ;-)
06:21angermanI'm not so certain I want to get localized.
06:21alexottangerman: just fyi
06:21angermanalexott: thanks
06:55Hali_303hi!
07:19AWizzArdIs subseq lazy?
07:23AWizzArdcgrand: do you know why PersistentTreeSet does not implement java.util.SortedSet? That would allow to get .subSets of them.
07:59Leonidas~[6~/win 2
07:59clojurebotexcusez-moi
08:41jcromartieso this is kind of odd...
08:41jcromartie,(clojure.set/difference (set "abc") "abc")
08:42clojurebot#{}
08:42jcromartie,(clojure.set/difference (set "abc") "abcd")
08:42clojurebot#{\a \b \c}
08:42jcromartie,(clojure.set/difference (set "abc") (set "abcd"))
08:42clojurebot#{}
08:42chouserclojure.set operations are for the most part undefined unless you pass in sets
08:43jcromartieok but what about the last one?
08:43chouser,(doc clojure.set/difference)
08:44clojurebot"([s1] [s1 s2] [s1 s2 & sets]); Return a set that is the first set without elements of the remaining sets"
08:44esjits not symmetric
08:44jcromartieI see
08:44chouserso that's a non-commutative "subtract", not a commutative xor
08:44esjwould be easy enough to synthesise with a union of the two differences
08:45esj(union (diff a b) (diff b a) i'd think
08:50jcromartieyeah
08:54cgrandAWizzArd: most methods in j.u.SortedSet return Sets while methods in Sorted return seqs, this make that interface harder to implement -- but no real reason
08:56AWizzArdcgrand: probably the functions in clojure.set will be helpful enough. I just thought it would be nice to have a (subset ...).
08:56AWizzArdsubseq can sometimes be helpful enough though
08:59cemerickusing require with :as is of course far cleaner and polite to those that need to read your code, but wow, using :use when you're just trying to hack something out feels so much more productive.
09:03cgrandAWizzArd: sure, ask rhickey if you can open a ticket
09:06AWizzArdcgrand: yes
09:47jcromartiewould it be reasonable to patch duck-streams to use a temp file?
09:48jcromartiespecifically when spitting to a File
09:50jcromartieI guess that's kind of specific and doesn't fit with the way it handles writers
09:51stuartsierrathat would not be ok
09:52stuartsierracan't guarantee that the process has permission to write anywhere except the file it was told to write to
09:54jcromartiegotcha
09:54jcromartiewell I'm very pleased with my safe atomic spit function :)
09:54jcromartieafter losing a file
09:55jcromartieand after finding a half-written file
09:55chousermaybe an option that allows the caller to specify a tempfile name and/or directory?
09:55jcromartieand atomic-spit just has a nice ring to it
09:56stuartsierramaybe, but that should be a separate function, e.g. write-rename
09:56jcromartiehttp://gist.github.com/286894
09:57jcromartieI just hit some of these safety issues pretty quickly while testing my code
09:57jcromartiei.e. simulating lots of writes and then bringing down the server
10:11AWizzArdstuartsierra: why?
10:11samlis there a library for command line option parsing?
10:12stuartsierraAWizzArd: see http://groups.google.com/group/clojure-dev/browse_thread/thread/7ab69b1d43012917#
10:12samlcommand-line
10:13stuartsierraThinking about making str-utils2/replace a macro that dispatches on types at compile time.
10:14chouserwhoa
10:14chouserreally?
10:14stuartsierraWell, multimethods are slow, and 99% of the time you're going to call 'replace' with literal arguments
10:14AWizzArdhmm
10:15chousersaml: clojure.contrib.command-line is there, though not terribly advanced.
10:15samlchouser: yup. it seems like it binds positional arguments to symbols
10:15stuartsierraIt could fall back on a multimethod if the types are unknown at compile time.
10:15samlthat's all i need for now :P
10:16chouserstuartsierra: by "unknown" you mean "symbols"?
10:16stuartsierrachouser: or expressions
10:16chouserah, sure.
10:17chouserhm, and if you make it :inline instead of always a macro, it could still be used with comp for our point-free friends, map, etc.
10:18stuartsierraHmm...
10:18stuartsierraI'd have to figure out exactly how :inline works.
10:19saml*command-line-args* this is global variable for command line arguments?
10:19chouserstuartsierra: won't take you long. :-)
10:19stuartsierraheh
10:19chousersaml: yes
10:19samloh to get that i need to launch through command line. not in emacs
10:20samlsilly me
10:26samljava -cp clojure.jar clojure.main /path/to/myscript.clj arg1 arg2 arg3 how can I get things before arg1 arg2 arg3 ?
10:26stuartsierraActually, a macro could do compile-time checking for anything.
10:27stuartsierraAny multimethod that dispatches on type can theoretically be resolved at compile time.
10:34chouserstuartsierra: you mean if the args are hinted?
10:34stuartsierrayes
10:34stuartsierraor literals
10:38stuartsierrathe tricky part is how to abstract that into a macro
10:40samlto read text file, do I use java interop?
10:42grammati,(doc slurp)
10:42clojurebot"([f] [f enc]); Reads the file named by f using the encoding enc into a string and returns it."
10:44samlgrammati: thanks
10:45samlhow do I know current working directory of the repl?
10:45chousersaml: but yes, anything slightly complicated and you'll probably have to fall back on interop calls.
10:46chouser(System/getProperty "user.dir")
10:47chouserthe jvm doesn't let you chdir
10:47LauJensen(defn pf [s & args] (println (format s args)))
10:47LauJensenIs there some & related trickery I can do to make this work w/o using a macro
10:48chouserapply
10:52LauJensenhow?
10:52clojurebotwith style and grace
10:56neotykclojurebot: are you the smartest in your family?
10:56clojurebotTitim gan éirí ort.
11:27jcromartieso those of you using Java IDEs... what is your preference: NetBeans or Eclipse?
11:28LauJensenEmacs
11:28LauJensen(sorry, couldnt help myself!! :P)
11:31jcromartie...
11:31jcromartieI use Emacs too.
11:32spariev_I tried IDEA and netbeans Clojure plugins, but Emacs is better
11:33spariev_I'm still the IDEA fan for java/ruby thought
11:34jcromartieNetBeans looks nice on SO X
11:34jcromartieOS X
11:35jcromartieit almost feels like a human being designed it
11:36jasappheh
11:37jcromartiemy concern is in having others collaborate on a clojure project that might not be quite ready for Emacs
11:38jcromartiezero emacs experience makes for fun times
11:39spariev_I believe netbean's enclojure is the most polished Clojure IDE plugin as for now
11:39esjdon't let anybody tell you that emacs stands for esc-meta-alt-ctl-shift, entirely untrue and misleading ;)
11:39jcromartiehah hah
11:39spariev_heh
11:39caljunioremacs schmemacs. :-) I'm having an issue using incanter with TextMate.
11:40jasappI love emacs now, don't get me wrong.
11:40jasappbut learning to use it was one of the most frustrating things I've ever done
11:40jasappafter 7 or 8 years of being a vim guy
11:40caljuniorwhen I try to load incanter in the repl with: (use '(incanter core))
11:41caljuniorI get this exception: java.lang.IllegalStateException: copy already refers to: #'clojure.contrib.duck-streams/copy in namespace: user (NO_SOURCE_FILE:0)
11:43lypanovjasapp: i use viper
11:43caljunioris this the prebuilt incanter version (incanter-app-*.jar clashing with clojure which is actually required for running code from TextMate?
11:43lypanovjcromartie: netbeans. eclipse is ... yeah.
11:43lypanovbut i'd rather suggest idea if you have the option.
11:44caljuniorI realise this is a less than interesting issue.
11:44stuartsierrahey, where's my paste?
11:45stuartsierraCompile-time type-checking multimethods: http://paste.lisp.org/+20HG
11:46cgrandstuartsierra: lispbot seems aphonic since yesterday
11:46jasapplypanov: I tried using viper, but that just made things worse for me
11:46caljuniorgot the answer directly from david liebke: should require not use. thanks David.
11:46jasappI think it was trying to use emacs, viper, and slime
11:46jasappall while trying to learn to use emacs
11:47AWizzArd,(instance? String "x")
11:47clojurebottrue
11:47AWizzArd,(time (dotimes [i 1000000] (instance? String "x")))
11:47clojurebot"Elapsed time: 159.273 msecs"
11:48lypanovjasapp: yeah. its painful. i'm just taking breaks whenever i feel like my skull might crack
11:48AWizzArdInteresting. This dotimes above gives on my system: (class: my/ns$eval__15603$fn__15604, method: invoke signature: ()Ljava/lang/Object;) Unable to pop operand off an empty stack
11:49joeggcgrand: aphonic is a great word. vocab++
11:53esj,(distinct '(1 2 2))
11:53clojurebot(1 2)
11:53esj,(distinct? '(1 2 2))
11:53clojurebottrue
11:53esj?
11:54stuartsierra,(apply distinct? '(1 2 2))
11:54clojurebotfalse
11:54AWizzArdmaybe compile time constants
11:54esjaaah apply
11:54esjthanks
11:58esjwould it be useful to be able to attach some textual explanation to :pre and :post assertion exceptions ?
11:58joeggI want to write a simplex solver to help with my clojure-learning, and I'm having trouble coming with how to represent the system of equations using clojure data structures. Something like a list of maps of variables onto coefficients would probably work, but then I'm worried about the fact these structures are immutable, and I just don't see how I would interact with the thing. Can anyone point me to some knowledge?
11:59esjjoegg: have you tried Incanter ?
11:59esjit backs into a bunch of numerical libraries
12:00esjhas things like linear regressions etc, so you'll find representations such as you're looking for
12:00joeggesj: That's a good suggestion, and I might look to for inspiration, but (and I know this is crazy), I don't want to pull in *any* libraries. The whole exercise is to do it myself, it's a kata.
12:01joeggI will see how they represent these structures, though. Excellent suggestion.
12:01joeggThanks!
12:01esjgroovy.
12:03joeggtechnomancy: Bruce Campbell never mistakes it for a noun. :)
12:04technomancyjoegg: perhaps if it were followed by the sound of a shotgun being loaded the ambiguity would fade.
12:04esj~groovy
12:04clojurebotI don't understand.
12:04esjjust checking clojurebot...
12:06MecHow come you cant chat in here as a guest?
12:06esjspammers
12:06joegg,(do (load shotgun)) (println "Groovy."))
12:06clojurebotjava.lang.Exception: Unable to resolve symbol: shotgun in this context
12:06joeggSomething is wrong.
12:13the-kennydan
12:13the-kennyoops
12:15esjis is possible to customise the sort function applied by (sorted-map ...) ?
12:16esjor is that all kinds a crazy ?
12:16chousersorted-map-by
12:16esj!
12:17esjthanks a ton, that's awesome.
12:17chouserbe careful -- if you say two keys are equal, it'll only store one of them.
12:17esjthanks, that could be unexpected.
12:18chouser,(sorted-map-by (constantly 0) :a 1, :b 2, :c 3)
12:18clojurebot{:a 3}
12:27MecI'm going to lose my mind trying to get an IDE to work
12:31Meccontrib is encluded in my enclojure project but it keeps telling me no contrib classes exist
12:32stuartsierraMec: start with the command line, then work up to an IDE
12:44samlcan I extend a java class in clojure?
12:45samloh java_interop has section about Implementing Interfaces and Extending Classes
13:09noidiis there a way to refer to the current namespace?
13:09chouser*ns*
13:09noidiI have a function called foobar/set! and it worked fine, but now I want to refer to it from another function in the same namespace, and *ns*/set! doesn't seem to work
13:09noidiand just plain set! doesn't work because it's a special form
13:11noidiI get "No such namespace: *ns*" when evaluating the file in slime with C-c C-k
13:11chouseroh. yeah, I don't think you can get away with a var named 'set!'
13:11noidiI can as long as I don't need it within the namespace :)
13:11noidibut thanks, I'll rename it to set-data!
13:11clojurebotclojure-alpha was renamed clojure-master, and this broke most of the projects on Clojars
13:12chouserif it were just a macro of fn, you could get away with it, but special forms will cause you trouble
13:13Chousukenoidi: *ns* is a variable
13:13Chousukenoidi: you'd have to do the.namespace/set!
13:14alexykhow do folks structure something like .clojurerc, to be loaded into each repl?
13:15alexyki.e. how do you auto-load it?
13:15noididepends on how you launch your repl :)
13:15alexykbetter not to depend on it :)
13:16noidithere's the -i command line flag for clojure.main, you could add that to the script than launches the repl
13:17alexykah ok
13:17noidijava -cp ... clojure.main -i clojurerc.clj
13:17BrandonWall right! class path talk!
13:17BrandonWthat is just what i came in here to ask :)
13:18Chousuke:P
13:18alexykclass of 2010
13:18Chousukenote that the classpath was omitted.
13:18alexykthe working class
13:18Chousukein other news, by qnap HDD was making some nasty click noises earlier :(
13:19Chousukeit seems to have calmed down now though.
13:19alexykChousuke: Time Machine!
13:19alexykor gibak
13:19somniumalexyk: if you put a user.clj on the classpath it will get autoloaded
13:19Chousukealexyk: it's RAID1; and a relatively new installation anyway. there's nothing to back up
13:19alexyksomnium: oh! now that's autoloading indeed
13:20BrandonWokay, so i am going through the programming clojure book and i am currently trying to generate a java class file via clojure's :gen-class
13:20alexykChousuke: it hurts even to read of clicking noises! :)
13:20Chousukealexyk: it just sucks. the hdds are about six months old
13:20Chousukealexyk: I have a six year old HDD that's still going strong.
13:20BrandonWthe start of my tasklist.clj file is (ns reader.tasklist, so it is the reader package, class tasklist
13:20Chousukewhat's wrong with modern ones :(
13:20alexykChousuke: we need to add a few terabytes here and there, too. Did you get some cheap SATA?
13:21BrandonWthat file is in com/reader/tasklist.clj
13:21BrandonWi start the clj repl in com directory (with no additional args)
13:21BrandonWtype (compile 'reader.tasklist)
13:21Chousukealexyk: I bought 2*1.5TB from a friend. he still has the receipts though so if the drives fail now I can get new ones through warranty
13:21Chousukealexyk: So I'd rather they fail NOW than after two years when they're full of data and out of warranty...
13:21BrandonWand it says No such file or directory (tasklist:clj:1)
13:22alexykChousuke: hope just one is clicking! there's all those urban legends that RAID'ed disks fail together etc.
13:22BrandonWunfortunately i am coming to clojure from c# :( i had some experience with java in college, but it was academic computer science, so i didn't get much experience with jars and class path. i looked up a bit on google but i feel like i am missing something very fundamental...
13:22Chousukealexyk: it should be jut one. right now, neither is making any noise, though.
13:23Chousukealexyk: but it was a really nasty tick-tock noise it made earlier...
13:23lypanovi sometimes here that for a drivethats been going without issues for 1.5 years
13:23lypanovdunno why
13:24Chousukehmm :/
13:24Chousukenow I ran aptitude and no ticking noises. hm
13:25alexykok to BrandonW's question: should the dirs with the actual files be on the classpath?
13:25jasappChousuke: maybe a little shaking would help
13:25alexykI actually call my namespaces whatever with the dot and don't consider it as a path part or anything
13:25BrandonWfrom teh quick research i did on class paths, i *think* the directory you start java/clj from is added automatically
13:25Chousukejasapp: I'll try that if the clicking resumes...
13:26alexykBrandonW: did you try adding the actual directory containing the tasklist.clj file to the path?
13:26alexyktools like lein repl or maven clojure:repl do that for you
13:26jasappChousuke: I meant to induce more ticking
13:26BrandonWand from what i've read of java classpath usage, it is supposed to be in reverse domain form (e.g. org.clojure.xxx) and it usually maps to directory structure
13:26Chousukehm.
13:26Chousukenow it made a couple ticks again. :(
13:26MecIs there a namespace tutorial anywhere? refer use require import ns *head explode*
13:26BrandonWand i could do that via clj -cp ./reader
13:27BrandonWright?
13:27lypanovBrandonW: fwiw, i don't use classpaths. lein repl takes care of all that for me. i'd suggest trying leiningen therefore if what you really want to do is learn clojure not java classpath nasties :)
13:27BrandonWwell
13:27BrandonWi would like to eventually use it at work if i can
13:27alexykBrandonW: I always load things by their full path, (load-file "meat/subdir/file.clj")
13:28BrandonWin which case i will probably have to deal with class paths anyways :P
13:28alexykmeat is a symlink into the maven guts, e.g. meat -> com/domain/somedir
13:28BrandonWwhen compiling though, you don't give it a full path, you gave it a package/class i think, right?
13:29alexykBrandonW: I don't really compile, you load and it's compiled for you.
13:29noidiMec, what do you find confusing?
13:29technomancyMec: use and import is all you need to get started
13:29alexykthe senior comrades will correct me, but you don't really need to compile clojure
13:29technomancy"use" for clojure code, "import" for java classes
13:29Mechow do I only take a few functions from a lib without using the whole thing?
13:29BrandonWi'm working on the programming clojure book, on the chapter where you generate java class files in teh filesystem
13:30alexykah, ok
13:30technomancyMec: it's best to have something like (:use [clojure.contrib.duck-streams :only [slurp* writer]])
13:30BrandonWso i could load the file, but i would still need a qualified package/class name (i think) to compile it with the compile function
13:30alexykI wish that chapter would move to the end of the book
13:30BrandonWyeah
13:30alexykto non-Java people it's confusing
13:30Mecah hah, i was missing a set of braces
13:30BrandonWi don't know that i would ever generate java class files in clojure, so i wasn't putting much thought into it
13:30BrandonWif class path issues like this normally don't crop up in clojure, then i'm okay with skipping it :)
13:30technomancyMec: (in your ns form at the top; it's different if you're using it outside ns)
13:30alexyktotally unnecessary to throw all that Java crap into the middle of the pretty gugrgling stream of FP
13:30lypanovheh
13:31DeusExPikachuanything like etypecase (from CL) in clojure?
13:31alexykDeusExPikachu: sounds like the name of a protein
13:33DeusExPikachualexyk: heh
13:38alexykDeusExPikachu: cool nick btw :)
13:39DeusExPikachualexyk: I've had it for the longest time, since 2000 I believe, came from the video game Deus Ex and you know what else
13:52alexyk_I notice my repl slow down significantly after some usage. I launch a 64-bit server JVM with compressed references and -Xmx30g, than see it reach 28g usage, then shrink back to 10g, and go 5 times slower on the same database load from mongo. I use transients to assemble the load back. Is there any knob to adjust?
13:52StartsWithKhow do i compare two symbols? (declare x) (defn is-x? [s] (or (= 'x s) (= `x s)) works if i (use) namespace with 'x and 'is-x?, but if i do something as (require '[foo :as f]) (f/is-x? 'f/x) it returns false
13:53somnium,(= 'foo 'bar/foo)
13:53clojurebotfalse
13:54Mec(= (name x) (name y))
13:54somnium,(= 'foo (name 'bar/foo))
13:54clojurebotfalse
13:54somniumdoh
13:54Mec,(= (name 'foo) (name 'bar/foo))
13:54clojurebottrue
13:54hiredmanbut those two symbols are not equivilent
13:54alexyk_that's deep
13:55hiredman.(= 'foo 'bar/foo)
13:55hiredman,(= 'foo 'bar/foo)
13:55clojurebotfalse
13:55alexyk_somnium: did you notice mongo slowdown after usage in the same repl?
13:56somniumalexyk_: Its lightning fast for all my loads, which have topped out around a million entries or so
13:57StartsWithKit works ok if i don't use aliased name, is there a way to force 'f/x to expand to 'foo/x?
13:59somniumalexyk: except when I accidentally print the database without setting print length, thats when I usually go refill my coffee or kill emacs
13:59chouser`f/x
13:59alexyksomnium: if I do that. it would print the whole twitter :)
14:00alexykwould need three tons of coffee
14:00alexykbtw how do I set that print limit again?
14:00somniumset! *print-length* 42
14:01the-kennysomnium: You forgot the parens!
14:01alexyksomnium: I feel like a plumber with a blob of sh*t somewhere. It definitely gets clogged, but whether it's the server, teh JVM, the mongo or the repl, who knows
14:01the-kennysomnium: Did your session ran out of parens?
14:01jasappalexyk: how many tweets are you up to now?
14:01alexykthe-kenny: can you imagine parens? :)
14:02alexykjasapp: I use a research set of 100 million. I have overall a few billions I think.
14:02StartsWithKchouser, how do i call ` my self, as in '(f/x 1) i would like to `f/x first argument only?
14:02jasappany exciting trends you've noticed?
14:03alexykjasapp: a lot of small things. I need to notice something exciting by the KDD deadline!
14:03jasappI played around with twitter for a week until the poor spelling and bad grammar got too depressing.
14:04jasappkdd?
14:04alexykI was effing with transients for a few days before I started to get my data quickly into repl.
14:04somniumI misplaced my father's parens for a moment
14:04alexykkdd.org
14:05alexykjasapp: since Oprah started using twitter in bed, you have no excuse not to
14:05jasapphaha
14:05BrandonWfinally!
14:05BrandonWi figured out my problem :)
14:06BrandonWi got mildly obsessed with figuring the stupid thing out so i had to keep bashing my head against the metaphorical class path wall :(
14:06somniumalexyk: you should team up with these guys >> http://noosphere.princeton.edu/
14:06BrandonWmy problem was i needed to have a classes sub-directory in the directory i started the repl from
14:06BrandonWand that *also* needed to be in the class path
14:07BrandonWso basically, i had to start clj like: clj -cp classes (after already making the classes subdirectory, which didn't exist before)
14:08hiredmanso, exactly what it says to do on the page about compilation on clojure.org?
14:08fractalis/join #emacs
14:08fractalis
14:08fractalisSorry, ignore that.
14:09jasappemacs? who uses emacs? ;)
14:09fractalislol
14:10hiredmanclojurebot: emacs?
14:10clojurebotemacs is an out-moded belief system
14:11technomancyclassics never go out of style
14:11alexyktechnomancy: ran ed on iphone. Did you run emacs on it?
14:11BrandonWah hiredman that would have helped had you linked me to it earlier
14:12BrandonWall i had was the book and (doc compile)
14:12technomancyalexyk: that's against the TOS!
14:12alexyktry to mess up your term and not be able to find the current line. ed saves the day!
14:12BrandonWwhich gave me enough to figure it out, but took a while as a non-java programmer
14:12alexyktechnomancy: that was before Steve Jobs told me to stop it
14:12technomancyI hope he asked nicely.
14:13alexykBrandonW: same here. I just cook the classpath in zsh now. leiningen puts things into lib/ with lein deps, then I say: JARS=( lib/*.jar ); LIB=${(j.:.)JARS}; CLASSPATH="$LIB${CLASSPATH:+:$CLASSPATH}"
14:14alexykand that's it :)
14:14BrandonWthe classes part of the classpath are what screwed me up, i saw classes on the sample shell script of code that came with the book, but i didn't know that i actually had to create the classes directory
14:14BrandonWi thought it would automatically generate it for me or something :O
14:14BrandonWi don't mind it so much now that i understand how it works
14:15BrandonWwhile i was looking around various bits of docs i saw a reference to .clojurerc which i think will be very nice in setting up projects
14:16BrandonWi will check out lein though
14:16alexyktechnomancy: in fact I repented and went back into the warm ATT fold, to sync my stuff with OmniFocus and Things.
14:16BrandonWi've seen that mentioned in various places
14:16alexykand, we have the leiningen field marshal here, prof. dr. technomancy
14:16alexykand it's really cool, except it effs up repl still
14:17technomancyyup... that's due to not being able to get a hold of the original I/O streams from inside a call to clojure.main/repl.
14:17StartsWithKwhy if i do (require '[foo :as f]) (find-ns 'f) it return false, but (find-ns 'foo) return true
14:17BrandonWactually while i'm here, i'm curious: how many people jazz up the standard repl and use that, and how many people use an in-place repl a la swank or vimclojure or the netbeans plugin?
14:17technomancynext release is going to print out a warning when you do "lein repl" and suggest use of swank or nailgun instead
14:18technomancyunless someone comes up with a clever fix post haste
14:18BrandonWalso, now that you have mentioend lein a couple of times and i am checking it out, how does lancet (the build tool you build in programing clojure) compare to it?
14:18BrandonWis lancet useful at all, or is it more of a proof of concept?
14:18technomancyBrandonW: lancet is useful as a library, not as a build tool.
14:18technomancyleiningen uses it to call ant tasks
14:18BrandonWah right
14:20BrandonWwell thanks very much for the classpath help and the pointer to lein :) have a great day
14:23StartsWithKuf.. (defn real-ns [s] (let [sn (symbol (namespace s))] (ns-name (or (find-ns sn) (get (ns-aliases *ns*) sn))))), is there a bether way to do this?
14:27alexyk,(set! *print-limit* 42)
14:27clojurebotjava.lang.Exception: Unable to resolve symbol: *print-limit* in this context
14:27alexyksomething else?
14:27somniumlength?
14:27clojurebotcount
14:27alexykah
14:27alexykclojurebot: don't talk unless talked too, as a good Victorian servant
14:27clojurebota is t
14:27somniumI put all the sets into a (user!) fn in my user.clj so I can forget these things
14:28chouserStartsWithK: s is a symbol?
14:28StartsWithKyes
14:28chouserwhich may have a namespace?
14:29alexyk,(set! *print-length* 42)
14:29clojurebotjava.lang.IllegalStateException: Can't change/establish root binding of: *print-length* with set
14:29StartsWithKyes, but a namespace can be in aliased form
14:29alexykI was wondering if we can hack GAE, but nope
14:29StartsWithKlike 'f/x or 'foo/x in my example
14:30StartsWithKi am looking in "make easier to switch between -> and ->>" patch by cgrand, as it looks like we are doing the same thing
14:31StartsWithKhe has a line "if (and (#{'-> '->> `-> `->>} form) (not (contains? &env form)))"
14:31StartsWithKbut that too will not work if i alias the core
14:31chouser(symbol (namespace (read-string (str "::" s))))
14:32alexyksomnium: thx mucho! the very next print I tried after setting the limit would have printed 100 million things. This user! is a must.
14:32chouserI think what you really want is clojure.lang.Compiler/namespaceFor, but it's private
14:32dnolenis there anything in contrib for converting a string into an inputstream?
14:32StartsWithKwill that pach then have the sam problem as me?
14:32chouser,(with-in-str "hello" (.read *in*))
14:32clojurebot104
14:33StartsWithKit's easy to miss in core as you usualy don't alias it by another name
14:33chouserStartsWithK: I don't see how an alias for core would cause a problem for cgrand's patch
14:34StartsWithK`-> and '-> will not match 'core/-> if clojure.core is aliased to 'core
14:35alexykhow do I list the names defined so far in ns again?
14:35StartsWithKalexyk, (ns-interns *ns*)
14:36alexykStartsWithK: thx!
14:36chouserStartsWithK: ah, I see. if you alias and then try to use the aliased name. hrm.
14:37alexyknow, how can I filter the result of ns-interns by whether it's a function or a value?
14:38alexyk...which is not a function? :)
14:38vagifhello, i'm reading the source code of contrib.sql.internal
14:38vagifhttp://github.com/richhickey/clojure-contrib/blob/master/src/main/clojure/clojure/contrib/sql/internal.clj
14:38vagifand i cannot find where the function resultset-seq is defined
14:39chouser,(map key (filter #(-> % val deref fn?) (ns-publics 'clojure.core)))
14:39clojurebotjava.lang.RuntimeException: java.lang.IllegalStateException: Var clojure.core/*3 is unbound.
14:40chouservagif: it's actually built in -- clojure.core/resultset-seq
14:41StartsWithKalexyk, they are all Vars, if you want to check is valu of the var a function, try (map (fn [[k v]] [k (fn? (var-get v))]) (ns-interns *ns*))
14:42vagifchouser: thx
14:43somnium,(-> 'clojure-is fn?)
14:43clojurebotfalse
14:43somnium,(-> 'clojure-is ifn?)
14:43clojurebottrue
14:43somnium:/
14:44cgrandStartsWithK: (and (#{#'-> #'->>} (resolve form)) (not (contains? &env form))) ; should be better
14:44alexykStartsWithK: thx! I did this to see fns: (->> (map (fn [[k v]] [k (fn? (var-get v))]) (ns-interns *ns*)) (filter second) (map first))
14:44alexyk,(->> (map (fn [[k v]] [k (fn? (var-get v))]) (ns-interns *ns*)) (filter second) (map first))
14:44clojurebot()
14:45cgrand(except that resolve is defined after ->)
14:46chouser,(resolve '(foo bar))
14:46clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
14:47chouserrhickey is mia today. wonder what he's up to.
14:48StartsWithKcgrand, that works in my case too
14:49cgrandchouser: right, (and (symbol? form) (#{#'-> #'->>} (resolve form)) (not (contains? &env form)))
14:50StartsWithKalexyk, just watch for unbound vars, check each 'v with (.isBound v) or you my get a exception when you try var-get
14:51alexykok
14:51StartsWithKtry something like (declare c)
14:52StartsWithKlisppaste8, help
15:08AWizzArd~seen rhickey
15:08clojurebotrhickey was last seen quiting IRC, 1835 minutes ago
15:13chouseroh, he apparently gave a talk at DRW today, whatever that is.
15:16dnolenyes
15:17dnolenoops, ignore that.
15:17alexyk,1835/60
15:17clojurebot367/12
15:17alexyk,(/ 1835 60)
15:17clojurebot367/12
15:18alexyk,(quot 1835 60)
15:18clojurebot30
15:19AWizzArdchouser: good
15:19AWizzArdI just watch him on Channel 9
15:19chouserI can't figure out what DRW is
15:20AWizzArdSoon we’ll know :)
15:20alexykI'm getting objects from a database, then insert into a transient. How can I parallelize it?
15:20jasappI thought of DSW, immediately, for some reason.
15:20chouserAWizzArd: link?
15:20alexykI'd like to have one thread loading things and converting, and another to insert them into the transient when ready
15:20AWizzArdhttp://channel9.msdn.com/shows/Going+Deep/Expert-to-Expert-Rich-Hickey-and-Brian-Beckman-Inside-Clojure/
15:21alexyk"I went deep, man. Deep."
15:21chouserAWizzArd: ah, thanks. yeah, I've seen that.
15:22chouserand twitter posts saying #DRW don't help
15:23alexyksomnium: so there's a clear slowdown, even for the version with the cursor.
15:23somniumwould putting a transient map in an agent and sending it things to conj! from multiple threads be reasonable?
15:24somniumalexyk: how many cores are you working with?
15:24chouseroh! DRW, Cloure funder: http://www.drw.com/
15:24alexyksomnium: since mongo is not parallel yet, I can have only one cursor anyways, right? 8 cores.
15:24StartsWithKwell drw = doctor who :)
15:25alexykWhat really bothers me is that on a virgin JVM, I do my fetch-graph version in 15 minutes; now it will go to 3 hours.
15:25alexykAt some point memory usage was 28g out of 31g, now is back to 12g, and fetch is going very slow
15:25alexyknothing else really happened
15:25somniumalexyk: but you could make 7 mongods
15:25somniumI think
15:26alexyksomnium: true. Would I then divide work by issuing partitioned queries?
15:26AWizzArdalexyk: is that a g as in "gigabytes"?
15:26alexykAWizzArd: yep
15:27AWizzArdis that the amount of RAM your system has?
15:27alexykAWizzArd: it's a 64g box
15:27alexykreally need a 256g for this
15:28somniumalexyk: maybe ask in #mongodb if that would let you get multiple cursors
15:29alexyksomnium: yeah...
15:29somniumyou could do it with one read thread and a conj! agent but I suspect the overhead would neutralize the benefit
15:29alexyksomnium: so any clue what may clog congomongo meanwhile? I do assoc! now instead of conj!, not to waste space twice, btw.
15:30somniumalexyk: hard to say whats happening
15:31alexykan identical fetch slows down 10 times, kind of... I wonder whether we can profile mongo-java-driver and congomongo separately
15:31somniumalexyk: all the other users (who have commented to me) have said its plenty fast enough, but theyre not juggling terabytes
15:32alexyksomnium: it's not terabytes yet! a few puny gigabytes
15:32somniumalexyk: have you tried writing the bottlenecks in java? (the loads)
15:33alexykthe problem is the slowdown on a JVM which is well back under its Xmx, so it's something fishy. Java didn't occur to me... hmm. I'd rather unleash the agents. :)
15:34alexykI did google for "ocaml mongo", but there isn't one yet :)
15:35alexyksomnium: the strangest thing is, as it does it slow fetch, it's decreasing the RAM! Now down to 10g from 12g.
15:36alexykCan it be that congomongo/mongo-java is allocating a lot and then same things are gc'ed?
15:36hiredmanalexyk: you seem to have theories, how collecting some evidence
15:37alexyksomnium: the funny part is, that each graph is mass-insert!'ed in 10 minutes each
15:37somniumalexyk: I have to plead utter cluelessness when it comes to jvm internals
15:37hiredmanenable some debugging options
15:37alexykhiredman: which ones?
15:37hiredmanyou could start with the one to print out GC information
15:38hiredmanyou could also grab a copy of yourkit and profile your app
15:38hiredmanor visualvm, or whatever
15:40somniumalexyk: you could try just calling the java driver from clojure, the driver returns <String><Object> Hashmaps, then write a loop that hammers those into your map, (assuming you know the types in the maps, you may avoid some coercion overhead)
15:41somniumalexyk: the wrapper just unravels maps/lists into keyword->object persistent maps/vector trees
15:43somniumbut I think you may as well try dropping to java if you want to get a baseline for performance
15:43alexyksomnium: do you mean to do it in java? I already work the cursor per your gist, still it uses .toClojure
15:43alexykthe thing is that the final map of maps must be clojure
15:43AWizzArdyou put in type hints I guess
15:43alexykhiredman: thx, I'll check those out
15:43somnium.toClojure does recursive .instanceOf calls to un-nest
15:43AWizzArdwarn-on-reflection set to true
15:44somniumif you know the structure you can avoid the recursion
15:48alexyksomnium: ah!
15:50alexykAWizzArd: what's warn-on-reflection set to true? :) Type hints are not there either, since I'm not sure where to start sticking them in, and everywhere doesn't seem pretty
15:50hiredman~performance
15:50clojurebothttp://clojure.org/java_interop#toc46
15:52AWizzArdalexyk: whenever you have a (.something ...) then it is not clear for which class the JVM should call .something.
15:52AWizzArdYou should type hint that to avoid reflection.
15:52alexykaha!
15:53alexykgood good
15:54AWizzArdif your .toClojure sits in a tight loop and is not type hinted it may run two orders of magnitude slower
15:57alexykAWizzArd: indeed...
15:57AWizzArdja
16:02alexykhey somnium: so I'm using that http://gist.github.com/278490. Should I type hint that cursor is DBCursor, and possibly replace .toClojure by something hand-made?
16:11somniumalexyk: you can type hint the target as #^ClojureDBObject too
16:12alexykok
16:15alexyksomnium: say my collection is of the form, {"user":"John","days":{"1":2,"2":7}}. What would .toClojure be replaced with, roughly?
16:17somniumalexyk: have you read the source of ClojureDBObject?
16:18alexyksomnium: am going to now :)
16:24somniumyou could have the default be "string" -> object, and then have #{"a" "b" "c"} -> map, and so on, sort of pattern matching on the keys in the root map
16:25hiredmanor profile and type hint
16:25somniumusing strings instead of keywords will avoid a little overhead too, the wrapper is aimed at convenience at the cost of a little (usually tolerable) overhead
16:25somnium^^
16:25hiredmaninstead of guessing and flailing your arms about
16:26somniumyeah, we have no idea where the bottleneck actually is afaik
16:28samlhey, how would you replace all \W with white space?
16:28samluse Java Matcher and Pattern ?
16:31alexyksomnium: so the reflections to avoid are, in toClojureVal, are two checks for instanceof Map/List?
16:32avarushi
16:32hiredmanare you even setting *warn-on-reflection*?
16:32hiredmanare you just guessing where you might be using reflection?
16:32somniumalexyk: its the stack-recursion more that the type checking
16:33alexykhiredman: step by step, I'm reviewing now
16:34saml(use contrib.str-utils) yay and re-split
16:34hiredmanwhat does that mean?
16:34hiredmanhave you set *warn-on-reflection* and reviewing what it told you?
16:34hiredmanhave you?
16:35samljava -cp clojure.jar clojure.main hello.clj --execute="(main *command-line-args*)" can I do this?
16:35hiredmansaml: please read the --help
16:35alexykhiredman: I'm speeding-up the alg first; added a type hint for Java method already; then will see what the warning shows
16:35samlhiredman: oh thanks
16:35hiredmanalexyk: stop!
16:36hiredmanjust stop
16:36alexykok :)
16:36hiredmanset warn-on-reflection first
16:36hiredmanadding a million type hints that you might not need is not "working on the algorithm"
16:37jasappit is entertaining to watch, though
16:37somniumhiredman: I think theres only two places he could type hint in the loop
16:37alexykhiredman: true, I mean working with somnium to avoid a generic recursive-reflective call with a hand-made
16:38alexyksomnium: I thought just one? #^ClojureDBObject cursor
16:38hiredmanalexyk: have you set warn-on-reflection?
16:38samlit seems to be impossible to call a function defined in some.clj file
16:39alexykhiredman: once the current load finishes, I will!
16:39hiredmansaml: you are going to have to provide more context than that
16:39hiredmanalexyk: warn-on-reflection is a compile time setting
16:39somniumthe cursor would be #^DBObject, set *warn-on-reflection* true, compile the loop, and it should tell you where the reflection happens
16:40somniumor smthing, DBCursor
16:40samlhiredman: my file ends with ;(main *command-line-args*) I explictely commented it out so that it won't call main function when I require it or load it on repl
16:40samlbut i also want it to be executable from command line
16:41samlhttp://stackoverflow.com/questions/973106/what-is-the-clojure-equivalent-of-the-python-idiom-if-name-main hah!
16:41alexykok, so far I just did (load-file "my-fetch.clj"); will it compile as well or need I do explicit things after warn-on-reflection?
16:41hiredmansaml: this is in the context of your earlier question?
16:42hiredmanalexyk: that will compile
16:42samlhiredman: yes. that link answered me
16:43hiredmanalexyk: keep in mind that it will load and compile my-fetch.clj, but not anything it depends on that is already loaded
16:43alexykhiredman: yep, that's ok. Lovely! oodles of info.
16:47alexykso if a typehint is wrong, Clojure silently ignores it, and reflection is warned about?
16:54alexykin a form, (-> cursor .next .toClojure), how can I typehint that .toClojure is called on a #^ClojureDBObject?
16:54alexykcursor is already hinted as #^DBCursor outside
17:01alexyki.e., the question is on how to syntactically stick a type hint in the middle of ->, or would I have to declare an intermediate var
17:02StartsWithKdo you get a reflection warnning wothout one?
17:03StartsWithK(-> "string" #^String (.toUpperCase)) will preserve :tag on final form
17:04chouserif .next is declared to return a ClojureDBObject, you don't need to hint .toClojure
17:05alexykStartsWithK: yeah, warning on .toClojure... .next returns a java DBObject, on which we need to tack on .toClojure from ClojureDBObject
17:06chouserTry (-> cursor #^ClojureDBObject (.next) .toClojure)
17:07alexykchouser: ok
17:07alexykso in the chain (-> #^TypeHint1 form1 #^TH2 form2) the hints are applied properly to their right-hand forms?
17:08chouseralexyk: judging by the source of ->, as long as the form is a list, yes.
17:09alexykcool. hiredman: thanks for advice, java is running fast after some bitch-slapping! or it may be the fresh JVM.
17:09StartsWithKthat kind of looks like a bug, .toUpperCase when wrapped in a list should pick up meta from .toUpperCase symbol
17:11jasappalexyk: are you timing these, or just feeling better about the speed?
17:11alexykjasapp: I'm timing runs and I have per-million progress throughout all of the code
17:12alexykcrucial for me to see progress bar or I want to kill things
17:12jasappcool, so you can actually quantify how much faster it's going?
17:12alexykjasapp: well I just run under (time ...)
17:13chouserI assume Clojure's deftype is just like C's typedef, only backwards...
17:13alexykthe beauty of clojure, indeed, is how easy is to time things
17:13jasappwhat kind of speed ups are you getting?
17:14alexykjasapp: you see it's hard to tell. On a fresh JVM I get 50 million records in 15 minutes; on a used one, an hour or 3 hours. Who's responsible, I dunno. It's all somnium's fault, if someone asks.
17:15alexykbut, seriously, somnium did a great job. Learning to work congomongo learned me some clojure for real good!
17:16somniumalexyk: its barely 300 lines, you could have written it
17:16alexyksomnium: 300 lines of clojure, that is :)
17:20somniumIm curious about protocols, is a protocol with sig (foo [x]) supposed to be faster than (fn [x] (cond (.isInstance SomeType x) ...)) in the general case?
17:21chousersomnium: yes, I think so
17:22chouserthe latter is essentially what core fns do now (generally implemented in clojure.lang.RT) like 'seq'
17:24hiredmanprotocols are supposed to be more polymophic
17:24avarusmhmh...
17:25hiredmanthe clojure rationale page specificly calls out switch statements (like cond) as being too brittle
17:25avarus-e "(compile 'foo.bar)" would compile file "bar.clj" in directory "foo" right?
17:25jlongsterHey guys, I'm trying to figure out how to list all the files in a directory with clojure. Here's what I've got so far:
17:25jlongster(doto (new java.io.File (str ROOT "/blog/")) (listFiles))
17:25jlongsterBut it can't find the listFiles method. How should I do it?
17:25StartsWithKjlongster, (file-seq (java.io.File. "base-dir"))
17:26hiredmanjlongster: you need to but a . infront of methods
17:26hiredman.listFiles
17:26hiredmanavarus: make sure you read the docs on compiling clojure.org/compilation
17:26devlinsfDid swank-clojure change recently?
17:28jlongsterStartsWithK: hiredman: thanks
17:28avarushiredman: ah ok, so the ns thingy and defn -main is needed, thx :)
17:29hiredman-main is not needed to compile
17:29hiredmanit is needed if you want to have a static main method as an entry point
17:29avarusok
17:30avarusI have no idea, I just want to set up something I can work with to learn the language
17:31hiredmanwhy us compile at all?
17:31hiredmanwhy use compile at all?
17:31hiredmanthere is really no point unless you need it, and you will know if you do
17:32hiredmanclojure always compiles code anyway, compile is just for if you need to keep the class files around
17:32avarusya, I know, java -jar clojure.jar bla.clj sets me up :)
17:33Chousukeavarus: the easiest way to learn clojure is just to run emacs and slime and execute whatever code you want in the interactive REPL buffer :P
17:33Chousukeavarus: setting up emacs can take some time though, but it's worth it if you ask me :P
17:33avarussure bit I hate emacs
17:33dnolenavarus: probably the "easiest" thing to do is setup lein, then you can just do "lein repl"
17:33dnolenlein comes with jline so interacting with the REPL isn't too tedious
17:34jlongsterIs there something that splits an absolute path into a directory name, filename, and extension, or should I use regular expressions?
17:34avarusexecuting java isn't too hard either :)
17:35hiredmanthe repl can use jline and rlwrap without needing lein
17:35hiredmanlein forces you to have project
17:35hiredmansome times you just want to run some code
17:35hiredmanavarus: vim?
17:36avarusna, gedit :P
17:36hiredman:|
17:36hiredmananyway
17:36avarusI press some key and I see the output
17:36avarusthat's good enough
17:36hiredmanreally, gedit does that?
17:36dnolenhiredman: only partly true
17:36avarusand I was experimenting with building the jar
17:36avarushiredman: ya
17:36dnolen"lein new whatever; lein repl"
17:36dnolensorry
17:36hiredmandnolen: so now you have a whatever directory
17:36avarushiredman: it's a plugin called external tools :)
17:36dnolenbut you can always go there for repl fun
17:37dnolen"lein new fun; cd fun; lein repl"
17:37StartsWithKavarus, did you try cream? (vim configured as normal editor, vimclojure should work with it too)
17:37hiredmanjava clojure.main
17:37dnoleneasy to remember to.
17:37hiredmanmuch easier
17:37hiredmanworks anywhere
17:37hiredmanclojurebot: dirt simple
17:37clojurebotNo entiendo
17:37the-kennydnolen: You forgot "lein deps"
17:37hiredmanclojurebot: dirt simple clojure
17:37clojurebotclojure is like life: you make trade-offs
17:38hiredmanclojurebot: are you kidding me?
17:38clojurebotPardon?
17:38the-kennyOr does lein that now by itself?
17:38dnolenyou don't need that the-kenny: just tried it, seems to work okay
17:38the-kennydnolen: Oh cool
17:38avarusStartsWithK: no, but I read about it some time ago
17:38dnolenactually
17:38dnolen"lein repl" works no project necessary SWEET
17:39avarusit's ok that way...I was only confused about the compiling stuff :)
17:39avarusI thought that was needed
17:39avarusyou told me it's not, I tested it, and it works :)
17:39hiredmanclojurebot: dirt simple clojure
17:39clojurebothttp://www.thelastcitadel.com/dirt-simple-clojure
17:40avarus:)
17:40the-kennyUh, the font is way too small here
17:40avaruslol
17:41the-kennyI like step VI
17:41hiredmanI don't see how the font could possibly be too small
17:42avarusit's too big :P
17:42Chousukehiredman: then it is too small, obviously!
17:42avarus:>
17:42hiredmanyour monitor is obviously too small
17:43Chousukeyes it is. also it makes a whining noise
17:43the-kennyhiredman: hm. Maybe I hit Cmd-- some time ago and my browser remembers this setting during visits
17:43hiredmanat the office here two people already have 28"
17:43Chousukeseriously though, that font is huge :P
17:44hiredmanit's not that big
17:44Chousukewell, I currently have 13.3" & 17" CRT
17:44hiredmanit's like 12pt
17:45the-kennyhiredman: hm.. if it's 12pt, I must accidently typed Cmd-- some time ago
17:45hiredmanmaybe 16
17:45dnolenlooks huge to me to
17:45dnolenmore like > 24
17:47hiredman*shrug*
17:47hiredmanwhat browser/os?
17:48hiredmanlooks fine in firefox on windows and freebsd
17:48hiredmanalso chrome
17:48hiredmanand msie8
17:49hiredmando you all have macs or something?
17:49avarusI don't
17:50somniumits huu-uuu-uuge on chrome/linux too :)
17:52hiredmanwell, y'all should fix your browsers
17:52ahamaywhich library would you use to write a parser in clojure?
17:53hiredmanclojurebot: parse?
17:53clojurebotPardon?
17:53hiredmanclojurebot: parsing?
17:53clojurebotI don't understand.
17:53hiredmanclojurebot: how much do you know?
17:53clojurebotI know 535 things
17:53hiredmanhmm
17:54ahamay:)
17:55the-kennyclojurebot: skynet
17:55clojurebotI will become skynet. Mark my words.
17:55hiredmanparser?
17:55clojurebotparser is http://github.com/joshua-choi/fnparse/tree/master
17:55hiredmanclojurebot: jerk
17:55clojurebotIt's greek to me.
17:56ahamayfnparse seemed a bit cryptic to me - but maybe I just need to get used
17:56hiredmanthere is at least one other parser library, fnparse is the only one I have used
17:57hiredmanfnparse does tend to shift out from under you
17:57hiredmanrelease to release it can vary significantly
17:57ahamayic
17:57ahamayguess you mean http://kotka.de/projects/clojure/parser.html
17:57ahamaybut the download's broken there
17:59ahamayok thx, guess I'll stick to fnparse for the start
17:59the-kennyUhh I'd love a parser like parsec for clojure
18:01ahamayyeah, that's what I was hoping for, too
18:02ahamayI even checked on JParsec - but to me that seemed closer to JavaCC than Parsec :(
18:02hiredmanclojurebot uses fnparse
18:02hiredman(badly)
18:04ahamayafter looking at the fnparse tutorial, it seems to do the job okay
18:04ahamayI just got scared by looking at the JSON example immediately :)
18:10somniumany monad enthusiasts on?
18:11DeusExPikachuwhat's the right way to go about this, I want to create objects for the purpose of creating identities and I want to create a tree datastructure populated with these objects using sequences and other objects, I want to be able to traverse the tree and dispatch based on the class. Now I don't think there is a way to define classes in clojure that I'm aware of, is this the time to use 'derive, thoughts?
18:12avarusgood night
18:16ahamaysomnium: I'm a bit into monads and this category theory stuff
18:16ahamaythough I'm not an expert
18:18ahamayDeusExPikachu: won't multimethods be all you need? Or did I get something wrong?
18:19DeusExPikachuin case it helps with the explanation, I'm trying to write a very expressive PEG parser generator where the PEG is expressed in this hybrid form of clojure code and these objects that are identities for certain operators
18:19DeusExPikachuahamay: the idea is to use multimethods and dispatch on class, but I dont' know how to define a class
18:20ahamayyou don't need classes
18:20DeusExPikachuI really can't dispatch on anything else but a class cause a class in my case will be the most unique
18:20DeusExPikachueverything else can potentially be unintended if something else matches in the clojure code
18:21ahamaydid you read up about ad-hoc hierarchies and stuff?
18:21DeusExPikachuI've been reading it but still don't quite understand the usage
18:22ahamayor how about having a :type field with a keyword in it?
18:22hiredmanDeusExPikachu: I still don't see why you would dispatch on a class
18:22hiredmanuse a keyword
18:22ahamay{:type my-type-a :data 42}
18:22DeusExPikachukeywords can potentially clash
18:23DeusExPikachuI'd have to make it part of the contract that the user not create any code that evaluates to a map with the keyword type
18:23hiredmanyou can namespace qualify keywords
18:23DeusExPikachuhmmm, true
18:24DeusExPikachuhmm I think that solves it for now
18:24DeusExPikachuis that the general way to prevent clashes?
18:25hiredmanI don't think preventing clashes completely is a good idea
18:25somniumahamay: I have multimethod with sig [x y] dispatching on x, and all methods return [(f x) updated-y], and callers always merge updated-y onto y, kind of passing an environment up and down the stack
18:25hiredmansome users may want to clash for some reason
18:26somniumusing macros and map-destructuring to chop at the boiler-plate, but wondering if its a good spot for a monad (which I still dont really get)
18:26DeusExPikachuwell from a developer standpoint, I don't want clashes interfering with the interface
18:26ahamaythat indeed sounds like monad usage, yes
18:27ahamaythough actually I haven't yet looked at the clojure module for it
18:27ahamayI was doing Haskell before
18:27DeusExPikachuexcuse me, I mean interfering with my lib's interface
18:27hiredmanDeusExPikachu: but somewhere downline the line someone using the software may want a clash for some reason, best to leave them an out somehow
18:28hiredmansure, prevent accidental clashes
18:28hiredmanwhich namespacing does
18:28DeusExPikachuok, so I guess its idiomatic enough then, thanks
18:28hiredmanbut let people clash if they really really want, even if breaks stuff
18:28ahamayI think http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html helped me a lot for understanding
18:28DeusExPikachuwell they can clash it if they want to create a fully qualified keyword now then
18:28somniumahamay: thanks, will read
18:28hiredmanDeusExPikachu: exactly
18:29DeusExPikachuso I think it fulfills what you are talking about in my case too
18:32ahamaysomnium: I just found http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/ - did you already look at these?
18:34somniumahamay: yes, I think I got the principles, but havent tried using them in practice yet. maybe this is a good opportunity
18:35somniumright now I have a def-envfn macro and a call-envfn macro, and suspect Im reinventing something poorly
18:36hiredmanmaybe an evaluator
18:37somniumhiredman: the mechanism, not the application
18:37somniumhiredman: it is indeed an evaluator
18:40technomancyRaynes: JavaMail is actually very true to the spec. it's the spec that's causing those headaches; it's insane.
18:40ahamayif nothing else, understanding monads gave me a good feeling :)
18:42hiredmanyeah
18:42hiredmanemail is old and crufty
18:45technomancy"you have to remember, this was invented twenty years ago, before people were smart."
18:45technomancyaccording to dysinger =)
18:46hiredmans/smart/experienced/
19:04the-kennyIs congomongo still the "best" client for mongodb?
19:19Raynestechnomancy: Do you have experience with receiving email in JavaMail via Clojure, by any chance?
19:21technomancyRaynes: not directly via IMAP or SMTP, just parsing it from disk.
19:22Raynestechnomancy: http://gist.github.com/287405 I'm confuzzled as to why it wont let me return mseq because I've closed the folder. I process the emails while the folder is open (mostly toStringing java objects) to stuff I can use.
19:22RaynesI can't figure it out.
19:23RaynesBut I can do whatever with mseq as long as it's before I close the folder. It's confusing, because I don't actually store any Message objects or anything in mseq.
19:23technomancyRaynes: actually you're processing them after the folder is closed
19:23technomancyclojurebot: map?
19:23clojurebotmap is lazy
19:23technomancyRaynes: ^^
19:23RaynesOh shit.
19:23technomancyhehe
19:23RaynesHehe.
19:23Raynes:>
19:24RaynesYou've saved the day.
19:24technomancylast time I made that mistake clojurebot was all: map is *LAAAAAZY* and made me feel more like a doofus. kids these days have it so easy. =)
19:25Raynes:)
19:26DeusExPikachutechnomancy: do you frequent google groups swank-clojure? I posted a bug a day ago, was wondering if you looked into it yet
19:26Raynestechnomancy: What is the preferred way to force evaluation in this particular situation?
19:26technomancyDeusExPikachu: I'm just swamped... behind on all my projects. =\
19:27technomancyRaynes: wrap map in a doall
19:27DeusExPikachutechnomancy: ok, just curious
19:27RaynesAlright. Thanks. :)
19:27technomancyDeusExPikachu: I will probably get to swank-clojure after I make the next leiningen release
19:28RaynesYay! It works.
19:33Raynestechnomancy: How does lein test work? It appears that it only looks for a tests.clj file, and if it isn't there, it fails.
19:35the-kennyUhm.. any congomongo-developer here? Why does (databases) return a java ArrayList instead of some clojure-seq?
19:36technomancyRaynes: if you give it a list of test nses as CLI args it will use those, otherwise it uses every namespace in the tests/ dir
19:37RaynesI tried making a testsomething.clj file with ns testsomething, but it didn't see it.
19:38RaynesI'm new to unit testing, so I've probably done something wrong.
19:38RaynesI'll figure it out later. :>
19:38technomancyRaynes: doing "lein new" on git master will spit out something with the correct structure
19:40the-kennyhm.. I have to go to bed. I'll file a bug.
19:40Raynestechnomancy: Not sure what you mean.
19:40the-kennyNight
20:53dnolenso do people agree that eval is the only way to accomplish "introspection" when writing macros? that is it's most straightforward to reflect on the current environment
20:53dnolen?
20:54chouseravoid eval
20:55chouser'resolve' isn't quite as bad, though still not always what you want.
20:55chousernow you can look at &env as well
20:55dnolenchouser: oh yeah, care to explain how &env works? I guess it's what I need
20:56dnolenin the past I used eval or resolve because I didn't really know any other to look up the value of previusly defined symbols.
21:00hiredmanerm
21:02chousera macro that depends on the *value* of a var or locall is suspect
21:03dnolenchouser: I'm reading a file's contents to produce the code for a function
21:05dnolenI'd like to avoid what I'm doing but I don't "see" how.
21:05dnolenthus the ^ question
21:06dnolenbasically I'm introspecting on the contents of an HTML file to produce an Enlive template. I want the code to be pretty terse
21:06dnolen(templ name *path*)
21:16chouserhm. Well, examining data to produce code and then eval'ing it isn't necessarily wrong, but I don't see what that has to do macros.
21:17dnolenchouser: well in order to produce the proper syntax of an Enlive template I need a macro.
21:17dnolenbasically I'm looking up all the CSS ids, and automatically generating the template to match them so they can be replaced by pass a map to the template.
21:18dnolenpass -> passing
21:42mquanderwhat's the clojure equivalent of letrec?
21:43mquanderthat is, a let that allows me to bind one variable and then bind another based on the value of the first, hopefully without unnecessary nesting
21:43mquanderoh, i think it's "let".
21:51qedwhy is it suddenly surprising to some bloggers that leiningen is the community's build tool of choice
21:51qedive been operating under that assumption for 3 months
21:54qedwhy would you use maven or ant?
21:55qedhow have java developers put up with them for so long?
21:55dnolenqed: perhaps because you want something smarter/robust? I like lein because it's simple.
21:55dnolenpersonally I think lein has some issues but I imagine they'll be worked out over the coming months.
21:55qedi had no java experience prior to clojure -- but it just baffles me that people used to actually write these gargantuan xml pieces of crap
21:56qedno thanks.
21:57qedlein definitely has some issues
21:57qedbut the issue it doesn't have is making the build process a complete fucking bummer
21:57qedexcuse my french
21:59qedi guess i was just surprised people didn't see lein being the standard months ago
22:00qedto me it was always the clear winner in build tools
22:02qedtbqh being a newbie to clojure and java at the same time, i dont know if i ever would have created a single tangible runnable application in clojure if it weren't for lein -- maven, ant, etc. just looked like complete crap to me, a waste of time to learn
22:03qedlike "here, sift through this mountain of garbage to piece together a tiny working piece of distributable code"
22:03mquandernewbie q: is there a lazy-mapcat somewhere that i can use as shorthand for (lazy-cat (map #(lazy-seq (my-real-mapping-fn %)) xs))?
22:03qed</rant>
22:04mquanderer, i know i could actually just use concat there not lazy-cat
22:04hiredman,(doc mapcat)
22:04clojurebot"([f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection."
22:04qedthere's a mapcat iirc
22:04mquanderi just don't like having to wedge the lazy-seq into my mapping lambda
22:04mquanderoh, yeah, i guess i can use that to shorten it on front
22:04mquanderthat's pretty good then
22:05hiredmanyou know map is lazy right?
22:05hiredmanhaving lazy-seq there makes no sense
22:05mquandermap is lazy? heck no i did not know that
22:05qed:)
22:05mquanderthat is awesome
22:05hiredman,(doc map)
22:05clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
22:06mquandergeez problem annihilated then
22:06hiredman
22:06qed:|
22:07qedthe clojure spirit sometimes wraps me up, swallows me whole, and spits me out
22:07qedit's like christmas, except real
22:07hiredmanmquander: I don't think lazy-seq does what you think it does, so until you read up on it, I would pretend you hadn't heard of it
22:08hiredmanmost of the functions that operate on sequences use lazy-seq internally, so you should not worry about it at all
22:08mquanderok, i see. i didn't realize that.
22:08qedwhat did lazy-seq used to be?
22:08qedlazy-cat was it?
22:08hiredmanlazy-seq does not magically make a seq lazy, the seq has to be constructed using lazy-seq
22:08hiredmanqed: lazy-cons
22:09qedah yes, thanks
22:10hiredmanbut that changed long ago
22:10qedwhere long ago == 4 months
22:11mquanderif map is lazy, then why does this happen?
22:11brweber2,(println "hey folks")
22:11clojurebothey folks
22:11mquander(defn expensive-operation [n] (print "foo") n)
22:11mquander(first (map expensive-operation [1 2 3])) ;; prints "foo" 3 times
22:12qed,(source println)
22:12clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
22:12hiredmanmquander: oh, complain to rhickey about it
22:13qed,(doc prn)
22:13clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
22:13hiredmanmquander: http://www.assembla.com/wiki/show/clojure/Chunked_Seqs
22:14alexykhow do you convert a :10 to number 10?
22:15hiredmanhttp://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
22:16mquanderi see. thanks hiredman
22:16dnolen,(Integer/parseInt (name :10))
22:16clojurebot10
22:16dnolenalexyk: ^
22:16qedalexyk: well done sir
22:17qedi couldnt find that
22:17alexykqed: dnolen did it!
22:17qedoh oops
22:17qeddnolen: you're a champ. i love you.
22:17qed(alexyk is okay, too)
22:18alexykqed: cheers!
22:18qedto clojure!
22:18alexykGlenfiddich all around!
22:18qedso im not the only clojurist with a penchant for scotch
22:19qedalexyk: where are you from?
22:19alexykNew England. Formerly Russia...
22:20qedah -- well, next time im out east i owe you a drink
22:21alexyk:)
22:22alexykwe can go visit cemerick too
22:22qed!!!
22:22alexykin his MA hamlet
22:22qednot the vietnam-type hamlet
22:22alexykhamlet is a processed piglet
22:22qedor the shakespearean hamlet
22:22alexykor when-let
22:23alexyk(hamlet [ham (...
22:23qedi can get behind ham
22:23alexyk(hamlet (to-be ...) (or (not( to-be ...
22:23qednot literally
22:25qed(def to-be true)
22:25alexykthat's optimism!
22:26qedhaha
22:26mquander(def the-question (or to-be (not to-be)))
22:26mwilliams_~seen technomancy
22:26clojurebottechnomancy was last seen quiting IRC, 72 minutes ago
22:26mquandera sufficiently smart compiler would just optimize hamlet's question out imo
22:26qedalexyk: im trying to start up an Erdos-esque travel schedule
22:27qedcan I come visit you with a suitcase and amphetamines in-tow?
22:28alexykqed: you have to sell off all possessions then and live out a backpack. I got two small kids though which only eat healthy stuff; but the Appalachian trail passes right next to our house, and shadowy bearded types spend the nights in small tents in the snow...
22:29qedthe trouble with computer science is you need a computer to test it
22:29qedi wish i could get rid of this damned thing
22:29alexykqed: that's the paradox of a computer scientist. To teach the stupidest and dumbest machine to do what a 5-year old kid knows.
22:30qedi should write a book about doing CS for a year without a computer
22:30alexykqed: well you can have iPhone with IRC and ask people to compute for you
22:30qednah that'd be cheating
22:30clojurebotis_rhickey_a_minor_god is yes
22:31alexykor you can leave sexps to be eval'ed on scraps of paper
22:31qedi have so many books and junk downloaded -- i just need to print it all and disconnect
22:31alexykqed: printing is old, stuff it into kindle
22:31mquanderleaving paper in public place, waiting for someone to write response on it = very lazy evaluation
22:31alexykor Apple tablet coming tmrw
22:32qedmquander: lol,
22:32alexykmquander: right, and responses might be in any FP language, like Erlang or OCaml
22:32qedthe apple tablet is going to be a disappointment and i know it
22:32alexykqed: I wouldn't be so sure
22:32qedif it isn't eink, i dont care about it :(
22:32qedi doubt they have a dual purpose screen
22:32qedif they do ill buy one on the spot
22:32alexykqed: well, in fact I prefer to read off my iPhone instead of a Kindle DX
22:33qedalexyk: yes, but you're absolutely mad
22:33qedso who would trust your opinion?
22:34alexykeink works for hours on end to read, then I do the DX
22:34alexykqed: well, I'll take it as a compliment for now :)
22:34qed:)
22:34qedhave you read Logicomix?
22:34qed(highly recommended)
22:34alexyknever heard of it
22:34qedthe first and only graphic novel ive ever read
22:35qedhttp://www.logicomix.com/en/
22:35mquanderi want device with touchscreen, hardware keyboard that folds up underneath it but can extend to a normal laptop form factor
22:35qedi want a device that doesnt run iphone OS
22:35mquanderthat too :X
22:35qedbecause it clearly sucks
22:36qedcan you imagine a 10" screen covered in apps?
22:36qedwhat a waste of machine
22:37qedunless i can compile and run emacs23, Terminal.app, and chrome -- ill pass
22:37mquanderi just want something light and small that i can both program on and draw diagrams on
22:38qedmquander: i think we're thinking alike here
22:38qedi played with the iphone liberally -- adding ssh to it, installing stuff on it, like GHC and such
22:39qedbut it was never that mythical machine that this tablet could potentially be
22:39qedthe rumors suggest it runs iphone OS
22:39qedwhich makes it completely sad
22:39mquanderonly source i saw for that one was some textbook CEO on cable news
22:39qedyes the mcgraw hill asshole
22:40qedhopefully he is wrong about the iphone OS
22:40mquanderas if that guy can tell an OS from his rear end
22:40qedthe mcgraw hill guy, regardless of what OS the tablet runs, needs a new rug
22:40qedthat thing was atrocious
22:40mquanderanyway, if it runs mac OS, i would expect them to cook up some custom UI on top of it, sort of like smartphones and like that windows media center thing
22:41mquanderso probably textbook guy would be clueless as to what was under the hood
22:41qedyeah, that's to be expected, id be very happy with that
22:41qedbut if it's just iphone OS, 10 inches big
22:41qedthat's going to be a very sad state of affairs
22:41qed(until it's jailbroken)
22:41mquanderthat would be really lame, until jailbroken.
22:41mquanderi feel guilty about buying apple products when they contribute to this lame walled garden stuff
22:41mquanderi wish the products weren't as good as they are
22:42qedmquander: the next phone i get wont be apple
22:42qedhello N900
22:43mquanderlikewise.
22:44qedapple really set the stage for such a phone
22:44qedbut it doesnt change the fact that apple is now being outclassed by their competition in features and extensability
22:45qedmy dream: a tablet with really revolutionary tactile feedback mechanism -- a full OS with a layer of software to make it easy to use via touchscreen
22:46qedim big on my keyboards. im certainly the minority here i think, but im typing on a 250$ keyboard. why? feedback.
22:47qedthe touch screens are a joke
22:48qedwithout feedback or a neural interface the'll always be substandard
22:55alexykwhen I call (map ... <some map>), the map is seq'd. If I do (pmap ... <some map>), will it seq first or do I have to seq manually?
22:57alexykI see it mostly at 100%, 400-500% inly blinks for a moment
22:57alexykonly
23:01alexykI run pmap on a seq of pairs, then join them as a map with (into {}). Given keys don't overlap, is there a faster way?