#clojure logs

2010-12-12

03:07kumarshantanuhi, is there a shorter way to write this: #(and (number? %) (pos? %))
03:38pppaulwrite your own function and call it (positive-number?)
03:39kumarshantanupppaul: that's what I just did :)
03:39pppaulyou may be able to get away with just (pos?) no?
03:39kumarshantanu,(pos? :hello)
03:39clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number
03:39pppaulewww
03:39pppauloh well
03:42kumarshantanuis there a function to find out the index in a vector? (foo [:a :b :c]) --> [0 1 2]
03:43kumarshantanunot exactly like the foo above, but some variations
03:43G0SUBkumarshantanu: you mean given [1 2 3] and 2, the result should be 1?
03:44kumarshantanuG0SUB: I want to find out the indexes of positive numbers in a vector
03:45G0SUBkumarshantanu: there is no built-in fn for that, but can be written trivially.
03:58G0SUBkumarshantanu: did you write the function?
03:59kumarshantanuG0SUB: almost..I zipmap'ed (take elem-count (iterate 0)) and the vector
04:00kumarshantanuand then filter'ed to find out which keys were affected
04:01kumarshantanunot sure if this is the most efficient way though
04:03kumarshantanus/iterate 0/iterate inc 0/
04:04G0SUBkumarshantanu: you can use for. let me give you a quick example.
04:05kumarshantanuG0SUB: sure
04:08G0SUBkumarshantanu: http://paste.lisp.org/display/117598
04:12kumarshantanuG0SUB: version 1 is cool (short) but it returns the indices in reverse order
04:12kumarshantanuversion 2 maintains the order
04:12kumarshantanuboth are cool though
04:12G0SUBkumarshantanu: yes. you can do a reverse on it if you care about the order.
04:13raekthere's map-indexed in core too...
04:13raek,(doc map-indexed)
04:13clojurebot"([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thu...
04:14G0SUBraek: yes. that got added in 1.2. completely forgot :)
04:15raektoo bad stuarthalloway's 'indexed' from Programming Clojure isn't there
04:15kumarshantanulearned today -- map-indexed and remove (I should be reading the core/docs often)
04:16raek(defn indexed [coll] (map vector (iterate inc 0) coll))
04:16kumarshantanuG0SUB: thanks!
04:16G0SUBraek: yes, that's useful when the fn takes k & v
04:16G0SUBkumarshantanu: you are welcome.
04:17raekto just get the indices, consider ##(range (range 0 (count [:a :b :c])))
04:18sexpbotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to java.lang.Number
04:18raek&(range 0 (count [:a :b :c]))
04:18sexpbot⟹ (0 1 2)
04:19G0SUBkumarshantanu: (defn take-idx-when [coll pred] (remove nil? (map-indexed #(when (pred %2) %1) coll)))
04:19G0SUBkumarshantanu: that should solve your problem.
04:21kumarshantanuraek: G0SUB: yup, this is cool
04:22kumarshantanuG0SUB: is it idiomatic to place pred after coll?
04:24G0SUBkumarshantanu: no. put the coll after pred. In this case, IMHO pred should come first.
04:24kumarshantanuG0SUB: okay
04:42kumarshantanuG0SUB: found a shorter version -- (keep-indexed #(if (pos? %2) %1) [-9 0 2 -7 45 3 -8])
04:42kumarshantanu,(keep-indexed #(if (pos? %2) %1) [-9 0 2 -7 45 3 -8])
04:42clojurebot(2 4 5)
06:20kumarshantanudoes println work asynchronously is 1.2?
06:20kumarshantanus/is/in/
06:20sexpbot<kumarshantanu> does println work asynchronously in 1.2?
06:45auserhola
06:45auserwhat does the '*' (star) mean after a function
06:48kumarshantanuauser: generally used for helper implementation fns
06:49ausernot sure I understand... what does it mean though?
06:51kumarshantanuauser: assuming 'foo' is the function that is for public use, foo* is the functin that actually carries out the job and 'foo' just delegates the work to foo*
06:51auserah
06:51kumarshantanu'foo' calls 'foo*' to the actual work with some pre-configuration
06:51auserso it really could be either, but foo* used inside the namespace doesn't have to push off to the delegate
06:51ausercool
07:02auserthanks kumarshantanu
07:03auserI've got one more question... is there a way to "fork" off a process?
07:04auserI want to continuously poll for a queue to see if there's an item in it (unless I can "push" from the queue)
07:05ausermaybe like an agent
07:05auser(from: http://faustus.webatu.com/clj-quick-ref.html)
07:06kumarshantanuauser: not a process, AFAICT
07:06auser(sorry, I come from the erlang world)
07:06kumarshantanuauser: but you can use threads, whiich is what jvm supports
07:07kumarshantanulook at ConcurrentLinkedQueue
07:07auserk
07:08auserSo you're suggesting I fork off a thread that does the "take"
07:08kumarshantanutehnically you can, but forking off a thread is not so inexpensive as BEAM
07:09kumarshantanuso you can use a task executor thread-pool during the runtime of the operation
07:09auseryeah... that's one thing I'll miss with erlang in this current project
07:09auseroh. okay?
07:09kumarshantanua thread-pool maintains a pool of runnning threads, and returns the thread to the pool (but not killing it)
07:10auseroh that would work nicely I think
07:11kumarshantanualso, though not mentioned in the clojure docs, you may find hava.util.concurrent package very useful
07:11kumarshantanus/hava/java/
07:11sexpbot<kumarshantanu> also, though not mentioned in the clojure docs, you may find java.util.concurrent package very useful
07:12kumarshantanuhttp://download.oracle.com/javase/6/docs/api/java/util/concurrent/package-summary.html
07:12auserthat's funny, I was just looking at that
07:12auserhttp://download.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html
07:13kumarshantanuauser: yes, and you will probably find some clojure wrappers written by people to work with the task-executor framework
08:20fliebelIs Clojure a JSR 223 script engine? And what about other JVM languages? I came across the term a few times, and I'm wondering if it'd be possible to create a generic REPL for all these languages. (inside an applet?)
08:28kumarshantanufliebel: Did you notice this? http://code.google.com/p/clojure-jsr223/
08:28fliebelkumarshantanu: No, I didn't
08:28kumarshantanuseems to be bringing 223 to clojure
08:29AWizzArdDoes swank-clojure work with fresh builds of clojure.jar ?
08:29fliebelkumarshantanu: I did notice this: https://github.com/tinkerpop/mutant/wiki
08:31kumarshantanufliebel: I noticed Mutant few days ago too...maybe useful for glue-work
09:44NikelandjeloHow can I disable auto-casting (+ Integer/MAX_VALUE 1) to long? I need it to convert into Integer/MIN_VALUE?
09:45mcav,(unchecked-add Integer/MAX_VALUE 1)
09:45clojurebot-2147483648
09:46NikelandjeloThanks
09:46mcavyw
10:14TordmorQuestion: How would you generate a random sequence of digits of arbitrary size?
10:17mcav,(take 5 (repeatedly #(rand-nth (range 10))))
10:17clojurebot(0 8 8 9 5)
10:20mcav,(take 5 (repeatedly #(rand-int 10)))
10:20clojurebot(6 3 0 5 8)
10:27Tordmormcav: Thanks, that looks great
10:27mcavTordmor: glad to help
10:37jk__if i need to build a function that returns true or false, is it sufficient to have the function return non-nil or nil?
10:39fliebeljk__: Most of the time, yes.
10:39jk__this is for calling tree-seq
10:40jk__fliebel: i have functions that return a result or nil. wanted to know if there is any problem using them directly in tree-seq
10:40jk__fliebel: when you say "most of the time" that makes me nervous :)
10:40fliebelmcav: Why use rand-nth rather than rand-int?
10:41fliebeljk__: The only problem is when you chekc explicitly for false?
10:41mcavfliebel: I wasn't thinking the first time; that's why I put rand-int right after that
10:42fliebel&(false? nil)
10:42sexpbot⟹ false
10:42jk__i see. so only false is false
10:42jk__according to the predicate i mean
10:42fliebelbut #(when nil true)
10:42fliebel&(when nil true)
10:42sexpbot⟹ nil
10:43jk__,(doc when)
10:43clojurebot"([test & body]); Evaluates test. If logical true, evaluates body in an implicit do."
10:43fliebelSo in the context of tree-seq, you should be fine I guess.
10:43jk__fliebel: because if i return a nil, it's not going to be true?
10:44jk__&(true nil)
10:44sexpbotjava.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.IFn
10:44jk__&(true? nil)
10:44sexpbot⟹ false
10:44fliebeljk__: Everything except false and nil are true.
10:44jk__fliebel: but for (false?) only false is false
10:45jk__i think a part of my brain just exploded but that works for me
10:45fliebel(map boolean [1 [] true false nil 0])
10:45fliebel&(map boolean [1 [] true false nil 0])
10:45sexpbot⟹ (true true true false false true)
10:45jk__got it
10:45jk__thx!
10:46fliebelfalse? really checks of the argument IS false, not if it would be falsy.
10:47jk__it's like nil is just an unknown. it's neither true nor false
10:47jk__well no, that's not right either
10:47jk__nm
10:47pdk,(boolean nil)
10:47clojurebotfalse
10:47pdknil = false
10:47jk__.(boolean [])
10:48jk__,(boolean [])
10:48clojurebottrue
10:48jk__,(false? nil)
10:48clojurebotfalse
10:49jk__nil is neither (true?) nor (false?)
10:49jk__,(true? nil)
10:49clojurebotfalse
10:49jk__,(= nil false)
10:49clojurebotfalse
10:50jk__ok sorry for the spam. i understand how it works. thx fliebel
10:53raek'if' checks whether things are truthy or falsy
10:54raekfalse and nil are falsy, everything else is truthy
10:54raek'false?' checks whether something is the value false, rather than falsy
10:55raekand vice versa for 'true?'
10:56raekuse (boolean ...) when you really need the value true of false
10:56raek*true or false
11:02jk__raek: well that's the thing. tree-seq, for example, wants a function that returns true if a node has children, for example. if i do some sort of existence check and it returns a non-boolean thing, or nil, i wanted to just use it
11:02raeknow for something that will cause your world to fall apart ;)
11:02raek,(true? (Boolean. true))
11:02clojurebotfalse
11:02jk__raek: wanted to know if i really had to transform the result to a real boolean
11:02fliebelraek: How mean!
11:03raek("solution": no one should ever use that constructor.)
11:03fliebeljk__: You don't. It uses when, so nil will just work fine. ##(source tree-seq)
11:03sexpbotjava.lang.Exception: Unable to resolve symbol: source in this context
11:04raekjk__: in most clojure code, you usually don't have to do that. for java interop though, you might need to do it.
11:04jk__,(true? Boolean/FALSE)
11:04clojurebotfalse
11:05jk__,(Boolean. true)
11:05clojurebottrue
11:05raek,(identical? true Boolean/TRUE)
11:05clojurebottrue
11:05jk__,(identical? false Boolean/FALSE)
11:05clojurebottrue
11:07jk__,(true? (Boolean. "true"))
11:07clojurebotfalse
11:07jk__ok gonna do real work now
11:07jk__thx guys
11:07raek:-)
11:07fliebel:)
11:15gfrlog,(into {} [[1 2] [3 4 ][5 6]])
11:15clojurebot{1 2, 3 4, 5 6}
11:41gfrloganybody got any ideas for the easiest way to plot a simple X-Y graph from clojure?
11:52raekgfrlog: incanter.
11:52gfrlogI had just gotten into that
11:52gfrloghas good features
11:52gfrlogno telling how much documentation browsing it will take before I can take a bunch of (x,y) pairs and save a basic line graph
11:54fliebelgfrlog: I found plot-fn to be useful for these things.
11:54gfrlogfliebel: thanks for the tip
11:55gfrlogxy-plot also looks promising
11:57fliebelgfrlog: Then you'd have to change the direction of your seq I think
11:59gfrlogwhat do you mean?
11:59gfrlogit takes an x seq and a y seq
11:59fliebelxy-plot takes [x x x x x x] [y y y y y y y] rather than x y pairs
12:01fliebelWhat you could do is a plot-fn over the result of (into {} pairs) using (range (max-key pairs))
12:01fliebeluhm, function-plot
12:02gfrlogit takes an arbitrary function?
12:03fliebelgfrlog: Yea, it takes a function, and invokes it for all xs and uses the result as y.
12:04fliebelBut xy-plot is probably better. Only you need to convert the input.
12:05gfrlogthanks for the help; I think xy-plot will work
12:07fliebelhmmm http://liebke.github.com/incanter/charts-api.html#incanter.charts/add-lines
12:28jk__$see cemerick
12:28jk__$seen cemerick
12:28sexpbotcemerick was last seen joining on :#clojure-casual 3 hours and 38 minutes ago.
12:28cemerickjk__: what's up?
12:28cemerickRaynes: there's a bug for you ^^
12:28jk__cemerick: hey, you're one of the main committers on CCW right?
12:29cemerickI'm a commiter, yes. Not sure what constitutes "main", but whatever.
12:30jk__heh... i just had a question about whether "reformat" in the editor is in the plans. like if your indentation is broken in java, i hit ctl-shift-f to reformat the whole file. that doesn't work in ccw. note that i'm not whining here, i love ccw
12:31jk__that's really the only thing i miss
12:31cemerickjk__: I think Laurent has that in his working copy right now. Line-by-line reindentation is there -- just hit tab at the beginning of a line.
12:32jk__cemerick: aha! i didn't know that about tab
12:32ordnungswidrighi
12:33jk__cemerick: that helps. i find that i frequently add a let or something and that skews the whole rest of a function. i was doing <end><enter><select to next line><del>
12:33jk__cemerick: <tab> is certainly much quicker :D
12:33ordnungswidrigwhat's the advantage of using letfn over let?
12:33cemerickjk__: yeah -- it's sort of a hack at the moment, IIRC.
12:34cemerickI'm afraid the editor stuff itself is not my area of specialty in the codebase.
12:34jk__cemerick: btw, this plugin allowed me to avoid adding another monstrous learning curve (emacs) to the already big one with clojure. good work! i always used vi in the past
12:34cemerickAll that stuff needs to get bound to the usual commands (e.g. Cmd-I, Cmd-Shift-F, etc)
12:35cemerickjk__: are you using the 0.0.59 release, or the RC?
12:35cemerickI'm really a bit-player -- thank lpetit when you see him. :-)
12:36jk__0.0.64-STABLE01
12:36cemericker, right, that :-)
12:36jk__:) i just looked
12:36cemerickjk__: there's an 0.2.0-RC1 available now, that has a much-improved REPL
12:37jk__cemerick: thanks for the tip. i'll upgrade my plugin then. this one is working well for me
12:37cemerickjk__: FYI: http://groups.google.com/group/clojuredev-users/browse_frm/thread/339b0347f6d15b17
12:37jk__ahh, nice. i didn't know about that group
12:37cemerickit's an RC, so eclipse won't present it as an upgrade. You'd have to uninstall and reinstall. Perhaps only for the brave :-)
12:38jk__cemerick: no problem. i've done that procedure hundreds of times on other plugins
12:38cemerickwe'll probably have 1 or 2 more RCs, then release it (which will then offer it up as an upgrade)
12:38jk__well... maybe dozens :)
12:38cemerickThat's definitely the place to post questions, issues, etc.
12:39cemerickLaurent and I monitor it pretty regularly.
12:39jk__cemerick: when i hear people talking about emacs/swank or vi/nailgun stuff, i never really hear anything that seems to be lacking from CCW. it's really a nice plugin
12:40cemerickIt's getting there :-)
12:40fliebelordnungswidrig: letfn saves you some typing, but afaik the only real advantage is that you get to have mutually recursive functions.
12:41cemerickIt has a ways to go in some areas, but what's there is very solid. And, eclipse is a great foundation.
12:41jk__cemerick: i use the maven plugin too and wrote an archetype for generating a clojure app with compojure and a couple other goodies added. your site gave me the added incentive to go full-bore with the maven and clojure plugins in eclipse
12:42cemerick:-)
12:42cemerickjk__: I suspect that Mark (@talios, maintainer of clojure-maven-plugin) might be interested in archetypes.
12:43cemerickOne for "plain" projects and one for compojure webapps would make a lot of sense.
12:44jk__cemerick: i agree. my simple archetype just includes the dependencies, config to do src-only jar and a sample clojure file. i need to do another one to create an AOT compile war file
12:46jk__cemerick: i can give it to talios. i'll have to take out the repository entry for our internal artifactory :) everything goes through that internally
12:46cemerickright
12:46cemerickI keep throwing example projects out there, but never get around to an archetype
12:47jk__yes, i started by cloning my sample project and renaming it, including in the .project file all the time, but it was getting too tedious. i finally broke down and whipped out the archetype so i could quickly start new small test projects
12:48raekordnungswidrig: with letfn, the function can refer to itself. this can be done with let too. (letfn [(foo [...] ...)] ...) ~ (let [foo (fn foo [...] ...)] ...)
12:48cemerickI usually just copy a simple pom around a tweak :-)
12:49jk__cemerick: yes i should have done that. but that would work well enough that i'd be too lazy to do the archetype :D
12:49raek(however, mutually recursive functions using let can only be done with the letfn variant)
12:50ordnungswidrigraek: so it's just saving some typing
12:50raekpretty much
12:50ordnungswidrigok
12:50raekexcept for the self-referring stuff
12:51raek,(let [foo (fn [] foo)] (foo))
12:51clojurebotjava.lang.Exception: Unable to resolve symbol: foo in this context
12:51raek,(letfn [(foo [] foo)] (foo))
12:51clojurebot#<sandbox$eval159$foo__160 sandbox$eval159$foo__160@32a325>
12:51raekstupid example, but you get the idea... :-)
12:53raekthe only time I have used letfn is when I needed a helper function to implement a lazy sequence
13:00Lajlaraek,
13:00LajlaI am the second best programmer in the world.
13:00LajlaEver told you that.
13:00Lajlacemerick, how about my named recur
13:00LajlaI want it.
13:00LajlaIf you can give this to me.
13:01LajlaThen I will reward you handsomely.
13:01bmhWhat's a reasonable way to compare two doubles with a desired precision?
13:07ordnungswidrigraek: ok, thanks for explaining
13:17npoektopAdamant: hi! is there a way to make slime-autodoc work with clojure?
13:17Adamantdon't know offhand
13:45kumarshantanuQuestion: how can I convert a string to a regex?
13:45kumarshantanu"hello" --> #"hello"
13:46raek,(re-pattern "[0-9]+")
13:46clojurebot#"[0-9]+"
13:46kumarshantanuraek: thanks!
14:20bobo_raek: yeh that one is awesome
14:22jkkramerhey thanks :) i guess i should probably write the promised follow-up
14:26raekjkkramer: I'm looking throught the docstrings of loom and I came across the word "read-only". what does it mean in this case?
14:26raekall the graphs are immutable, right?
14:27raekdoes it mean that you cannot create modified copies of them?
14:27jkkramerraek: meaning the add/remove fns won't work. it's for when graphs are created on the fly (e.g. from some function)
14:28jkkramerraek: i.e., there's no stored data to "modify" -- just functions which generate neighbors and such on-demand
14:28jkkrameri should mention that loom's implementation may still change a lot. in particular, i plan on having it use deftype instead of defrecord
14:29jkkramerhaven't had time to work on it recently
14:29raekif I just use the public function, that wouldn't affect me, right?
14:30jkkramerright, ideally the API wouldn't change much
14:31jkkrameri might rethink fly graphs...maybe just creating something like graph-seq, analogous to tree-seq
14:31raekI have only used the lib for about 10 minutes, but I really like what I have seen so far :)
14:31jkkramercool, thanks. let me know if you have any comments/suggestions
14:32raekonly one small one so far:
14:32raekyou might want to consider to put the ubigraph integration in a separate artifact/jar
14:33jkkrameryeah, that might make sense
14:33raekI assume that the core of loom only uses a few deps
14:34jkkramerjust clojure.core, yup
14:34raekand the most of the deps seemed to be used only by the ubigraph parts
14:34raekneat
14:34raekis there any autodoc up for loom?
14:35jkkramernot yet
14:36raekbtw, it's truly wonderful to be able to just send a graph to GraphViz...
14:37jkkramerturned out to be quite easy, compared to integrating a java lib for visualization, or writing my own
14:55fuchsdHowdy! What's the best/most idiomatic way to re-bind *command-line-args* in a test with Lazytest?
14:56fuchsdI tried this: https://gist.github.com/738277
14:56fuchsdand it didn't seem to work.
14:56fuchsdHowever, if I move that bindings form to within the it form,
14:57fuchsdthe test passes and fails as it should, but the reporting isn't the best (it reports the whole bindings expression instead of just the tests)
14:57fuchsdIs there a better way to do this?
14:59cemerickIs anyone aware of a way to compile Java apps down to Javascript to be run within the browser?
14:59cemerickchouser, perhaps?
15:00lpetitGWT
15:00lpetitahem
15:01bobo_souns alot like GWT yes
15:02cemerickyeah
15:02cemerickWhat I just heard about was something Oracle-sponsored, though.
15:03cemerickI can't find anything about oracle being involved in such a project though…
15:17bobo_can someone tell me why i should name a argument for username "s" instead of "user-name"? or "n" instead of "size" if it is the size of something?
15:17bobo_or am i missunderstanding the coding standards?
15:22ossarehbobo_: I guess since a username is a string and size is a number. IMHO I prefer the longer variants but have found myself using the shorter ones as I spend more time hacking clojure.
15:24bobo_i have tried to like the short once for a long while now. dont get it at all
15:25ossarehThe regular short ones I use are "n" for number and "x" for some anonymous data, (map (fn [x] (do-something-with-x x)) coll)
15:27bobo_and that seems to be the correct way to do it according to the standards, but would be nice to know why it is the standard.
15:34fuchsd('let' or 'given' don't work in this case either)
15:51cemericklpetit, bobo_: http://cemerick.com/2010/12/12/oracle-vp-we-have-a-strategy-to-run-java-inside-a-javascript-environment/
15:59fliebelWhy the f*ck does the RSS icon on twitter.com give my my favorites?
16:00fliebeloops, that was meant for my twitter feed
16:05bobo_cemerick: that sounds realy weird, i dont get why they would develop such a thing
16:05raekok, now I got loom hooked up with ring and moustache. now I can make graphs of clojure data available from the web!
16:07cemerickbobo_: Oracle can't keep ceding client-side stuff to everyone else.
16:07cemerickEspecially if they're working on something like orto, that would be *huge*
16:08bobo_orto?
16:09cemerickbobo_: there's a link about it in my post
16:09bobo_ah! im blind =)
16:09bobo_ah yes that would be huge
16:12bobo_if people are crazy enough to do a flash runtime in javascript oracle could very well be building a java runtime in it.
17:00ordnungswidriguh, so they want to keep java but not then jvm?
17:00brehautmarketting?
17:01brehautthey were talking in terms of desktop applications
17:01ordnungswidrigUh, you mean the desktop machines that will have 12 cores in 4 years by default?
17:02ordnungswidrigSounds like java compiled to javascript would be a perfect fit *g*
17:02brehautmy guess is that the JVM is unattractive to users as a platform for desktop apps but web apps are great. java applets are dead. whats next? try to make java run in the one platform everyone has
17:03brehauti was only imply that it did seem like they were discarding the JVM wholesale
17:03npoektopDoes lazytest run tests in a separate thread?
17:03brehautonly that they implied it wasnt part of desktop plan
17:05ordnungswidrigbrehaut: you mean, desktop apps in the browser
17:05ordnungswidrig?
17:06brehautordnungswidrig: im guessing and reading through the lines but yes
17:07ordnungswidrigbrehaut: how scary, in the browser we already have a nice function language named ecmascript. who, really, will need java, here ?
17:07brehautordnungswidrig: java developers? GWT developers?
17:09ordnungswidrigbrehaut: Shouldn't a developer be able to program in multiple languages?
17:10brehautordnungswidrig: i dont think its any more sane than you do, im just trying to suggest why they might think its a good idea
17:10ordnungswidrigbrehaut: However, I see that there is no strongly language in the browser
17:10ordnungswidrigbrehaut: …strongly typed...
17:11ordnungswidrig(There is a haskell to js compiler, IIRC)
17:11brehautordnungswidrig: im very much a polyglot myself, but im also aware of how much of a minority view that is with a lot of developers
17:11ordnungswidrigbrehaut: then, they should do a vba to js compiler :-)
17:11brehautordnungswidrig: good god no
17:11brehautordnungswidrig: vba needs to be shot
17:12brehautim still recovering from the trauma of programming vaste quanitities of VBA professionally
17:12ordnungswidrigbrehaut: by the number of developers then yes!
17:16brehautordnungswidrig: my last gig i was working on legacy systems where basicly everything was VBA. most of our servers had several million lines of it in production
17:17ordnungswidrigbrehaut: fascinating that such systems work
17:17ordnungswidrigbrehaut: often without a glimpse of qa
17:17brehautordnungswidrig: aint that the truth :P
17:18brehautno more of that for me
17:18ordnungswidrigbrehaut: beside end-to-end testing done by a horde of tester running test scripts by hand an entering results into excel sheets?
17:18brehautword docs rather than excel sheets for us but yeah ;)
17:18arrummzenHow do I import clojure functions from one namespace to another so I don't have to append the other namespace/ to every function call?
17:19brehautarrummzen: first, aliasing the namespace is a prefered choice
17:19brehautarrummzen: otherwise 'use'
17:19arrummzenWhat do you mean by aliasing the namespace?
17:19brehaut(require '[clojure.xml :as 'xml])
17:19brehautoh sorry
17:19brehaut(require '[clojure.xml :as xml])
17:20brehautthen you can do (xml/emit nodes)
17:20brehautfrinstance
17:20brehautarrummzen: this is the recommended approach
17:20arrummzenhmm... require seems to only work if I have the functions I need compiled to disk?
17:20brehautarrummzen: it should work for any clj file you have. its the typical way of loading code
17:20arrummzenUse has the same problem...
17:21brehautarrummzen: you have a deeper problem i think?
17:22brehautarrummzen: do you have your project anywhere public?
17:23brehautarrummzen: or are you dabbling in a repl?
17:23ordnungswidrigarrummzen: is the source file with the used function on the classpath?
17:23arrummzenNever mind, it seems that it can load a .clj file as well.
17:23brehautyes
17:24arrummzenSorry, I'm new to this REPL stuff. I'm used to the C/Makefile style of working.
17:24brehautarrummzen: no worries
17:26brehautarrummzen: if you must import a function into your namespace rather than requiring the namespace, it is suggested that you restrict what you import to a specific set of symbols.
17:27brehautarrummzen: eg (use '[clojure.contrib.zip-filter.xml :only [xml-> xml1-> text])
17:28brehautarrummzen: are you using a project management / 'build' tool?
17:29arrummzenNo....
17:30brehautarrummzen: may i suggest you look into github.com/technomancy/leiningen for managing your projects
17:30arrummzenI'm using eclipse which manages the Java part of the build. But counterclockwise doesn't seem to support a unified build system.
17:30brehautarrummzen: and its sibling project github.com/liebke/cljr
17:31brehautarrummzen: sure. I've used lein for the buildy bits of a project with eclipse + ccw
17:33arrummzenSounds good. I've only 2 files at this point but as the project grows I'll have to start thinking about a build system.
17:34brehautarrummzen: importantly lein will maintain the dependancies for you, both fetching them and sticking them on the projects classpath. ahead of time compilation is the exception, not the rule, in clojure, so 'build' ussually just means producing an uberjar with your clj + all dependant jars.
17:37arrummzenbrehaut: what do you mean by fetch? Does it automatically download updates?
17:37brehautarrummzen: it will download any dependancies you specifiy with the version you specify
17:38brehautand handle dependancy resolution for those too. It is built on the maven dependancy system
17:38arrummzensounds interesting =)
17:40gfrlogisn't there a histogrammy function in clojure that does [1,3,3,4,5,4,6] => {1 1, 3 2, 4 2, 5 1, 6 1} ?
17:41gfrlogclojure.core/frequencies
17:44hiredman(apply merge-with + (map (fn [x] {x 1}) [1,3,3,4,5,4,6]))
17:44hiredman,(apply merge-with + (map (fn [x] {x 1}) [1,3,3,4,5,4,6]))
17:44clojurebot{6 1, 5 1, 4 2, 3 2, 1 1}
17:45brehauthiredman: cunning :) also he answered his own question with clojure.core/frequencies i think
17:46gfrlogyeah
17:46gfrlogthat's cute though
17:47hiredman~def frequencies
17:47hiredmanclojurebot: you suck
17:47clojurebotIt's greek to me.
18:11rata_hi
18:11brehautrata_ [temporally appropriate greeting]
18:12rata_:)
18:13raek_rata_: good morning (Universal Greeting Time)
18:17Licensernight everyone!
18:27jk__arrummzen: it's pretty easy to build clojure project with the maven clojure plugin inside eclipse. if you're already using the maven plugin that is
18:59gfrlogdoes incanter have a feature for drawing a basic graph on a log scale?
18:59gfrlog(i.e., y-axis is log scale)
19:42jcromartieI made a map function that prints progress over large lazy seqs https://gist.github.com/738505
19:43jcromartieoops, updated to include the missing dot-points :)
19:59tomojjcromartie: try not to count the seq
19:59tomojer, coll
19:59jcromartiehm, yeah I guess that might spoil things
20:00jcromartiethen it's kind of hard to do
20:00jcromartieoh well
20:00tomojI don't see why you need the progress atom
20:00tomojcan't you just map-indexed?
20:00jcromartiewell you still need to know where in the collection you are at
20:00tomojoh, of course
20:00tomoj:)
20:01tomojso it only makes sense anyway for colls you can fit in memory
20:01jcromartieit's more for the evaluation of (f x), not the coll of x's
20:01jcromartieyeah
20:02tomojdoprogress?
20:02tomojI dunno, I guess using map like that is ok
20:02tomojas long as people know the thing they get back will behave weirdly
20:03tomojbut if they were going to use map to do it, they'd know that anyway
20:16jcromartieyeah
20:16jcromartieI have a better idea
20:16jcromartiehow about with-progress
20:16jcromartiewhich binds *progress* and lets you use fns like (progress "Doing stuff") (progress 0.5) to show meters
20:22laurusDoes anyone know a way in Clojure to do something similar to http://briancarper.net/blog/527/printing-a-nicely-formatted-plaintext-table-of-data-in-clojure , but with commands that would allow the selection of data based on certain criteria, say, for that example, age < 29 ?
20:23tomojfilter the data before passing it to the table function?
20:23tomojmaybe I'm not following you
20:23laurustomoj, how?
20:24tomoj(table (filter #(< (:age %) 29) data) [:age :name]) ?
20:24laurusAh, I see.
20:24tomojdepends on the data I guess
20:30Darmaniuser> (- 0 -9223372036854775808)
20:30Darmani-9223372036854775808
20:30Darmani*sigh*
20:31DarmaniHow should I report this?
21:07hippiehunteris there a way to un-zip a collection of maps with x elements into x collections?
21:07gfrlogexample of input and output?
21:08brehauthave you tried (apply map col) ?
21:08brehautsorry
21:09hippiehunter[{:item1 "hello" :item2 "again"}] into ["hello"] and ["again"] with some way to name the resulting collections
21:10brehauthippiehunter: you might need to be a bit more explicit
21:11brehauthippiehunter: do you want say [{:i1 1 :i2 4} {:i1 3 :i2 5}]
21:11hippiehunteryes
21:11brehautto become say {:i1 [1 3] :i2 [4 5]}
21:11hippiehunterthat would certainly do the trick since i could destructure it
21:12brehauti think merge-with would be a good start
21:13brehaut(apply merge-with + col) for example would sum those for you
21:14brehautso replace + with a fun that conjs acc [i] or returns [item]
21:15gfrlogI think he'd still have potential problems with that
21:15brehautid noodle about in a repl to work it out for you, but i just sliced mu finger open
21:15hippiehunterim unsure of how to pass the arguments into merge-with with considering they would be in vector form
21:15gfrlogfor keys present in the first map and none of the ethors
21:15brehauthippiehunter: apply
21:15gfrloghippiehunter: I'll try to scratch something up real quick, one sec
21:15hippiehunterthe maps are homogeneous
21:16gfrlogoh
21:16gfrlogthey all have the same keys?
21:16hippiehunteryes
21:16gfrlogmuch easier
21:16gfrloglessee...
21:18gfrlog(into {} (map (comp vector (apply comp coll)) (keys coll)))
21:18gfrlogno way that'll work on the first try
21:19gfrlogyeah, the (keys coll) at the end should be (keys (first coll))
21:21gfrlogI could clean it up even better if I knew of a good way to take a set of keys and a fn and spit out a map
21:21gfrlogusing (into {} and-some-pairs) is the only way I know how
21:24hippiehunterim a little hazy on (apply comp coll)
21:25hippiehuntercoll doesnt contain functions, doest comp try to run things?
21:25gfrlogcoll contains maps, right?
21:25hippiehunteryeah
21:25gfrlogmaps are functions
21:25gfrlogin this case we want to take each key, and run it through each one of those maps/functions and get a vector of the results
21:26gfrlogwhich should be what (apply comp coll) does
21:26gfrlogthere's a bug in there still that I'm trying to work out
21:27gfrlogah hah
21:27gfrlogcomp is not what I want :)
21:27gfrlogit's...the other thing
21:27gfrloglemme find the cheatsheet...
21:28gfrlogjuxt I bet
21:29gfrloggot it:
21:29gfrlog(into {} (map (juxt identity (apply juxt coll)) (keys (first coll))))
21:30gfrlogso (apply juxt coll) is a function that takes a key and returns a vector of values
21:30gfrlogthe (juxt identity ...) part will return a pair, where the first element is the key and the second element is the vector of values
21:30gfrlogso map creates a list of pairs, and into shoves them all in a map
21:32hippiehunter,(let [coll [{:i1 1 :i2} {:i1 3 :i2 4}]] (into {} (map (juxt identity (apply juxt coll)) (keys first coll))))
21:32clojurebot3
21:33gfrlogyour first map looks incomplete
21:33hippiehunterahh thanks
21:33hippiehunter(let [coll [{:i1 1 :i2 2} {:i1 3 :i2 4}]] (into {} (map (juxt identity (apply juxt coll)) (keys first coll))))
21:33hippiehunteroops
21:33gfrlogI'm surprised that doesn't throw an error
21:33hippiehunter,(let [coll [{:i1 1 :i2 2} {:i1 3 :i2 4}]] (into {} (map (juxt identity (apply juxt coll)) (keys first coll))))
21:33clojurebotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$keys
21:34gfrlogyou want (keys (first coll))
21:34hippiehunter,(let [coll [{:i1 1 :i2 2} {:i1 3 :i2 4}]] (into {} (map (juxt identity (apply juxt coll)) (keys (first coll)))))
21:34clojurebot{:i1 [1 3], :i2 [2 4]}
21:34gfrlogwoohoo
21:34hippiehunterawsome
22:41DeranderI wonder if it'd be possible to implement a swank server for ruby
23:03hippiehunterwhen I do a full macro expand, it tends to produce a single line of mega doom that I would like to have nicely formatted. Is there such a feature or must I reflow by hand?
23:04brehauthippiehunter clojure.contrib.pprint might contain what you want?
23:04brehauthippiehunter: http://richhickey.github.com/clojure-contrib/pprint-api.html
23:12hippiehunterthanks that got me in the right direction
23:18Synt_xQuiet in here
23:32technomancyclojurebot: wake up, sluggard.
23:32clojurebotIt's greek to me.
23:33technomancyclojurebot: well then Ξυπνήστε, οκνηρός
23:33clojurebotHuh?
23:33brehaut(inc technomancy)
23:33sexpbot⟹ 1
23:33technomancyಠ_ಠ
23:34Raynes(inc brehaut)
23:34sexpbot⟹ 2
23:35brehautwow im quickly approaching my HN karma score
23:42Lajla,(+ 1 1)
23:42clojurebotLajla: Excuse me?
23:42LajlaI'm still ignored. =(
23:42ossareh&(+ 1 1)
23:42sexpbot⟹ 2
23:42ossarehspeak to bots that listen
23:43ossarehis clojurebot's code in github?
23:44technomancyclojurebot: source?
23:44clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
23:44ossareh^_^
23:45Lajla&(set! * +)
23:45sexpbotjava.lang.IllegalStateException: Can't change/establish root binding of: * with set
23:54Raynesossareh: sexpbot isn't a clojurebot.
23:54ossarehRaynes: what is the core difference?
23:55Raynesossareh: They are entirely different bots designed in entirely different ways with totally different goals.
23:55RaynesThe core difference is 'everything'. :p
23:55ossarehhah.
23:55RaynesI've never looked at the clojurebot source code outside of it's sandbox code.
23:56Raynessexpbot: whatis source
23:56sexpbotsource does not exist in my database.
23:56Raynessexpbot: whatis sexpbot
23:56sexpbotsexpbot = the bestest sexpbot ever
23:56RaynesHeh, I nixed my own link.
23:56Raynes$learn sexpbot http://github.com/Raynes/sexpbot
23:56sexpbotMy memory is more powerful than M-x butterfly. I wont forget it.
23:58ossarehRaynes: btw - saw your tweet about your mum burning things. I know how that roles, best thing that ever happened to me because I was forced to cook. Such a great skill to have!
23:59RaynesI have a high respect and admiration for proper chefs. If programming wasn't my thing, cooking would be.
23:59RaynesToo bad I suck at cooking.