#clojure logs

2010-01-05

01:13ndimidukfrom within (ns foo (:gen-class)), how do I access foo.class?
01:13ndimiduki'd like to pass the .class of the generated class as a parameter. saying (. instance method foo) doesn't work.
01:13ndimidukcompiling throws an exception saying Unable to resolve symbol foo
01:21scottj_is there a function in clojure or contrib to turn [{:a "x" :b 1} {:a "y" :b 1} {:a "x" :b 1}] into {"x" 2 "y" 1}?
01:22scottj_I wrote my own with reduce and but I'm wondering if there's a higher level idiom I'm missing
01:26somnium,(frequencies [{:a "x" :b 1} {:a "y" :b 1} {:a "x" :b 1}])
01:26clojurebot{{:a "y", :b 1} 1, {:a "x", :b 1} 2}
01:26somnium^^ gets pretty close, one transformation or so away
01:27danlarkinWhat will the syntax be for defining a print-dup for a byte array
01:28danlarkindefmethod print-dup bytes isn't it, defmethod print-dup [B throws an EOFException
01:28danlarkinthose were my two ideas
01:29somnium(->> [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}] frequencies (map (fn [[{a :a} b]] [a b])) (reduce merge {}))
01:30somnium,(->> [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}] frequencies (map (fn [[{a :a} b]] [a b])) (reduce merge {}))
01:30clojurebot{"x" 2, "y" 1}
01:31somniumhmm, into {} better than reduce merge
01:33scottj_somnium: interesting. my example wasn't clear but I actually wanted to add up the :b's, that's how "x" gets 2
01:34somniumscottj_: well, as long as :b is always 1 it will work for any value of :a
01:35somniumscottj_: but to your orginal question frequencies is the only that I know of
01:38scottj_this is the best I came up w/, curious if there's something better
01:38scottj_(reduce (fn [result item] (assoc result (:a item) (+ (get result (:a item) 0) (:b item)))) {} [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}])
01:43somnium,(reduce (fn [m {x :a y :b}] (update-in m [x] + y)) { "x" 0 "y" 0 } [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}])
01:43clojurebot{"x" 2, "y" 1}
01:44somniumscottj_: + blows up on nil keys so a custom + fn would make it a bit more robust
01:51somnium,(reduce (fn [m {x :a y :b}] (update-in m [x] #(-> %1 (or 0) (+ %2)) y)) {}
01:51somnium [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}])
01:51clojurebotEOF while reading
01:52somnium,(reduce (fn [m {x :a y :b}] (update-in m [x] #(-> %1 (or 0) (+ %2)) y)) {} [{:a "x", :b 1} {:a "y", :b 1} {:a "x", :b 1}])
01:52clojurebot{"y" 1, "x" 2}
01:52somniumlast try before bed :)
02:06somniumscottj_: on reflection I think I like your original better, I would just add map destructuring
02:11chouserdanlarkin: (Class/forName "[B") I think
02:13chouseror (type (byte-array nil))
02:13danlarkinchouser: ah ha, trickery :)
02:13danlarkinthanks
04:56adityo~max people
04:56clojurebotmax people is 240
06:19defnHow does one use options with (clojure.contrib.shell-out/sh)?
06:19defn,(use 'clojure.contrib.shell-out)
06:19clojurebotnil
06:20defn,(doc sh)
06:20clojurebot"([& args]); Passes the given strings to Runtime.exec() to launch a sub-process. Options are :in may be given followed by a String specifying text to be fed to the sub-process's stdin. :out option may be given followed by :bytes or a String. If a String is given, it will be used as a character encoding name (for example \"UTF-8\" or \"ISO-8859-1\") to convert the sub-process's stdout to a String which is returned. If :byt
06:23shafiAre there any clojure examples based on GPU?
06:26hoeckdefn: it parses its args, and whenever it finds a keyword, the next string is considered a value to this key
06:27hoeckdefn: so this should work: (sh "ls" "-l" :in "-a"), or this (sh :in "abc" "ls" "-la")
06:29hoeckclojurebot: google clojure gpu
06:29clojurebotFirst, out of 6760 results is:
06:29clojurebotideolalia - is it strange to dance so soon
06:29clojurebothttp://ideolalia.com/
06:30hoeckshafi: ^^
06:30slashus2http://github.com/ztellman/penumbra
06:31shafiMany thanks. I will have a look.
06:53defnhoeck: thanks buddy
07:00praptakSuggestions for Clojure docs changes. Where to raise them?
07:01praptakIs there an accepted way to suggest improvements to docs?
07:02slashus2praptak: Raise the issue in the google group.
07:02praptakOk, thanks.
07:02Chousukethough if it's just "add examples, please", then don't bother. that's a known issue :)
07:03Chousukeunless you have a solution for it, of course.
07:03praptakNope, maybe it's even "remove examples" :)
07:32carkclojurebot: source reductions
07:34carkclojurebot: source rec-seq
07:38bbommaritoDoes Clojure have something like progn?
07:38praptakdo
07:38praptakI believe that 'do' is the Clojure equivalent of progn
07:39bbommaritopraptak: Thanks much. I'm sitting here trying to figure out why progn is bombing, until I think that maybe Clojure doesn't have that construct.
07:40bbommaritoI may at some point have to add a progn into Clojure.
07:44praptakI am not sure if 'do' is 100% equivalent to 'progn', though.
07:47bbommaritopraptak: Looks to be...I use progn usually for one use: ifs
07:48bbommaritoYep, do is progn. Takes a series of forms, evaluates them in order, returns the last one.
07:49praptakAt this level they are equivalent - I mean the fine details of compilation (what is and what isn't a top-level form, etc.)
07:50bbommaritopraptak: I don't tend to concern myself so much at the lower level of functions (I should, but sometimes there isn't time).
07:50Chousukeprogn is a weird name :/
07:50ChousukeI'm still not sure what it's supposed to mean
07:51ChousukeI guess it's something historical like car and cdr
07:51praptakI think it's "professional gnome"
07:51bbommaritoChousuke: progn is a program without arguments, prog is a program with arguments. prog is an older lisp form.
07:52ChousukeI see.
07:52bbommaritoprog takes arguments in, sort of like a let, and progn doesn't. Needless to say, you will see mostly progn when you need to run multiple forms in a body (IE in an if)
07:56praptakfor this, we have 'when'
07:56bbommaritoYou can do: (prog ((x 1)(y 2)(z 3)) (print x)(print y)(print z))
07:57bbommaritopraptak: I try to use whens and unless whenever possible, but sometimes you need both conditions.
07:57praptakTrue.
07:58bbommaritoI really have to set slime up with clojure and allegro...make my life so simple.
08:01hoeckI always thought then n in progn stands for the nth-form which is returned
08:03bbommarito"progn is a special form that stands for “program with no arguments”."
08:05bbommaritoThat's the best meaning I could find for it.
08:07bbommaritoprogn is identical to prog, except prog can take arguments, progn cannot.
08:09hoeckbut there is also prog1 and prog2, both taking any number of forms returning the result of the first or the second
08:10hoeckbut anyway, sometimes I'm really in need of a do1, in clojure
08:10Chousukedo1? :/
08:10Chousukeah.
08:10Chousukeread only the latest line :P
08:13bbommaritoOooohhhh, prog could be useful. There is another macro to write in clojure.
08:14bbommaritoI have never heard of dol.
08:19bbommaritoWhich means I have to figure out how to take a list of bindings...
08:25Chousukeprog just looks like a plain let though :/
10:02danleiwhen I try to use contrib from the new branch I always get NoSuchMethodErrors (RestFn ...) I thought that a patch was applied to contrib to fix that?
10:03the-kennydanlei: Have you tried rebuilding a clean contrib? (ant clean && ant build)
10:03danleithe-kenny: ah, that might be it
10:03the-kennyclojurebot: clojure.lang.RestFN
10:03clojurebotant clean and rebuild contrib
10:03the-kenny:)
10:04danleiant stuff :D
10:04danleiI always mess it up :)
10:06chouserooh
10:09danleithe-kenny: works, ty
10:09the-kennydanlei: You're welcome
10:27danleiare there plans to get clojure-dev on gmane, too?
10:27danleiwould be nice
10:43CalJuniorHave a question about am auto-proxy macro for implementing a Java interface. See the macro here: http://paste.lisp.org/+1ZRY
10:46CalJuniorThis is a macro I found on a blog by Tim (don't know his surname) on his blog at brool.com
10:47CalJuniorThe macro works very well and saves a lot of overriding code when implementing a Java interface with a lot of things that need to be overriden.
10:48CalJuniorThe problem I have is that it seems to override only the first call I define.
10:49CalJuniorThis is his example implementation of auto-proxy: http://paste.lisp.org/+1ZS0
10:51defnIs there a limit to the depth a namespace can be?
10:51defnwww.xyz.server.foo.bar.baz
10:54CalJuniorOK, posted too soon. I solved the problem. I had a bug in the second defined method.
10:54CalJuniorthe macro is perfectly fine.
10:54Chousukedefn: probably not any limit that you're going to hit :P
10:55Chousukeunless you like REALLY long names.
10:56CalJuniorby the way: would be nice to have this in clojure contrib. very handy for java interop.
10:56CalJuniorI have asked Tim to submit it.
12:23rbewhats your favourite solutions for distribution, clustering?
12:27esjfrom what I've read Terracotta seems to be in favour
12:28esjis there a way to upack the arguments that get bundled as an array seq in & parameters ?
12:29arohner_esj: yes, destructuring in the fn args, and let
12:30esjoooh that's sneaky
12:30arohner_http://clojure.org/special_forms
12:30esjthanks
12:31esjperhaps that's what I need... can you look at my mock-up example at http://paste.lisp.org/display/93032 see ?
12:32esjor perhaps my hiding of the composition is stupid ?
12:33arohner_if you want ((seq-add-x 2) 10) and ((seq-add-x 2) 10 20) to work, you'll need to dispatch on the type
12:33Chousukewhat exactly do you want those to do? :/
12:33arohner_(cond (number? y) ... (seq? y) ...)
12:34churibperhaps apply would help :)
12:34arohner_oh, yes
12:34arohner_that's a better solution
12:35esjsorry, as usual I'm not clear. The composed function is for a DSL, so I want to able to do (s-a-x 4 3) or (s-a-x 4 3 10) rather than ((s-a-x 4) 3) and ((s-a-x 4) 3 10), to make the interface clean.
12:35esjbut can't figure out how to write the wrapping function
12:35arohner_so you want s-a-x to return [3+4 10+4]?
12:35Chousukebut what are those supposed to do?
12:36Chousukeremember, you can also overload on arity.
12:36JonSmithyou could always make it ((s-a-x 4) 3 10) and then write a macro
12:36esjyeah, I could explicitly overload by arity
12:37esjbut it seems like there should be a way to avoid that ?
12:37arohner_(defn s-a-x [x & y] (map #(+ x %) y))
12:37arohner_assuming you want to add the first argument to each of the second
12:37Chousukeesj: there might be if I understood what you want the functions to do.
12:37arohner_(s-a-x 4 3 10) => (7 14)
12:37JonSmithidk i like macros :-P
12:38Chousukeaha.
12:39churiboverloaded arity in already built in +
12:39churib,(+ 1 2 3)
12:39clojurebot6
12:40esjthe example itself is totally made up to have something simple to talk about. What I've got is a composed function which (like range) has several possible arities. So if I accept the double parens ((s-a-x 3) ...) then I'm 100% fine. But I'd like to get rid of the internal parens and have calls like (s-a-x 3 ...). Perhaps I'm just being greedy ?
12:40Chousukeand is the two-argument form of s-a-x supposed to use a range of ten elements as the seq?
12:40ChousukeI still don't quite get what they're supposed to do.
12:41JonSmithwell you can just wrap the double parens in another function
12:41esjChousuke: the two argument form of s-a-x calls the two argument form of range.
12:42esjJonSmith - yes, but then I have arity trouble in writing this wrapping function.
12:42Chousuke,((partial apply (comp #(map + 1 %) range)) 1 5)
12:42clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
12:42Chousukehm
12:43Chousukewhoops
12:43Chousuke,((partial apply (comp #(map (partial + 1) %) range)) 1 5)
12:43clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
12:43esjthe partial ?
12:43JonSmith(defn s-a-x [& args] (let [function (fn [] ...composed... function)] (apply function args)))
12:43Chousukeghsghj
12:43JonSmithor something like that
12:44JonSmithcan do arg & argsif you want to have one seperated out
12:44esjJonSmith... interesting, let me wrap my mind around that .
12:44JonSmitharg and args if*
12:44Chousuke,((partial apply (comp #(map (partial + 1) %) range))) 1)
12:44clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$apply
12:45Chousuke,((partial apply (comp #(map (partial + 1) %) range))) 1 2)
12:45clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$apply
12:45Chousukeardsgf
12:45Chousukealso, point-free :(
12:45JonSmithpoint free makes my head hurt :-(
12:46JonSmith((partial apply (comp #(map (partial + 1) %) range))) (list 1 2))
12:46Chousukeah, right.
12:46JonSmith,((partial apply (comp #(map (partial + 1) %) range))) (list 1 2))
12:46clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$apply
12:46JonSmithlol
12:46JonSmithmaybe not
12:46Chousuke,((partial apply (comp #(map (partial + 1) %) range)) [1 5])
12:46clojurebot(2 3 4 5)
12:46JonSmithah
12:46JonSmiththere we go
12:46Chousuke,((partial apply (comp #(map (partial + 1) %) range)) [5])
12:46clojurebot(1 2 3 4 5)
12:47Chousuke,(let [s-a-x (fn [& args] ((partial apply (comp #(map (partial + 1) %) range)) args))] (s-a-x 1 3))
12:47clojurebot(2 3)
12:47esjsmoooth
12:48Chousukecompletely unreadable :P
12:48Chousukeactually.
12:48Chousukethe partial apply is unnecessary
12:49Chousuke,(let [s-a-x (fn [& args] (apply (comp #(map (partial + 1) %) range)) args)] (s-a-x 1 3))
12:49clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$apply
12:49Chousukeor wait.
12:49Chousuke,(let [s-a-x (fn [& args] (apply (comp #(map (partial + 1) %) range) args))] (s-a-x 1 3))
12:49clojurebot(2 3)
12:50esjI know nothing about macros, so forgive me if its a stupid, but is there not a way just to pass in ((s-a-x a) ...) and get out (s-a-x a ...) ?
12:50esjsorry, the other way around.
12:50Chousukeno.
12:50Chousukeor yes, but s-a-x would then be infinitely recursive
12:51Chousukehmm.
12:51Chousukeor actually, not.
12:51Chousukedepends on what the one-argument form of s-a-x expands to.
12:52Chousukeit's actually pretty easy: (defmacro sax ([x & xs] `((sax ~x) ~@xs))) ([x] one-arg-form-here))
12:53esj:)
12:53konrAre there documentation functions (something like describe-symbol) available in clojure--mode on emacs? Strangely I couldn't find anything on the docs
12:54Chousukekonr: C-c C-d or something prints docstrings
12:54ChousukeMight be C-c C-d d or C-c C-d C-d. I'm not sure.
12:54Chousukeall I know is that it works :P
12:55Chousukemy fingers do it so I'm not sure of the command :D
12:55konrChousuke: Hahaha, I guess I'm using an old version, then
12:55esjthanks for your help everybody.
12:55Chousukekonr: I think it might be a SLIME thing actually.
12:57esjkonr: I saw an slime "inspect" thing working in Lau Jensen's screencast, never got it working myself.
12:57esjthat brought up the javadocs
12:59konresj: thanks for the reference! I was precisely looking for a compojure screencast
12:59technomancyesj: it requires Emacs 23 unfortunately, are you on an older version?
13:00arj_seq-utils/flatten seems to be failing for me. I have a lazyseq of arraylists and if I flatten it, it just gives me back the lazyseq again
13:01the-kennyslime-inspect is working fine here, without a special setup
13:02patrkriswhat is the easiest way of creating a map m2 from m1, where all values of m2 are the values from m1 except that str has been applied to them?
13:03esjtechnomancy: shouldn't be, its the latest aquamacs.
13:03esjmaybe I should try harder.... hold on.
13:04the-kennypatrkris: A mix of zipmap, keys and values
13:04patrkristhe-kenny: of course! thanks!
13:07technomancyoh, with aquamacs all bets are off
13:08the-kenny,(let [map {:foo 42 :bar 23} ] (zipmap (keys map) (map str (vals map))))
13:08clojurebot{:bar 23, :foo 42}
13:08the-kenny,(let [m {:foo 42 :bar 23} ] (zipmap (keys m) (map str (vals m))))
13:08clojurebot{:bar "23", :foo "42"}
13:08the-kenny:)
13:08the-kennypatrkris: there you are
13:09patrkristhe-kenny: i did exactly that, except that I keep forgetting that I can just pass standard functions to map (instead of str I passed #(str %) as the map function)
13:10patrkristhe-kenny: thanks in any case
13:10the-kennyYou're welcome :)
13:44jlongsterHey guys, I'm new to Clojure. What's the best practice for splitting up a project into several files? I want each file to have its own namespace, and import them into each other. But I can't find a way to do relative imports.
13:49the-kennyjlongster: (ns foo.bar) in src/foo/bar.clj, (ns foo.baz) in src/foo/baz.clj
13:49the-kennyjlongster: importing is done with the correct classpath (for examplw provided by swank-clojure-project) and (require 'foo.bar) or (require 'foo.baz)
13:50jlongsterthe-kenny: ok, so I need add my project's path onto the list of classpaths?
13:50phaerI have been trying to install vimclojure for hours, without success. ng-server runs, syntax highlighting, rainbow parens,.. works. But there are now keymappings in, according to :nmap and if i want to :call vimclojure#EvalFile() - for example - it throws errors: http://dpaste.com/141401/
13:50jlongsterCan I do that with Clojure code?
13:55technomancyjlongster: no; the JVM doesn't allow that =(
13:55technomancyjlongster: setting up your classpath is something that should be handled by your editor
13:57jlongstertechnomancy: ok. I can write some Emacs functions. thanks.
13:58technomancyjlongster: they're written for you. =) check out M-x swank-clojure-project from the swank-clojure readme
14:00jlongstertechnomancy: I've already got that set up and using SLIME. It's great. I don't want to hardcode project paths in my .emacs though, so I think I'll write a "slime-at-project" function which takes a path, sets the cwd to it and adds it to the classpath, and fires up SLIME. Or does it do something like that already?
14:02technomancyyou've basically just described swank-clojure-project, yeah
14:03jlongsterOh, I must not have that code then, it sits on top of swank-clojure?
14:03akingjlongster: no need to hardcode paths in .emacs - M-x swank-clojure-project asks for the correct path and automatically uses any jars in the dep dir
14:04technomancyjlongster: it's defined in swank-clojure.el. if you've got an old version remove your config and install via package.el: http://tromey.com/elpa/install.html
14:04akingjlongster: if you're using lein that is..
14:06akingjlongster: see technomancy's leiningen here: http://github.com/technomancy/leiningen/
14:07jlongstertechnomancy: aking: thanks, I'll install it through elpa
14:13jlongstertechnomancy: If I may ask this here, I just installed swank-clojure through elpa. I don't see a swank-clojure.jar though, doesn't it need one? And what should be in my .emacs now? Just my call to "swank-clojure-config"?
14:14LauJensenjlongster: http://www.bestinclass.dk/index.php/2009/12/clojure-101-getting-clojure-slime-installed/
14:16technomancyjlongster: swank-clojure-config is deprecated
14:17technomancyswank-clojure.jar should be handled by leiningen or whatever you're using for deps
14:18jlongstertechnomancy: ok
14:32knuckollsLauJensen: since we're on the topic. that screencast you posted was just what i needed to finally get everything set up with emacs last week. thanks.
14:33LauJensenknuckolls: Great, I'm glad to hear it :)
14:41joshua-choiIs there a version of clojure.template/do-template that encloses its expansions in a list rather than a do block?
14:41joshua-choiOr some kind of sequence
14:43jlongstertechnomancy: So I've downloaded all of the necessary Emacs packages, and now I need the swank-clojure.jar file. Were you saying that I need to build it myself?
14:46technomancyjlongster: no, it should be handled like any other JVM dependencies. (using leiningen, maven, etc.)
14:47jlongsterI'm completely new to the JVM/Clojure world, and that's the first time I've heard of leiningen, which looks like a tool which would help me build swank-clojure.jar. If you have time, do you mind elaborating?
14:49technomancyjlongster: this is a pretty good introduction: http://zef.me/2470/building-clojure-projects-with-leiningen
14:52the-kennyhm.. the post doesn't use "lein new" for bootstrapping project directories
14:53akingjlongster: once you have lein installed and a project setup, just add " :dev-dependencies [[org.clojure/swank-clojure "1.0"]])
14:53the-kennyaking: there's already [swank-clojure "1.1.0"] :)
14:54jlongsterBut surely my project doesn't depend on swank-clojure, it's just my development environment that does?
14:54akingto the project.clj file and do M-x swank-clojure-project
14:55the-kennyjlongster: That's what :dev-dependencies is for
14:55the-kennyaking: you forgot "lein deps"
14:55akingjlongster: you're right - that's why it's tagged as :dev-dependenciers
14:55jlongsterok, I see. It's still a little strange that my project should mention it at all though.
14:58akingSo - to setup a new project called 'jlo', it's simple: lein new jlo; cd jlo; "add the swanl-clojure dependency to project.clj";lein deps - and that's it
14:59the-kennyaking: Yes
14:59the-kenny:)
14:59akingthe-kenny: yup - I'm already using that for 3 different projects - love the uberjar option :)
15:00the-kennyaking: uberjar is really cool - especially for deploying :)
15:10defnim having trouble with shell-out
15:11defn(sh *command* :in "abc123" "-x" "-f" "etc")
15:11defnthe command expects a file where abc123 is
15:12chouser_:in supplies the given string as the command's stdin
15:13cburroughsI am trying to use clojure.contrib.http.agent to open a large number of urls. One of those requests has a problem with "Agent has errors". I can't figure out how to either 1. figure out which url caused the error 2. keep the error from blocking the rest of the requests.
15:13defnchouser: is there a way to fake it being a file?
15:13chouserdefn: many commands take a dash "-" to mean "read from stdin instead of a file"
15:14cburroughs(A better way to open a large number of urls would also be welcome.)
15:14chousercburroughs: agent error handling is up for an overhaul
15:15the-kennycburroughs: Can you define "open"?
15:15jlongsterHey guys, thanks for the help so far. I've got everything installed now and unfortunately I'm getting an obscure error when I run SLIME. I can look into it more, but is this a common error?
15:15jlongsterhttp://paste.lisp.org/display/93041
15:15jlongsterEmacs 23.1 on OS X
15:15chousercburroughs: until then, you can try 'agent-errors' to get a look at the details of the stack trace
15:15the-kennyIf you just want the text behind the url, you could use slurp* together with a ThreadPool
15:15cburroughsthe-kenny, GET the url
15:16chousercburroughs: or be careful to wrap try/catch around every action you send to the agent, printing what ever details you need in the 'catch'
15:16the-kennycburroughs: Try slurp* with a threadPool :) slurp* is a member of duck-streams and can pull text from urls of different types
15:17the-kennyjlongster: Huh? the ~/tmp/bla.something looks wrong
15:17akingjlongster: M-x swank-clojure-project doesn't work?
15:17the-kennyIt's /var/folders/something here.
15:18cburroughsthe-kenny, Is there a standard threadpool to use?
15:18jlongsteraking: no, in the end that still calls slime
15:19jlongsterthe-kenny: I don't know why it's that way, but ~/tmp exists so it should be able to create it
15:19the-kennycburroughs: hm.. not one that I'm aware of. But it's easy of you use java.concurrent.Executor
15:19the-kennyjlongster: hm yes, right.
15:19akingjlongster: I used to do M-x slime to start slime - but no need to now with the lein stuff.
15:20the-kennyjlongster: Are the permission of the directory correct?
15:20jlongsterI create stuff in ~/tmp all the time, so yeah
15:20the-kennyand what if you do "lein repl" and paste the code there? You can also try to modify the file-url when you paste it
15:21ctdeanIt's the shell that expands ~/tmp Try using the fully qualified pathname
15:22jlongsterctdean: good point, that's what it is
15:22jlongsterWhy is it trying to create it there then?
15:25jlongsterfinally.
15:25jlongsterI had to:
15:25jlongster(setq temporary-file-directory "/var/tmp")
15:25the-kennyIn your .emacs?
15:25jlongsterI freaking hate setting up development enviroments.
15:26jlongsteryeah
15:26the-kennytry (expand-file-name "~/tmp/")
15:26the-kennyThe command will expand the ~
15:26jlongsterThe default one in my slime.el was set to ~/tmp
15:26jlongsterI could do that too
15:26ctdeanThere is probably a EXPAND-FILE-NAME missing somewhere in your emacs startup, or a misconfigure env variable
15:27ctdeanyep, like he said :)
15:27akinglooks like slime will use one of: TMPDIR TMP or TEMP, if found
15:27technomancyjlongster: you aren't using aquamacs by any chance, are you?
15:28jlongsterNo, just the normal gnu emacs which recently incorporated the Cocoa-specific Emacs extensions for OS X
15:29jlongsterctdean: Yeah, it looks like "~/tmp" was set in my custom-set-variables
15:30jlongsterThanks guys, gotta restart Emacs
15:30ordnungswidrigre
15:32ordnungswidrigdoes anybody know of a clojure lib to produce css?
15:35ctdeanHow do folks setup a repl when deploying a production app?
15:42poetany idea what could cause this error in leiningen? https://pastee.org/dk3mf
15:57Licensergood evening my lispy friends!
15:57konrhi there!
15:57LicenserI have a question regarding security today. Is it possible to wrap a single function call into something like a 'secure' manner? that it can only accees some functions not overload memory or eat unlimited time?
15:58Licensersomewhat like the clojurebot is doing but I'm not sure of his security isn't JVM based
15:58ordnungswidrigI like the jvm for that
15:58ordnungswidrig+chroot, selinux and ulimit
15:58chouserpreventing consumption of memory and time are both rather tricky, I think.
15:59hiredmanyes
15:59Licenserwell time can be done with a thread and a timeout - that should not be so hard me thinks
15:59chouseryeah, chroot, ulimit, etc. are probably more bullet-proof.
15:59Licenserchouser: yap but I don't want to fire up a own JVM for every function call - not really feasable for my scenario :P
16:00hiredmanLicenser: but what if your function starts other threads?
16:00chouserLicenser: but what do you do when the timeout expires? The only way to guarantee a shutdown of some other thread is using a deprecated method call.
16:00hiredmanthat too
16:00ChousukeClojurebot's security measures are rather fragile :/
16:00hiredmanof course, deprecated things are never *removed* from java
16:00Licenserhiredman: that (and other things) fall under 'can only access some functions'
16:00Chousukeit's pretty easy to DOS
16:00chouserLicenser: you could keep a process running and toss functions to it to eval. nailgun-like.
16:01ordnungswidrigyou could use a bunch of jvm to eval a request and then kill the jvm is a request takes to much time.
16:02ordnungswidrigjkill to the rescue
16:02LicenserHeh
16:02pjacksonHow do people generally host a Compojure app? Via Apache?
16:02ordnungswidrigor ulimit with cpu-bounding. Don't know if you can limit the max user/sys time
16:02LicenserWell I had the same problem with ruby, I solved it by writing a own VM to run the code on (not an ideal but pretty interesting solution)
16:02ordnungswidrigpjackson: you mean apache http server or apache tomcat :-) or apache geronimo.
16:03pjacksonI don't know, how do you do it? :)
16:03ordnungswidrigpjackson: I'd use jetty + ngnix
16:03ordnungswidrigpjackson: or pure jetty if a single instance is enough
16:03pjacksonReally? Cool, thanks.
16:03LicenserWhat I generally want to do is having a Server that can run user submitted functions without them wreaking havoc on the server itself or being able to do more then they should do (
16:04arohner_that's very hard in the general case
16:04arohner_how much do you care about maliciousness?
16:04the-kennyLicenser: Why not do it like clojurebot?
16:04Chousukethe-kenny: Clojurebot is not very safe.
16:04Licenserthe-kenny: because that would also limit the server itself to run certein functions when I'm not mistaken
16:05Licenserarohner_: It sould be not like a open door :P
16:05ordnungswidrigLicenser: i would surely pool some jvms with strict java policy and jail them in chroots.
16:05Chousukethe-kenny: you can't take over the system it runs on, but you can make the JVM it runs on pretty much use its maximum allotted resources.
16:05knuckollspjackson: there was an article on hn about deploying compojure websites earlier today. http://briancarper.net/blog/deploying-clojure-websites
16:05ordnungswidrigLicenser: you can distribute the requests using some mq like rabbitmq
16:05Licenserordnungswidrig: sounds like a good start
16:06hiredmanthe other option is writing an interpreter
16:06ChousukeLicenser: write a clojure interpreter and disable the . special form except for core functions!
16:06ChousukeLicenser: then you can easily interrupt any rogue clojure code.
16:06LicenserChousuke: I run a solaris under it, so I can limit exessive use of system resources
16:06LicenserChousuke: and we'd have clojure in clojure :P
16:06ordnungswidrigare there distributed agents for clojure?
16:07ChousukeLicenser: yeah, but you need to restart the JVM still :/
16:07ordnungswidrigLicenser: …the wholy grail: cinc
16:07Chousukea clojure interpreter would not be cinc :)
16:07pjacksonA repl to live seems like a bad idea... doesn't it?
16:07ordnungswidrigchouser: i know.
16:07Chousukewell, it would be, but I want a compiler ;/
16:07Licenserheh I'll go with a mission specific interpreter - sory
16:08ordnungswidrigwill jvms of recent java versions share memory? I remember some vm options. So that if multiple jvms run the same libs they don't all have a copy of the code in mem?
16:08jlongsterIs eval in clojure limited to the clojure.core namespace, or can I eval inside a different namespace?
16:09ordnungswidrigthat was java -Xshare:on
16:09Chousukejlongster: eval happens in whatever namespace you're in
16:10Chousukejlongster: and in whatever environment :P
16:10Chousukecan't access locals though.
16:11jlongsterHm, for some reason *ns* was clojure.core when I tried, but that must have been something else
16:11Licenserthen a interpreter it shall be!
16:13Licenserbut first some other things
16:44lpetitChousuke: but preventing user code to use the . special form, thus limiting the access of any method/static field of any java class for all users is ... rather restrictive ! How do you make your String uppercase ?
16:45lpetitChousuke: and also, you'll have to prevent the user from jumping into the clojure.core ns and defining all his functions in there ... :-p
17:41xstertest 1 2 3
17:41the-kennyxster: Test passed
17:41xsterkewl!
17:42xsterwhendo people get together to talk about clojure?
17:42JonSmithright now
17:42JonSmithhere
17:42xsterWell, I'm a newbie. But I really like what I've read about clojure
17:43xsterI come from a C, Java, Smalltalk background
17:43xsterI've over the years tried to learn Lisp and Scheme, but did not get very far, I'm afarid.
17:43xsterI'd like to become proficient in clojure though
17:44xsterAny tips for someone like me?
17:44JonSmithi feel the same way
17:44JonSmithexcept i come from lisp and am bad at c and java
17:44hiredmanyou could do some analysis of the logs to discover peak #clojure times
17:45xsterWell, as a Lisper, i think you're certainly one up on me
17:45JonSmithwell remember that java libraries are like clojure libraries
17:45JonSmithso you can just plug them in pretty much
17:45xster@hiredman: interesting. I'm new to IRC as well. how do I read the logs of previous IRC chats?
17:46ohpauleezxster: http://clojure-log.n01se.net/
17:46arj_any good tips for easy profiling in clojure?
17:47xster@ohpauleez: Thanks!
17:47ohpauleezxster: totally welcome
17:47xster@JonSmith: have you had experience with Genera or Symolics Lisp?
17:48JonSmithnope!
17:48arj_I'm looking for something like (profile *something)
17:48JonSmithjust writing application code in old(e) versions of common lisp
17:48JonSmithlike gold hill lisp 4!
17:49gravityarj_: I've heard that using the jvm's profiling flags is good, but I've not done it myself
17:49arj_gravity: thanks
17:49ohpauleezxster: to answer your question, read these: http://java.ociweb.com/mark/clojure/article.html http://en.wikibooks.org/wiki/Clojure_Programming/By_Example
17:50ohpauleezand hang out in here for a week or so
17:50ohpauleezand you'll be up to speed in no time
17:50JonSmithand write code
17:50JonSmithwrite lots of code
17:51ohpauleezAlso it helps to watch the screencasts on clojure.org
17:51JonSmithwriting > reading
17:51ohpauleezagreed
17:52xsterThanks guys!. Those are great tips.
17:53xster Since I'm used to Smalltalk, I've come to appreciate the value of a good development environment, and the usefulness of using an image. How good are Common Lisp IDEs such as LispWorks or Genera? I'm sure clojure is still too new to have as good a development environment.
17:53arj_xster: Emacs
17:53the-kennyxster: Clojure has an excellent development environment: Emacs together with Slime :)
17:54JonSmithi didn't know you could get genera beyond emulation
17:54the-kenny(Slime has it's roots in Common Lisp, but it's expandable)
17:55xsteremacs? *cough* I was hoping for more Smalltalk tools such as the browser, inspector, and debugger. One can code in the debugger.
17:55ohpauleezxster: I think both emacs and vim are great for clojure. Clojure is the first lisp I use vim with
17:55mebaran151what's the best way to get the arity of a function object?
17:55the-kennyxster: You have a browser, a repl and an inspector in emacs :)
17:55gravityO
17:56ohpauleezxster: there is a plugin for netbeans, and I think someone may have an eclipse plugin
17:56gravityI've not seen the coding inside the debugger thing anywhere but smalltalk
17:56the-kennygravity: You mean something like redefining functions while stepping in the debugger?
17:57gravityxster: There is an inspector in the clojure.inspector namespace
17:57the-kennyThat's possible with Slime in Common Lisp, but sadly not in Clojure
17:57gravitythe-kenny: Yeah
17:57gravityAh, neat
17:57ohpauleezmebaran151: no idea, but if you get reflection on it, you may find a field for that sort of thing
17:57the-kennygravity: There's also a really cool inspector in slime :) C-c I
17:58the-kennymebaran151: It's possible if you can get the metadata of the var, like #'+. I don't think there is a way with function-objects
17:58gravitythe-kenny: Cool! I'll play with that some more later
17:58the-kenny(functions don't have metadata in clojure)
17:58gravityI really need to dig in to slime. I know I'm barely using it
17:58mebaran151seems like there should be a way to reflect that
17:59mebaran151I'm trying to figure out a functional way to wrap Netty that doesn't make people cry
17:59the-kennygravity: If you use a frequent version of swank-clojure (1.1.0), you can also do -x swank-list-threads and kill java-threds from there :)
17:59technomancyxster: if you're hoping for smalltalk-like support, every language is going to disappoint you.
17:59the-kennyUhm.. M-x ...
17:59JonSmithm-x smalltalk-mode?
18:00gravityoooooh.... I could use some thread control.
18:00gravityToo much stuff!
18:00mebaran151I wonder if ti was possible to somehow integrate metadata and annotations
18:01mebaran151modern Java has moved toward using annotations, which make interoperability with clojure a little bit more problematic
18:01xster@technomancy: You may be right.
18:02technomancythe-kenny: list-threads is really slick; thanks!
18:02the-kennytechnomancy: I'm glad I can help :)
18:02xsterI've head thoughthat genera from Symbolics was the most productive Common Lisp environment around. Don't know if it's true or how well it stacks up against Smalltalk.
18:03the-kennytechnomancy: I would like to implement more things like the thread-list, but it's kind of hard to find missing features. Any suggestions?
18:04technomancythe-kenny: there's a TODO in swank-clojure. =)
18:04JonSmithhum, can't find any symbolics machines on ebay
18:04technomancyprompting for insertion of :import lines when you try to refer to an unqualified Java class would be a great feature.
18:04technomancyalso making M-. work for namespaces
18:05the-kennytechnomancy: Ah :) Cool, and even in org-mode. I'll take a look.
18:05xster@JonSmith: yeah, they're like moon rocks. however genera can be run in an emulated Dec Alpha environment
18:06arj_how does a dosync inside another dosync work?
18:06JonSmithi think i just found a moon meteorite on ebay though :-P
18:06arohner_arj_: the transaction happens at the end of the outermost dosync
18:07arj_arohner_: ah, cool. That is perfect for composability
18:07arohner_arj_: that's the plan :-)
18:07arj_sweet!
18:07arj_thanks arohner_
18:07arohner_np
18:08the-kennytechnomancy: hm.. looks like slime-list-threads is broken in Emacs 22 too :(
18:21Licenserhmm I know there is an easy way to write a function that returns an unique id in clojure but I'm just too stupid to think of it :(
18:22rhickey,(gensym)
18:22clojurebotG__5824
18:22rhickey,(gensym)
18:22clojurebotG__5828
18:22rhickeyor use UUIDs
18:22ohpauleezrhickey: Update the copyright on the bottom of clojure.org
18:22LicenserI
18:22LicenserI
18:22Licenserargh sorry
18:23rhickeyohpauleez: done - thanks
18:23LicenserI'd mean something like a function that returns 1, 2, 3 ... for every call - I saw an example somewhere
18:23Licenseron the other hand uuid's are just fine too
18:24rhickey,(gensym "")
18:24clojurebot5832
18:24rhickey,(gensym "")
18:24clojurebot5836
18:24Licenserrhickey: that is briliant
18:25ohpauleezrhickey: np, noticed it today
18:25the-kennyA
18:25the-kennyOops
18:26LicenserI really enjoy clojure more and more as I use it
18:35mebaran151anybody know any good libraries for something akin to binary json to efficiently send some clojure data structures between processes?
18:35bradfordanyone had class not found issues in emacs/slime with genclassing?
18:36Knekkmebaran151: something like Thrift?
18:36mebaran151something like Thrift without the whole fixed schema precompiling
18:36hiredmansomeone did a clojure implementation of bert
18:36mebaran151I'd like to take a hash map and send it down river
18:36patrkrisquestion concerning clojure.contrib.http.agent: how do I specify headers to (http-agent ...) without having to calculate the request length manually?
18:36hiredman~google clojure bert
18:36clojurebotFirst, out of 465 results is:
18:36mebaran151bert?
18:36clojurebottrotter's bert-clj at master - GitHub
18:36bradfordI've found that I have to stick requires for all the ns'es that i use before i import the gen'd classes
18:36clojurebothttp://github.com/trotter/bert-clj
18:37Knekkwith Thrift you can just send a hashmap, simple schema
18:37mebaran151do I have to run a precompilation stage though?
18:37mebaran151I'd be happy to use thrift, but I'd prefer not to go through all the code genning
18:38mebaran151especially 'cause I have to write an actionscript adapter too, and last I looked thrift and as3 weren't best buddies
18:38Knekkdunno then
19:16konrGuys, what do I need to do to make swank find swank.clj? I'm getting the 'java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)' despite having its directory on the swank-clojure-extra-classpath
19:17the-kennykonr: I would suggest using leiningen in combination with swank-clojure-project. It's dead-easy and very cool
19:19konrthe-kenny: hmm, what do I need to set in order to use it? I tried it here and slime was loading sbcl, haha
19:20the-kennykonr: Here is the readme for leiningen: http://github.com/technomancy/leiningen/blob/master/README.md After you ran "lein deps", you can just fire a repl in emacs with M-x swank-clojure-project
19:20the-kennyAll classpaths etc. are set correctly according to the project.
19:22ieure+1. I use it, and it rocks.
19:24Licenserout of curiosity is a vector faster at sorting then a list?
19:25konreven that doesn't work. I guess that I'm having some problem with the versions
19:26the-kennykonr: What's the error if you use leiningen?
19:27the-kennyHave you added [swank-clojure "1.1.0"] to the list of dev-dependencies? :dev-dependencies [[swank-clojure "1.1.0"]]
19:29konrthe-kenny: yes, and it was working in another box. The error is the same, and happens after I use swank-clojure-project - 'java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0)'
19:31konrthe-kenny: the swank-clojure jar in lib/ also seems to be valid
19:31the-kennykonr: That's strange
19:45konrthe-kenny: do you set any variable or configure emacs in some way, besides requiring swank-clojure and clojure, to use swank-clojure-project? I've noticed that I don't get an error without the (clojure-slime-config) line (although in this case it loads the wrong lisp).
19:46the-kennykonr: In fact, I don't even require swank-clojure explicitly, as it's managed by elpa.
19:46the-kennykonr: And no, I don't set any additional vars.
19:47the-kennykonr: I use swank-clojure only in combination with leiningen. I've never bothered with setting additional variables.
19:57rdsrHi all, is there a good way to convert between a java map (e.g. Hashtable) to clojure persistent arraymap
19:58rdsrI ask this because I cannot read values from hashtable the way I can from clojure maps
19:59rdsrlike (map key)
19:59technomancy(into {} my-hash-table) maybe
19:59rdsroh ok thk technomancy
20:12poetwhat should be used instead of (gen-and-load-class)?
20:12poetas that macro was removed
20:13Chousuke:gen-class in the ns form
20:14Chousuke(doc gen-class)
20:14clojurebot"([& options]); When compiling, generates compiled bytecode for a class with the given package-qualified :name (which, as all names in these parameters, can be a string or symbol), and writes the .class file to the *compile-path* directory. When not compiling, does nothing. The gen-class construct contains no implementation, as the implementation will be dynamically sought by the generated class in functions in an impleme
20:14Chousukesee that, and also see (doc ns)
20:31mebaran151why don't function objects support metadata?
20:33ctdean_What's the difference between the elpa version of slime and the one from common-lisp.net ?
20:37the-kennyctdean_: The one from elpa is just slime on the emacs-side. The other side (swank) needs to be installed seperatedly by the dependency-manager of your backend.
20:37the-kennyctdean_: The one from common lisp should bring a bunch of .lisp-files for different common lisp implementations and some contrib modules with it
20:38ctdean_the-kenny: it looks like all the slime/contrib stuff is missing too
20:39the-kennyYes, the contrib stuff is missing. But most people only use one or two modules from there (usually repl and fancy) and it's no problem to install them by hand
20:39the-kenny(slime-repl is also in elpa)
20:40the-kennyMaybe someday more and more of these contrib-stuff will be in elpa when it's integrated in emacs
20:41ctdean_I see (I use 6 from contrib myself)
20:41hiredmanmebaran151: (with-meta a m) evaluates to a new thing, a-prime with the metadate m, doing this with functions is slightly more complicated and some choices have to be made (regarding function identity and equality, closed over values, etc) and rather than make those choices, fn's just don't support metadata for now
20:42mebaran151but technically, there could be a with-meta! that just added a hash-map to the field
20:42ctdean_There also seems to be enough of a version skew that the latest cvs slime doesn't work with the lein swank server
20:42technomancyctdean_: that's correct, you can't use cvs slime with clojure at all
20:43ctdean_This is going to wreak havoc with my CL development
20:43technomancyI'd love help bringing the clojure side up to date, but I don't have time to do it myself
20:44hiredmanmebaran151: fortunately this is not a technical decision, but a design decision
20:44ctdean<--- irc client keeps crashing :(
20:44technomancyctdean: I'd love help bringing the clojure side up to date, but I don't have time to do it myself
20:45mebaran151it would be nice to have it for Strings to, but I understand why their implementation might be problematic
21:32poetis there a way to force a member of a structure to be a certain type?
21:40chousernope
21:44chouserbut that's the kind of thing that deftype can do for you ("new" branch)
21:58konrIs there a clojure.contrib cheatsheet?
22:02djorkHow would you like to edit Clojure on your iPhone :)
22:02djorkwithout typing much
22:05akingdjork: I got clojure running on the iphone with jamvm - but it took about 20s to show the repl
22:05djorkI'd want to run the code remotely
22:05djorkover HTTP/S
22:05djorkor whatever transport
22:05akingohh.. that's different then
22:06djorkbut I am interested in building an S-expression editor
22:06mebaran151djork, I'm also considering building a clojure editor in clojure
22:07djorkthat would be fun
22:07mebaran151I'm thinking of layering it on top of neo4j actually
22:07djorka Dr Scheme for Clojure
22:07akingI saw someone writing an emacs like editor in javascript - you could probably use that as a base
22:07mebaran151and connecting depending fn's as nodes
22:07mebaran151at the end I'd just output all the files in whatever configuration you wanted
22:08mebaran151so ns reorganization would be fast
22:09djorkneo4j... not familiar
22:09djorkah, graph database
22:09mebaran151i've always thought it would be cool if one could cherrypick fn's from projects, if we weren't bound to libraries as they existed but only as they relied on other fn's
22:09djorkcool
22:09mebaran151yeah it's a graph db
22:09chouserdjork: I want
22:10mebaran151yeah I think it would be cool too
22:10djorkworking on it as we speak
22:10mebaran151you might be able to use some of the code I'm writing now, connecting netty to evaluate s expressions
22:11mebaran151I wish I had an iPhone :(
22:11djorkno you don't
22:11djorkAT&T sucks and it's expensive :)
22:11mebaran151I have ATT
22:11djorkIf I wasn't working for an iPhone shop I wouldn't have one
22:11mebaran151but no iPhone
22:11chouserso expensive. I wouldn't have one if I had to pay for it.
22:11djorkI DO have to pay for it
22:11mebaran151I got a Blackberry Bold, which is actually a neat little device
22:11djorkthat's the shitty part
22:11mebaran151I haven't gotten a chance to whack clojure on it
22:11djorkyeah those aren't bad at all
22:12mebaran151I like it for typing
22:12mebaran151I'd actually love to have a dev environment for it
22:12somniumdjork: have you seen ymacs?
22:12chouserI don't like typing on the iphone, though I guess it's slight better than graffiti
22:12mebaran151I didn't mind graffiti
22:13mebaran151could Clojure run on an BlackBerry Bold
22:13mebaran151it's got a beefy little processor, and I think everything RIM does is Java Tastic
22:13chouserno, not terrible. typing on the iphone is better though
22:13djorkchouser: as little typing as possible would be the goal
22:13djorklists of fns
22:13mebaran151djork, that would be generally useful for all mobile phones
22:13chouserright. auto-completing keywords. oh, sure, lists
22:13djorkyes
22:14djorkwriting code and other things like SSH clients suck horrendously on mobile devies
22:14djorkdevices
22:14hiredmanmebaran151: bb's still only have j2me
22:14mebaran151j2me can't run Clojure?
22:14hiredmanj2me is a complete waste
22:14hiredmannope
22:14mebaran151I thought j2me was j2se without swing and stuff
22:14hiredmannope
22:14mebaran151oh
22:14mebaran151I know nothing of phone dev land
22:14hiredmanj2me is like java 1.3 or 1.4
22:15mebaran151I just thought it would be cool to hack clojure on my blackberry
22:15mebaran151and clojure probably needs 1.5 for generic support
22:15hiredmanit would, if someone would release a phone that actually ran java
22:15hiredmanmebaran151: nope
22:15mebaran151nope?
22:15hiredmanit needs 1.5 for the Collections api mostly
22:15hiredmanclojure doesn't care about generics
22:15mebaran151I thought the collections api was from way back when
22:16mebaran151which is why it was so badly designed
22:16hiredmanthats possible
22:18mebaran151I thought Dalvik was basically j2me but with different bytecode and reinvented by google
22:18hiredmanit's more like standard java with a different bytecode
22:19djorkdalvik, yech
22:19hiredman(the developement environments for j2me are hellish as well)
22:19djorkthe dalvik compilation step can get nasty if you have bad 3rd-party jars
22:20hiredmanpalm's phones apparently come with apache's jre
22:20hiredmanharmony
22:22djorkthat's pretty good
22:22djorkbetter than most
22:22djorkbut basically, whenever I see the Java logo come up on a phone I know I am going to be waiting a while
22:22djorkand not just at startup
22:22djorkevery button press, and even shutdown, is painful
22:33mebaran151sigh
22:33mebaran151I wonder if Clojure in Clojure could actually help the mobile phone scene
22:34mebaran151though concurrency isn't a huge issue for phones yet
22:35KirinDave2mebaran151: Distribution is, tho.
22:35mebaran151oh yeah, I couldn't even tell you how to load a program on my blackberry
22:36mebaran151I think Adobe AIR actually might help this a great deal if they get the whole Open Mobile thing to work out
22:36mebaran151Adobe products always make deployment trivially easy
22:52alexykchouser: ping
22:53chouserhiredman:
22:53chouserer
22:53chouserhi
22:53chouser:-)
22:54alexykso I'm using your sorted-seq-merge from yesterday, which was toy-tested for int seqs and uses (< x y). But the real data is java.util.Date, which is compared with: (< (.compareTo (first a) (first b)) 0)
22:54alexykunless there's a prettier way equivalent to <
22:54alexykhow do we parameterize sorted-seq-merge with the sorting predicate, defaulting to < ?
22:55chouserhmmm
22:57alexykkind of tests the whole dynamic typing :)
22:57alexyki.e., the literal (< x y) -- works only for numbers?
22:59chouseryes, apparently for performance reasons
23:00chouserall fns implement .compare -- I'm trying to think if that would be useful.
23:00alexykthe question is, do I really have to specialize per type, e.g. sorted-date-seq-merge, or there's an efficient way to parameterize
23:00alexyksimplest case is numbers and strings
23:02chouserI guess it'd be reasonable to accept 2 or 3 args, [comparator a b]
23:05chouseruse (.compare comparator (first a) (first b)), comparator can default to <
23:05alexykchouser: would it be as efficient as hard-coded < for numbers? And how do I syntactically write the default to < ?
23:07chouser< is faster for unboxed numbers, but these will all be boxed.
23:07chouser...so I dunno. It seems plausible to me that hotspot could make it about as fast. I guess you'd have to test it.
23:09alexykchouser: the minor question remains, how to do default. Check if comparator is given in an (if ...)?
23:09alexyk(if comparator (.compare ...) (< ...))?
23:09chouserno, < implements .compre
23:10chouseras do all two-arg clojure fns :-)
23:10alexykok; so how'd I give < as a parameter?
23:17lisppaste8Chouser annotated #93006 "three-arg sorted-seq-merge" at http://paste.lisp.org/display/93006#1
23:29chouserha! don't use that version
23:30chousermy recursive calls weren't including the new arg
23:35GeekyCoder :)
23:38lisppaste8Chouser annotated #93006 "fixed it" at http://paste.lisp.org/display/93006#2
23:39chouseralexyk: there you go. Could use a type hint on 'c' if you care about performance
23:40chousercould also try to build a chunked seq instead of one-at-a-time. Dunno how well that would go.
23:40chouseroff to bed.
23:43alexykthanks much!
23:44alexykgonna try