2009-05-06
| 00:46 | lisppaste8 | dysinger pasted "clojure 1.1-SNAP on gentoo" at http://paste.lisp.org/display/79740 |
| 03:33 | Raynes | It's storming. :\ |
| 07:06 | cgrand | wow it's very quiet this morning |
| 07:06 | Cark | hush ! |
| 07:06 | Cark | =P |
| 07:07 | Raynes | What are the benefit's of using Git? (This ought to do it.) |
| 07:28 | jdz_ | git is awesome |
| 07:28 | jdz_ | but i'm repeating myself |
| 07:29 | jdz_ | git bisect --help |
| 07:39 | Cark | anyone using compojure ? |
| 07:40 | Cark | i can't seem to find a way to modify the session from a handler |
| 07:41 | Cark | ahwell i guess i only had to ask here in order to find the solution |
| 07:41 | Cark | =P |
| 08:19 | Raynes | D'aw shit. TVS just tripped, moving in my direction. :\ |
| 08:29 | Raynes | There is a town near me named Arkadelphia. Neat. |
| 08:44 | chessguy_work | are clojure symbols case senssitive? |
| 08:44 | Chouser | yes |
| 08:54 | chessguy_work | ok |
| 08:54 | chessguy_work | so i'm thinking of using anaphoric macros to build a chess pattern-recognizing system |
| 08:54 | chessguy_work | sometying along these lines: http://paste.lisp.org/display/79760 |
| 08:55 | chessguy_work | part of the idea is to separate the patterns from what to do with the matches |
| 08:56 | chessguy_work | since i'm very new to macros, i'd love to know if i'm completely insane |
| 09:02 | Chouser | you can't pass around macros like that |
| 09:02 | Chouser | *usually* trying to get at a macro as a function is not what you want, so you're prevented. |
| 09:02 | jdz_ | macros are invoked before compiling code to transform the code |
| 09:03 | Chouser | in this case, though, you could make kqk be a function (that still takes clojure forms and returns a clojure form), and pass that into your apply-pattern macro. |
| 09:04 | chessguy_work | but as a function, could it leave those variables defined the way i want it to? |
| 09:07 | Chouser | (defn kqk [& body] `(let [~'K "king" ~'Q "queen"] ~@body)) |
| 09:07 | Chouser | (defmacro apply-pattern [pat & body] (apply (resolve pat) body)) |
| 09:07 | Chouser | (apply-pattern kqk (println K Q)) |
| 09:07 | Chouser | I'm not quite sure what you're trying to do, but something like that might work. |
| 09:08 | Chouser | note the 'resolve' call, in order to take the *name* of a function at compile time, in this case "kqk", and find the appropriate function to run,. |
| 09:08 | chessguy_work | what is resolve? |
| 09:09 | cgray | hi, i'm a bit confused by the .. macro. is it possible to turn (. foo (bar) (baz "quux")) into something more elegant using it? |
| 09:11 | chessguy_work | Chouser, that seems like it could be what i want, i'm just trying to parse it here. why the back-quote in a non-macro? |
| 09:12 | Chouser | chessguy_work: because the macro is using that fn as a helper to produce a code form, which the macro will then return. |
| 09:12 | chessguy_work | ohhhh |
| 09:12 | chessguy_work | brilliant! |
| 09:13 | Chouser | I'm not sure this is a good idea. you're really going to have other fns besides kqk that apply-pattern needs to take? |
| 09:13 | chessguy_work | oh yes, many |
| 09:15 | chessguy_work | what's the down-side? |
| 09:16 | Chouser | you can only pass in globally named functions to apply-pattern, since it uses resolve to look it up. No anoymous or locally-defined functions. |
| 09:17 | chessguy_work | yuck |
| 09:18 | chessguy_work | why does it need resolve? |
| 09:22 | aosborne | cgray: I don't think it helps in that case, it's for chaining java methods. eg: (.. foo (getA x) (getB y)) is equivalent to foo.getA(x).getB(y) in java notation |
| 09:22 | aosborne | ,(macroexpand '(.. foo (getA x) (getB y)) |
| 09:22 | clojurebot | EOF while reading |
| 09:22 | aosborne | ,(macroexpand '(.. foo (getA x) (getB y))) |
| 09:22 | clojurebot | (. (. foo (getA x)) (getB y)) |
| 09:23 | cgray | aosborne: I thought my code was equivalent to foo.bar().baz("quux") |
| 09:23 | cgray | maybe I'm misunderstanding . as well :) |
| 09:23 | chessguy_work | Chouser, i don't get this. why is resolve needed? |
| 09:25 | aosborne | hehe.. your example can't be written in java notation |
| 09:26 | cgray | hmm, it works though |
| 09:26 | aosborne | really? hmm.. maybe I'm misunderstanding the docs.. I hadn't tried using . like that before |
| 09:30 | aosborne | cgray: actually I think for your example it just drops the (baz "quux") |
| 09:30 | cgray | aosborne: what do you mean? |
| 09:31 | aosborne | (. System/out (println) (str "quux")) |
| 09:31 | aosborne | prints nothing |
| 09:31 | aosborne | so I assuming it's just the same as: (. System/out (println)) |
| 09:31 | aosborne | (. System/out println (str "quux")) works |
| 09:32 | unlink | What's the easiest way of calling clojure from java without the boilerplate of interning Vars, etc. |
| 09:32 | aosborne | (. System/out (println (str "quux"))) <-- so does this |
| 09:32 | aosborne | just not mixing the two forms |
| 09:33 | cgray | the second one doesn't work for me |
| 09:33 | cgray | in the form I'm using, (baz "quux") is called for a side-effect, and the side-effect is happening... |
| 09:34 | aosborne | (. System/out (println) (assert false)) <-- doesn't throw an exception for me |
| 09:34 | aosborne | I dunno then ;) |
| 09:34 | cgray | you're right |
| 09:34 | aosborne | oh wait |
| 09:34 | aosborne | assert is a macro |
| 09:35 | cgray | but it's not quite the same thing... you're writing System.out.println().str("quux") if i understand correctly... |
| 09:35 | aosborne | (. System/out (println) (Th!s is invalid)) <-- no exception |
| 09:36 | aosborne | hmm |
| 09:36 | Chousuke | hmmh |
| 09:36 | Chousuke | so . just ignores extra parameters? :/ |
| 09:37 | aosborne | cgray: your example was this right: (. foo (bar) (baz "quux")) |
| 09:37 | cgray | yep |
| 09:37 | Chousuke | in that case (baz "quux") apparently gets silently ignored. |
| 09:38 | cgray | oh crap, you might be right... |
| 09:38 | aosborne | yep, not even evaluated.. which is odd that you're seeing a side-effect happening |
| 09:38 | cgray | sorry, the side-effect didn't happen |
| 09:38 | Chousuke | if you want to do chaining, don't use . anyway. use -> or something |
| 09:41 | cgray | good to know |
| 09:41 | unlink | ant |
| 09:42 | aosborne | unlink: depends how you want to call it: eval? run a script? use a class defined in Clojure code? |
| 09:42 | Chousuke | It's the special form so eventually all the sugar will be reduced to it, but I still think it should be avoided in most code in favour of the .method syntax (and -> instead of ..) |
| 09:43 | cgray | Chousuke: so foo.bar().baz("quux") should be (-> foo (.bar) (.baz "quux")) ? |
| 09:43 | unlink | aosborne: I just want to call a function in clojure code. |
| 09:43 | unlink | (.. foo bar (baz "quux")), no? |
| 09:44 | Chousuke | cgray: yeah |
| 09:44 | aosborne | http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java |
| 09:44 | Chousuke | unlink: I don't like .. either. it doesn't allow mixing clojure functions and java methods |
| 09:44 | Chousuke | cgray: though you can just say (-> foo .bar (.baz "quux")) |
| 09:45 | cgray | Chousuke: cool, thanks |
| 09:46 | Chousuke | cgray: and as I said, you can mix in clojure functions as well |
| 09:47 | Chousuke | ,(-> "foo" .toUpperCase (println "afterfoo")) |
| 09:47 | clojurebot | FOO afterfoo |
| 09:54 | unlink | How do you (set!) from java? e.g. *warn-on-reflection* or *command-line-args* |
| 09:56 | Raynes | Tornado sirens are hurting my ears. :( |
| 09:59 | cgray | Raynes: that usually means you should do something :) |
| 09:59 | marklar | cgray: usually? :) |
| 10:00 | cgrand | unlink: myvar.bindRoot(myObject) |
| 10:03 | Raynes | cgray: Not in this case, I've been watching live tornado coverage all morning. It's to the south and east of me, the line past me just a moment ago. |
| 10:04 | Raynes | Tornadoes are isolated event's and only effect a small area, but the sirens go off for the entire county. |
| 10:04 | Raynes | Annoying. |
| 10:08 | unlink | thanks cgrand |
| 10:09 | cgray | Raynes: out of curiosity, where are you? I used to live in Tulsa, and we'd get tornado sirens all the time... |
| 10:16 | Raynes | cgray: Walker County in Alabama. |
| 10:16 | Raynes | Extreme Northwestern Walker County to be specific. |
| 10:27 | Holcxjo | Woot! Just got an email from pragmaticbookshelf.com -- in the "Coming up next" section I read: "Programming Clojure in print shortly" |
| 11:06 | Chouser | well, I tried to deploy my little phone app to the first user. Failure. |
| 11:06 | rhickey | Chouser: :( |
| 11:06 | Chouser | the jni piece is just too fragile |
| 11:07 | Chouser | the built-in repl was great for tracking down and solving other config issues -- his phone was set up a little oddly, and we were able to figure that out. |
| 11:07 | Chouser | but when it tries to use a standard unix socket, it segfaults. why oh why did java have to leave that out of the standard lib. |
| 11:09 | Chouser | we tried it with my .class files and his own .so's, but it segfaulted. So then we tried with my dbus .classes, but his .so and unixsocket .classes, but it segfaulted. |
| 11:09 | Chouser | of course with each of the attempts the tidy little command-line to launch it got more and more complicated... |
| 11:09 | durka42 | can't you use regular sockets? |
| 11:10 | durka42 | when i had to do serial ports i used a companion program that listened on a regular socket |
| 11:10 | durka42 | still annoying |
| 11:10 | Chouser | dbus doesn't do that. With good reason -- you want the socket to be discoverable per-user, not some port number that's global for the whole machine. |
| 11:10 | durka42 | oh, i see, you don't get to write the companion program :) |
| 11:11 | rhickey | http://www.michaelnygard.com/blog/2009/05/kudos_to_relevance_and_clojure.html |
| 11:11 | Chouser | no, I'm talking to libpurple aka pidgin |
| 11:11 | durka42 | you could still put some horrible hack of a C program in between you and dbus |
| 11:12 | Chouser | or I could write my app in ruby or python, where I would have easy access to unix sockets. there are dbus libs for each that don't need any of their own machine-native parts. |
| 11:12 | durka42 | that too |
| 11:13 | danlarkin | right language for the right job |
| 11:13 | Chouser | but I want Clojure to be the right language. |
| 11:13 | danlarkin | :) I do too, but sometimes it's not and we all have to accept that :'( |
| 11:14 | durka42 | what does jruby do? |
| 11:14 | durka42 | oh, they use jna |
| 11:14 | Chouser | presumably just doesn't supply access to that part of its standard lib. |
| 11:14 | Chouser | oh, really? hm... |
| 11:14 | Chouser | hm... |
| 11:17 | Chouser | rhickey: nice writeup |
| 11:17 | durka42 | http://stackoverflow.com/questions/170600/unix-socket-implementation-for-java |
| 11:17 | Chouser | durka42: there's a debian/ubuntu package libunixsocket-java |
| 11:18 | Chouser | works great locally, but deploying jni turns out to be hard. |
| 11:19 | durka42 | i imagine |
| 11:20 | rhickey | Chouser: what I like about the article is that it shows the perhaps unplanned benefits of simply following the model (not that Stu et al didn't anticipate it) |
| 11:20 | Chouser | rhickey: exactly |
| 11:20 | Chouser | durka42: since it's a standard package, I thought I had dodged a bullet -- tell the user to install the package, and we're good to go. |
| 11:21 | Chouser | but apparently there are version incompatibilities or something. |
| 11:21 | rsynnott | durka42: if it's just mysql access you want, you could potentially use UnixODBC |
| 11:21 | rhickey | One of the things I was trying to address with Clojure is how multithreaded access is often added later, then sharing mutable things you didn't plan to share and adding/expanding a lock policy is incredibly difficult |
| 11:21 | rsynnott | pretty sure it supports using unix sockets |
| 11:21 | stuhood | ~delicious |
| 11:21 | clojurebot | delicious is http://delicious.com/clojurebot |
| 11:23 | Chouser | symbol macros?? |
| 11:25 | rsynnott | where does clojurebot get material for its delicious? |
| 11:25 | rsynnott | just every url posted here? |
| 11:27 | Chouser | whoa. macrolet and symbol-macrolet implemented using code walkers, in clojure.contrib.macro-utils |
| 11:28 | danlei | interesting |
| 11:28 | twism | hello clojure... |
| 11:29 | twism | quick question |
| 11:30 | twism | i have a function that takes a list and spits out the list as a string (serialize)... |
| 11:30 | twism | (my-func '(fn [x] x)) => "(fn [x] x)" |
| 11:31 | stuhood | rsynnott: yea |
| 11:31 | Chouser | ,(pr-str '(fn [x] x)) |
| 11:31 | clojurebot | "(fn [x] x)" |
| 11:31 | twism | how would i go about having the function just work with a form |
| 11:31 | twism | without the list suguar |
| 11:32 | twism | Chouser: sweet |
| 11:32 | Chouser | (defmacro form-str [form] (pr-str form)) |
| 11:32 | Chouser | (form-str (fn [x] x)) |
| 11:32 | twism | Chouser: thanks man |
| 11:32 | Chouser | np |
| 11:35 | twism | sweet: that works well with lambdas too! |
| 11:35 | twism | Chouser:* |
| 11:36 | Chouser | I don't know what that means, but great! :-) |
| 11:36 | twism | (form-str #(test x)) => "(fn* [] (test x))" |
| 11:37 | twism | oh you mean me blowing you a kiss lol |
| 11:38 | Chouser | no, you answered my question. #() isn't really any more a lambda than (fn []) |
| 11:38 | twism | oh i meant the sugar for lambda |
| 11:38 | Chouser | #() is an Anonymous function literal. |
| 11:39 | Chouser | but sure. I just wasn't sure what you meant by "lambda" there. |
| 11:39 | danlei | lambda<->fn |
| 11:39 | twism | Anonymous function literal it is |
| 11:40 | twism | my fault for the confusion |
| 11:45 | konato | Does anyone having this error after getting the last version: java.lang.RuntimeException: java.lang.IllegalArgumentException: Wrong number of args passed to: test-is$report (NO_SOURCE_FILE:0) [Thrown class clojure.lang.Compiler$CompilerException] |
| 11:45 | konato | But running my test outside emacs works |
| 11:45 | marklar | konato: no, but I did get a similar arguement with =, doing a clean build fixed it |
| 11:46 | marklar | s/arguement/error |
| 11:46 | stuartsierra | the signature of test-is/report changed recently, may need a recompile |
| 11:46 | konato | I did clear and rebuild |
| 11:48 | konato | Thank you, i'll check that everything is fresh |
| 11:56 | konato | Still doesn't work, I'm at clojure-1.1.0-alpha-SNAPSHOT, anyone using emacs, slime with this version |
| 12:27 | durka42 | aviread returns a height-by-width-by-3 array of values |
| 12:28 | durka42 | sorry, wrong channel |
| 12:46 | Chouser | jna is fantastic. |
| 13:00 | Lau_of_DK | Good evening gents |
| 13:01 | technomancy | hi Lau_of_DK |
| 13:01 | technomancy | hey, were you interested in a toggle-between-test and implementation function for Emacs? |
| 13:02 | Lau_of_DK | Can you define that for me please? :) |
| 13:02 | technomancy | there's one in clojure-test-mode now: http://github.com/technomancy/clojure-mode/tree/master |
| 13:02 | technomancy | C-c t |
| 13:03 | technomancy | you have to follow the layout convention listed in the header though |
| 13:03 | Lau_of_DK | I have no ide what youre talking about :) |
| 13:03 | Lau_of_DK | +a |
| 13:03 | technomancy | oh. right. must have been someone else. =) |
| 13:04 | technomancy | I thought you meant "can you define that function for me", like using defun. =) |
| 13:04 | Lau_of_DK | Sorry, no |
| 13:04 | Lau_of_DK | I was asking around though, to hear if anybody had done anything JBossy with Clojure...? |
| 13:07 | cgray | is there an equivalent function to scheme's `append' in clojure? |
| 13:08 | Chouser | ,(conj [1 2 3] 4) |
| 13:08 | clojurebot | [1 2 3 4] |
| 13:08 | Chouser | like that? |
| 13:08 | dnolen | conj- if you're using a vector |
| 13:08 | cgray | ok, thanks :) |
| 13:08 | chessguy | ,(conj '(1 2 3) 4) |
| 13:08 | clojurebot | (4 1 2 3) |
| 13:08 | chessguy | oh right |
| 13:09 | cgray | actually, I meant (append '(1 2 3) '(4 5 6)) -> (1 2 3 4 5 6) |
| 13:10 | Chouser | ,(concat '(1 2 3) '(4 5 6)) |
| 13:10 | clojurebot | (1 2 3 4 5 6) |
| 13:10 | Chouser | but concat is lazy, so you're getting a lazy seq there, not a PersistentList |
| 13:10 | chessguy | ,(concat '(1 2 3) 4) |
| 13:10 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer |
| 13:10 | dnolen | ,(type (into [1 2 3] [4 5 6])) |
| 13:10 | chessguy | ,(concat '(1 2 3) (seq 4)) |
| 13:10 | clojurebot | clojure.lang.PersistentVector |
| 13:10 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer |
| 13:11 | dnolen | ,(into [1 2 3] [4 5 6]) |
| 13:11 | clojurebot | [1 2 3 4 5 6] |
| 13:11 | chessguy | ,(concat '(1 2 3) (into 4)) |
| 13:11 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$into |
| 13:11 | chessguy | ,(concat '(1 2 3) (into empty 4)) |
| 13:11 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer |
| 13:13 | chessguy | ,(not (seq 4)) |
| 13:13 | clojurebot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer |
| 13:15 | Chouser | what are you trying to do? |
| 13:15 | Chouser | (concat '(1 2 3) [4]) |
| 13:15 | chessguy | nothing in particular |
| 13:15 | Chouser | ,(concat '(1 2 3) [4]) |
| 13:15 | clojurebot | (1 2 3 4) |
| 13:15 | Chouser | (seq? 4) |
| 13:15 | Chouser | ,(coll? 4) |
| 13:15 | clojurebot | false |
| 13:15 | Chouser | ,(seq? 4) |
| 13:15 | clojurebot | false |
| 13:15 | chessguy | just poking at the edges of my (very limited) knowledge of clojure |
| 13:15 | Chouser | ok |
| 13:15 | Chouser | you can probably get your own repl if you want one... |
| 13:15 | chessguy | oh i have one |
| 13:16 | chessguy | at home |
| 13:16 | Chouser | ah |
| 13:16 | chessguy_work | :) |
| 13:17 | chessguy_work | feel free to yell if i'm making too much noise in here. i've found in #haskell that playing with code snippets in the local bot is a great way to collaboratively learn and build community at the same time |
| 13:17 | chessguy_work | as long as it's not interfering with an ongoing discussion |
| 13:17 | dysinger | hiredman - I was doing it wrong :) I was packaging clojure jar without AOT |
| 13:18 | dysinger | once I fixed everything went back to working |
| 13:18 | chessguy_work | ,(concat '(1 2 3)) |
| 13:18 | clojurebot | (1 2 3) |
| 13:18 | chessguy_work | ,(not) |
| 13:18 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$not |
| 13:19 | chessguy_work | it would be cool if we put currying in place of that exception |
| 13:20 | chessguy_work | though potentially confusing |
| 13:20 | Chouser | yeah, and problematic in various other ways |
| 13:21 | Chouser | what if a fn take 1 or 3 args, but not 2? |
| 13:21 | Chouser | hm, that's not the most compelling. I've forgotten all the arguments against it. |
| 13:21 | Chouser | sorry |
| 13:24 | chessguy_work | oh, so it's been discussed? |
| 13:24 | cgray | are there any contrib libraries that pretty-print xml and that operate like clojure.xml? |
| 13:24 | Chouser | chessguy_work: indeed. |
| 13:25 | chessguy_work | ah |
| 13:25 | chessguy_work | yeah in haskell they just bit the bullet of ugly messages for the sake of having more concise code |
| 13:26 | Chouser | ,((partial not) false) |
| 13:26 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$partial |
| 13:26 | Chouser | hm |
| 13:27 | Chouser | ,((partial + 5) 10) |
| 13:27 | clojurebot | 15 |
| 13:28 | Chouser | ,(#(apply + %&) 5 10) |
| 13:28 | clojurebot | 15 |
| 13:29 | chessguy_work | ew |
| 13:30 | Chouser | does haskell support varargs? |
| 13:35 | Lau_of_DK | JBoss any1? :) |
| 13:36 | danlarkin | Chouser: isn't it the case that haskell makes you curry all your function args beyond the first one? or something? shows how much I remember from looking at it 2 years ago |
| 13:37 | Chouser | dunno. I got a haskell book from the library. Made it about page 5 before my 2 weeks were up, so I returned it. |
| 13:37 | Chouser | I'll try again later. :-) |
| 13:59 | cemerick | danlarkin: I think all fn application in haskell is partial, yes |
| 13:59 | cemerick | Chouser: just catching up on the logs --- could you use JNA to access your C API? |
| 14:01 | cemerick | Chouser: https://jna.dev.java.net/ -- certainly not as fast as JNI, but supposedly a lot more robust, insofar as segfaults aren't supposed to be possible (I think) |
| 14:03 | walters | cemerick: you can definitely cause segfaults |
| 14:04 | cemerick | maybe you have to work at it, then? The one time I've used JNA, I did something stupid that would have segfaulted if I were writing C, but the thing threw an exception instead. |
| 14:04 | walters | for example calling .getString() on a Pointer that isn't pointing at a zero-terminated UTF-8 buffer |
| 14:05 | walters | or just messing up a structure type definition |
| 14:18 | marklar | I've been trying to define a function that returns a closure with several different anonymous functions, something like (defn test1 [n] (let [x 10] (list (fn [] n) (fn [i] (+ i x))))). Is there a cleaner/better way to do this than using a list? |
| 14:19 | technomancy | marklar: you probably want to return a map rather than a list so each entry has a name |
| 14:19 | technomancy | other than that it's hard to say without knowing what you'd use it for |
| 14:19 | marklar | technomancy: thats a very good point, thanks :) |
| 14:20 | marklar | No plans to really use it for anything, just trying to learn |
| 14:41 | mek||malloc | Does anyone have a moment of time to check a snipet of code? I've quite new to clojure and I'm trying to write a function which performs directed graph traversal in a depth-first fassion (bounded by a max-depth) and which accumulates the resulting graph. I am having trouble with the last 6 lines: http://paste.lisp.org/display/79784 |
| 14:43 | mek||malloc | I guess my specific question would be, in this function, should I be performing (assoc graph this-node children) somewhere? |
| 14:48 | hiredman | that looks very complicated, my first suggestion would be to decompose it into shorter functions |
| 14:48 | mek||malloc | I'll see if I can do that. |
| 14:49 | mek||malloc | I think I just messed up on the last if -- I only perform one recursion and don't specify a recursion for the else case. |
| 14:49 | mek||malloc | I'm going to work on it for a bit -- sorry for asking such an ill-formed question. |
| 14:49 | mek||malloc | And thanks for taking a look, hiredman! |
| 14:49 | marklar | Can there be more than one recusion point? |
| 14:50 | hiredman | sure, just not using recur |
| 14:50 | marklar | yeah, I translated recusion to recur, thanks |
| 14:52 | hiredman | contains-item? looks an aweful lot like contains? |
| 14:52 | hiredman | (doc contains?) |
| 14:52 | clojurebot | Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'.; arglists ([coll key]) |
| 14:53 | hiredman | or even .contains |
| 14:53 | hiredman | ,(.contains '(1 2 3) 3) |
| 14:53 | clojurebot | true |
| 14:54 | mek||malloc | Ah, I'll replace that. Thanks hiredman -- as I said, I'm very new to clojure. |
| 14:54 | cemerick | mek||malloc: no worries. This channel is quite friendly, regardless of one's level of expertise. :-) |
| 15:10 | Chouser | you can have multiple recur's in a fn or loop. |
| 15:11 | hiredman | Chouser: but not like (fn [] (recur) (recur)) |
| 15:11 | hiredman | you might not get an error, but it almost certainly will not do what you want |
| 15:11 | Chouser | no |
| 15:11 | Chouser | right, in fact you do get an error |
| 15:11 | hiredman | good |
| 15:11 | Chouser | at compile-time, no less. |
| 15:12 | Chouser | ,(fn [] (recur) (recur)) |
| 15:12 | clojurebot | java.lang.UnsupportedOperationException: Can only recur from tail position |
| 15:12 | hiredman | becuause the first recur is not in the tail position |
| 15:12 | Chouser | ,(fn [x] (if x (recur) (recur)) |
| 15:12 | clojurebot | EOF while reading |
| 15:12 | Chouser | ,(fn [x] (if x (recur) (recur))) |
| 15:12 | clojurebot | java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 0 |
| 15:12 | Chouser | bah |
| 15:12 | Chouser | ,(fn [x] (if x (recur x) (recur x))) |
| 15:12 | clojurebot | #<sandbox$eval__4214$fn__4216 sandbox$eval__4214$fn__4216@ed15da> |
| 15:12 | hiredman | woa |
| 15:12 | hiredman | that is new |
| 15:12 | hiredman | expected: 1 args, got: 0 |
| 15:12 | hiredman | or maybe I just never noticed |
| 15:12 | Chouser | no, I think recur has always done that. |
| 15:13 | Chouser | it's regular fn calls that there's an Issue to catch at compile-time. |
| 15:16 | kotarak | Is it possible to do something like (let [klass String] (new klass))? |
| 15:17 | Chouser | ,(let [k String] (.newInstance k)) |
| 15:17 | clojurebot | "" |
| 15:20 | kotarak | Ah. Thanks. :) |
| 15:30 | mek||malloc | I think this should do it: http://paste.lisp.org/display/79784#1 . Can anyone suggest a way to break this down into sub functions so it's not so dense? |
| 15:31 | dnolen | mek||malloc are you using this to grab nodes on a web page? |
| 15:31 | dnolen | or just to get a feel for how Clojure works? |
| 15:31 | mek||malloc | Both, kind of ;o) |
| 15:32 | mek||malloc | I am constructing a directed graph (via a depth first traversal as to avoid stack problems)... The graph represents web pages and the relationship of links found within the pages. |
| 15:32 | mek||malloc | The successor function should just be the URLs found within a page. |
| 15:32 | mek||malloc | Ultimately I'd like to do some parallel pagerank testing. |
| 15:34 | mek||malloc | I've been using CL a little bit but the datastructures in clojure seem to rock the socks (and it would have been a pain to do link parsing in CL). I've been happy with my clojure experience thus far but I still don't know how to code correctly in clojure |
| 15:34 | mek||malloc | Which is frusterating. |
| 15:47 | Chouser | mek||malloc: the code you pasted doesn't make it past the compile step |
| 15:48 | mek||malloc | Poop. |
| 15:48 | mek||malloc | One moment. |
| 15:49 | Chouser | as for some general tips... if you find you're doing (first foo) and (next foo) for a lot of the same foo, you may want to use destructuring. |
| 15:49 | Chouser | (let [[this-node next-nodes] candidate-list] ...) |
| 15:50 | Chouser | rather: (let [[this-node & next-nodes] candidate-list] ...) |
| 15:50 | mek||malloc | But that would be bredth first. |
| 15:50 | mek||malloc | No? |
| 15:50 | mek||malloc | And then my stack would eat the big one. |
| 15:51 | Chouser | You don't have to change the structure of your code at all to use destructuring like that. |
| 15:51 | mek||malloc | That was the significance of using concat to push the successors to the beggining of the candidate-set. |
| 15:52 | Chouser | you're already do (first candidate-list) and (rest candidate-list). |
| 15:52 | Chouser | I'm just saying you can combine those into a single more succinct 'let'. |
| 15:53 | mek||malloc | Ah, I think I see what you mean. |
| 15:53 | Chouser | I'm not quite sure what you're doing yet with the blacklist, but it looks like it might work better as a set rather than a list. |
| 15:53 | mek||malloc | Well, the blacklist is just a closed-list. |
| 15:54 | kotarak | ,(let [[x & y]�[1 2 3 4]] (println x) (println y)) |
| 15:54 | clojurebot | java.lang.IllegalArgumentException: let requires an even number of forms in binding vector |
| 15:54 | mek||malloc | Ensuring that the same node isn't expanded multiple times (and thus ensuring that the graph stays directed) |
| 15:54 | kotarak | ?? |
| 15:54 | stuhood | yea... that's a set |
| 15:54 | mek||malloc | Same url, rather ... Not the same node. |
| 15:55 | Chouser | kotarak: you've got a weird non-space thing in there. |
| 15:55 | kotarak | huh? Ok? |
| 15:55 | Chouser | ,(let [[x & y] [1 2 3 4]] (println x) (println y)) |
| 15:55 | clojurebot | 1 (2 3 4) |
| 15:58 | mek||malloc | So i want to be using a set instead of a list? |
| 15:58 | Chouser | yeah. |
| 16:00 | Chouser | ,(let [a #{1 3 4 5 7}, b (conj a 8)] [(b 2) (b 3) (b 5) (b 6)]) |
| 16:00 | clojurebot | [nil 3 5 nil] |
| 16:00 | Chouser | then you won't need contains-item? |
| 16:00 | Chouser | and it'll run faster. |
| 16:04 | mek||malloc | So instead of (let [whitelist (filter-successors ...)]) you're suggesting (set (successors this-node)) ? |
| 16:05 | mek||malloc | I have not yet been exposed to sets in clojure so I am trying to read the documentation now. |
| 16:05 | Chouser | I just gave you an example. |
| 16:06 | mek||malloc | I suppose I'm trying to make sense of your example -- sorry. |
| 16:06 | Chouser | I'm not sure how you're using whitelist, but backlist appears to be being treated as a set. |
| 16:07 | Chouser | that is, you're mainly consing things onto it and then calling contains-item? |
| 16:07 | mek||malloc | Right. |
| 16:07 | Chouser | so make it be a set instead. Then you can conj onto and you get efficient look-ups for free. |
| 16:07 | mek||malloc | Whitelist is just the pruned (successor this-node) |
| 16:07 | mek||malloc | I see. |
| 16:08 | mek||malloc | Well, I suppose candidate-set, blacklist, and whitelist are all sets then. |
| 16:08 | mek||malloc | Thank you for the guidance. |
| 16:08 | Chouser | (let [my-set #{:node-1 :node-3}, item :node-3] (contains? my-set item)) |
| 16:08 | Chouser | ,(let [my-set #{:node-1 :node-3}, item :node-3] (contains? my-set item)) |
| 16:08 | clojurebot | true |
| 16:08 | Chouser | ,(let [my-set #{:node-1 :node-3}, item :node-3] (my-set item)) |
| 16:09 | clojurebot | :node-3 |
| 16:09 | Chouser | ,(let [my-set #{:node-1 :node-3}, item :node-4] (my-set item)) |
| 16:09 | clojurebot | nil |
| 16:15 | mek||malloc | Is there a straight forward way to make a set of a list? |
| 16:15 | mek||malloc | Or am I confused. |
| 16:15 | Chouser | ,(set '(5 4 2 1)) |
| 16:15 | clojurebot | #{1 2 4 5} |
| 16:15 | mek||malloc | Fair enough. |
| 16:15 | mek||malloc | Thank you kindly. |
| 16:16 | Chouser | sure |
| 16:18 | kotarak | ,(vec '(5 4 2 1)) ; mek||malloc |
| 16:18 | clojurebot | [5 4 2 1] |
| 16:18 | triddell | Compojure question: does the (decorate) macro for routes require "using" a new namespace? |
| 16:19 | mek||malloc | ,(first (set '(1 2 3))) |
| 16:19 | clojurebot | 1 |
| 16:19 | mek||malloc | Neat. |
| 16:26 | mek||malloc | ,(difference (set '("1" "3")) (set '("2" 1"))) |
| 16:26 | clojurebot | EOF while reading string |
| 16:26 | mek||malloc | Aw. |
| 16:26 | Chouser | you missed a " |
| 16:26 | mek||malloc | ,(difference (set '("1" "3")) (set '("2" "1"))) |
| 16:26 | clojurebot | java.lang.Exception: Unable to resolve symbol: difference in this context |
| 16:26 | mek||malloc | Yeah. |
| 16:27 | triddell | FYI: to answer my own question, the decorate macro is in compojure.control |
| 16:27 | mek||malloc | ,(difference (set '("1" "3")) (set '("2" "1"))) |
| 16:28 | clojurebot | java.lang.Exception: Unable to resolve symbol: difference in this context |
| 16:28 | mek||malloc | Shucks, oh well. |
| 16:28 | Chouser | ,(clojure.set/difference (set '("1" "3")) (set '("2" "1"))) |
| 16:28 | clojurebot | #{"3"} |
| 16:28 | mek||malloc | Oh, I see. |
| 16:28 | mek||malloc | :o) Thanks. |
| 16:28 | Chouser | ,(clojure.set/difference #{1 3} #{2 1}) |
| 16:28 | clojurebot | #{3} |
| 16:28 | Chouser | sure |
| 16:36 | mek||malloc | ,(conj '"item-c" (set '("item-a" "item-b"))) |
| 16:36 | clojurebot | java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection |
| 16:36 | mek||malloc | That's what I thought. |
| 16:36 | kotarak | ,(conj (set ["a" "b"]) "c") |
| 16:36 | clojurebot | #{"a" "b" "c"} |
| 16:36 | mek||malloc | Yeah. |
| 16:36 | mek||malloc | Oh, hmm. |
| 16:37 | mek||malloc | ,(conj (set '("item-a" "item-b")) "item-c") |
| 16:37 | clojurebot | #{"item-a" "item-b" "item-c"} |
| 16:37 | mek||malloc | :o) |
| 16:38 | kotarak | mek||malloc: just a note: in clojure ["foo" "bar"] is preferred over '("foo" "bar") |
| 16:44 | mek||malloc | kotarak: Noted. |
| 16:44 | mek||malloc | But that too seems to depend, no? |
| 16:45 | mek||malloc | For example, if you have a structure that requires rapid resizing. |
| 16:45 | Chouser | sure, it depends. but if you don't specifically need list-like behavior, the vector literal is preferred. |
| 16:45 | Chouser | vectors change size fine |
| 16:45 | mek||malloc | Hm. |
| 16:47 | mek||malloc | Forgive me for playing devil's advocate. I'm not trying to argue -- just trying to learn correctly :o) |
| 16:48 | mek||malloc | Chouser and kotarak: You both have been very helpful and I greatly appreciate your time. |
| 16:48 | maacl | Is there a way to list all methods of a Java object from Clojure? |
| 16:48 | Chouser | maacl: clojure.contrib.repl-utils/show |
| 16:49 | maacl | Chouser: thanks |
| 16:57 | danlei | oh, show is in contrib, too? very nice. |
| 17:02 | danlei | and javadoc too ... perfect |
| 17:03 | technomancy | ,(isa? "hi" String) |
| 17:03 | clojurebot | false |
| 17:03 | technomancy | what's the deal with that? |
| 17:03 | eevar_ | ,(doc isa?) |
| 17:03 | clojurebot | "([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy" |
| 17:04 | Chouser | ,(instance? String "hi") |
| 17:04 | technomancy | is that a primitive vs object problem? |
| 17:04 | clojurebot | true |
| 17:04 | Chouser | ,(instance? String Object) |
| 17:04 | clojurebot | false |
| 17:04 | Chouser | ,(isa? String Object) |
| 17:04 | clojurebot | true |
| 17:05 | stuhood | ,(isa? String String) |
| 17:05 | clojurebot | true |
| 17:05 | dnolen | ,(instance? String "hi") |
| 17:05 | clojurebot | true |
| 17:05 | technomancy | Chouser: weird. thanks. |
| 17:05 | stuhood | the symbol is like a java 'Class' object |
| 17:05 | dnolen | ,(isa? (type "hi") String) |
| 17:05 | clojurebot | true |
| 17:18 | hiredman | I hand this method call that would return an arraylist |
| 17:19 | hiredman | so I wrapped it in reaptedly: (repeatedly #(.method obj)) |
| 17:19 | hiredman | and did (take 10 ...) |
| 17:20 | hiredman | and it worked I got a seq of ten non-empty arraylists |
| 17:20 | hiredman | but (take-while identity ...) got me a list of 30 some empty array lists |
| 17:21 | hiredman | so I fought and fought with this |
| 17:21 | hiredman | and ended up with: |
| 17:21 | hiredman | (take-while #(> (count %) 0) (repeatedly #(vec (to-array (.read csv))))) |
| 17:22 | kotarak | Does (take-while (comp identity seq) (repeadetly #(.method obj))) work? |
| 17:23 | hiredman | I doubt it |
| 17:24 | hiredman | the final method I arrived at does filter based on the size of the resulting vector |
| 17:24 | hiredman | but, the method I am calling on the object returns an arraylist or null |
| 17:24 | hiredman | so I was trying to stop on null |
| 17:25 | clojurebot | we can't stop here! this is bat country! |
| 17:25 | hiredman | which it would do |
| 17:25 | hiredman | clojurebot: thanks |
| 17:25 | clojurebot | No entiendo |
| 17:25 | hiredman | but the result would be a bunch of empty arraylists |
| 17:25 | durka42 | ,(count nil) |
| 17:25 | clojurebot | 0 |
| 17:26 | hiredman | but if I changed the (take-while identity ...) to (take 10 ...) it would give me ten non-empty arraylists |
| 17:26 | durka42 | that's weird |
| 17:26 | hiredman | at one point I tried using doseq and just dumping everything into a lbq and then calling seq on the lbq |
| 17:26 | hiredman | and I started getting concurrent modification exceptions |
| 17:27 | durka42 | blech |
| 17:27 | hiredman | Yes. |
| 17:27 | hiredman | blech indeed |
| 17:29 | kotarak | I must confess, that I don't understand the problem exactly. (It's too late..) But for take-while above: |
| 17:29 | kotarak | ,(take-while seq (list (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)) (java.util.ArrayList.) (doto (hava.util.ArrayList.) (.add :x)))) |
| 17:29 | clojurebot | java.lang.ClassNotFoundException: hava.util.ArrayList |
| 17:29 | kotarak | ,(take-while seq (list (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)) (java.util.ArrayList.) (doto (java.util.ArrayList.) (.add :x)))) |
| 17:29 | clojurebot | (#<ArrayList [1, 2, 3]>) |
| 17:30 | hiredman | kotarak: I am using SuperCSV (java class) to read CSV files |
| 17:30 | hiredman | csv supplies a CSVListReader |
| 17:30 | hiredman | which has a read method |
| 17:30 | hiredman | read returns an ArrayList of fields or null |
| 17:31 | hiredman | so I used repeatedly #(.read csv) to build an infite seq of calls to read |
| 17:31 | kotarak | ,(take-while nil? (list :a :b nil :c)) |
| 17:31 | clojurebot | () |
| 17:31 | stuartsierra | You know you can iterate over an ArrayList just like an ordinary sequence, right? |
| 17:31 | hiredman | (take-while identity ...) would trim it off at the place where it starts to return nil |
| 17:31 | hiredman | I am well aware |
| 17:31 | stuartsierra | ok |
| 17:31 | kotarak | ,(take-while (complement nil?) (list :a :b nil :c)) |
| 17:31 | clojurebot | (:a :b) |
| 17:31 | hiredman | the problem is, when using take-while like that I would get a seq of empty arraylists |
| 17:32 | stuartsierra | Maybe you want mapcat? |
| 17:32 | hiredman | but using take and some number (take 10 ...) for example, would return a seq of non-empty arraylists |
| 17:33 | hiredman | so obviously CSVListReader is doing some mutatble hanky panky |
| 17:33 | stuhood | haha |
| 17:34 | hiredman | which is why I would get concurrent modification errors |
| 17:34 | hiredman | so, in sort, bad Java, bad! |
| 17:34 | stuhood | bad API designer, bad! |
| 17:35 | hiredman | that too |
| 17:35 | stuartsierra | some libraries reuse the same structure for efficiency, but it can cause unexpected errors |
| 17:35 | hiredman | yeah |
| 17:35 | kotarak | I'm not aware, which libraries are good or not, but I used OpenCSV for that without problems. |
| 17:35 | hiredman | I have the past as well |
| 17:35 | hiredman | which is why this was so frustrating |
| 17:36 | hiredman | because it worked on another machine with the other code where I used this exact same pattern |
| 17:37 | kotarak | I really start getting allergic against mutable state... |
| 17:37 | twism | quick question... what the clojurey way of turning [["a" "1"] ["b" "2"]] => [["a" "b"] ["1" "2"]] |
| 17:37 | hiredman | ,(into {} [["a" "1"] ["b" "2"]]) |
| 17:37 | clojurebot | {"b" "2", "a" "1"} |
| 17:37 | hiredman | ,(keys {"b" "2", "a" "1"}) |
| 17:37 | clojurebot | ("b" "a") |
| 17:37 | hiredman | ,(vals {"b" "2", "a" "1"}) |
| 17:37 | clojurebot | ("2" "1") |
| 17:38 | twism | cool thanks hriedman... where would i be without you |
| 17:38 | kotarak | ,(for [[[x y] [a b]] [["a" 1] ["b" 2]]] [[x a] [y b]]) |
| 17:38 | clojurebot | java.lang.UnsupportedOperationException: nth not supported on this type: Integer |
| 17:39 | hiredman | I imagine you could use reduce too |
| 17:40 | stuhood | there is a function with a name like 'alternate' that would do the right thing too |
| 17:40 | twism | ,find-doc alternate |
| 17:40 | clojurebot | #<core$find_doc__4566 clojure.core$find_doc__4566@e7d658> |
| 17:40 | stuhood | its a synonym =./ |
| 17:41 | twism | ,(find-doc alternate) |
| 17:41 | clojurebot | java.lang.Exception: Unable to resolve symbol: alternate in this context |
| 17:41 | stuhood | ,(doc interleave) |
| 17:41 | clojurebot | "([& colls]); Returns a lazy seq of the first item in each coll, then the second etc." |
| 17:41 | hiredman | ,(reduce (fn [a b] [(conj (first a) (first b)) (conj (second a)(second b))]) [[][]] [["a" "1"] ["b" "2"]]) |
| 17:41 | clojurebot | [["a" "b"] ["1" "2"]] |
| 17:42 | twism | hiredman: that seems a bit verbose |
| 17:42 | kotarak | ,(partition 2 (apply interleave ["a" "1"] ["b" "2"])) |
| 17:42 | clojurebot | (("a" \b)) |
| 17:42 | stuhood | kotarak: that's the ticket |
| 17:42 | kotarak | It's definitively too late... Time for bed.. |
| 17:43 | kotarak | ,(partition 2 (interleave ["a" "1"] ["b" "2"])) |
| 17:43 | clojurebot | (("a" "b") ("1" "2")) |
| 17:43 | hiredman | twism: but the verbosity exactly describes what you are doing |
| 17:43 | dnolen | does Java have built in number formatters? like for presenting prices? |
| 17:51 | cgrand | dnolen: here I am |
| 18:03 | twism | ,(partition 2 (apply interleave [["a" "1"] ["b" "2"] ["c" "3"])) |
| 18:03 | clojurebot | Unmatched delimiter: ) |
| 18:03 | twism | ,(partition 2 (apply interleave [["a" "1"] ["b" "2"] ["c" "3"]])) |
| 18:03 | clojurebot | (("a" "b") ("c" "1") ("2" "3")) |
| 18:04 | stuhood | the '2' needs to match the number of lists you expect |
| 18:06 | twism | ,(partition 3 (apply interleave [["a" "1"] ["b" "2"] ["c" "3"]])) |
| 18:06 | clojurebot | (("a" "b" "c") ("1" "2" "3")) |
| 18:06 | twism | hmm why did it not do that for me when i was in my own repl |
| 18:08 | stuhood | ,(let [struct [["a" "1"] ["b" "2"] ["c" "3"]]] (partition (count struct) (apply interleave struct)) |
| 18:08 | clojurebot | EOF while reading |
| 18:08 | stuhood | ,(let [struct [["a" "1"] ["b" "2"] ["c" "3"]]] (partition (count struct) (apply interleave struct))) |
| 18:08 | clojurebot | (("a" "b" "c") ("1" "2" "3")) |
| 18:09 | twism | oh nah it was the count |
| 18:09 | ciaran | ?> |
| 18:09 | twism | thanks stu |
| 18:09 | twism | stuhood* |
| 18:09 | twism | don't know if you are "the stu" |
| 18:10 | stuhood | haha... there are a ridiculous number of stus in the community |
| 18:23 | brentp | hi, i'm trying to use vimclojure, i get the syntax highlighting working, but when i try omnicompletion, i get error:Option 'omnifunc' is not set |
| 18:23 | brentp | any ideas on what i can try? |
| 18:29 | durka42 | what is that options... |
| 18:31 | durka42 | :set omnifunc? => omnifunc=vimclojure#OmniCompletion for me |
| 18:34 | mek||malloc | I've run into the situation where I have a java object that must be called frequently in my clojure script. Should I be def-ing an instance of the class or is there a more conventional approach? |
| 18:37 | stuhood | mek||malloc: it would probably be better to pass it around attached to some kind of context |
| 18:37 | mek||malloc | Ah. |
| 18:37 | stuhood | (= evil (+ :global :mutable)) |
| 18:37 | mek||malloc | Yes, agreed. |
| 18:37 | mek||malloc | I am trying to practice good functional style. |
| 18:38 | mek||malloc | I basically have an object which has a function getLinks (which parses a url and returns a list of urls found in it) |
| 18:38 | mek||malloc | Not quite sure how I would "pass it around" |
| 18:39 | stuhood | does the method really need to be a method? |
| 18:39 | stuhood | could it be a function instead? |
| 18:39 | stuhood | aka, does it use the 'this' keyword? |
| 18:40 | mek||malloc | Are you suggesting I have a clojure function which just makes a call to (new Obj (method args))? |
| 18:40 | stuhood | that's an option. |
| 18:40 | mek||malloc | I just feel like there would be a lot of overhead constructing a obj every time. |
| 18:41 | stuhood | but if the method doesn't really use the state of the object, you could just define a function that is a closure containing the object |
| 18:41 | mek||malloc | Fair enough. |
| 18:41 | mek||malloc | Thanks for the advice :o) |
| 19:10 | laheadle | hoooo boy is my java rusty! |
| 21:32 | eee | hi |
| 21:33 | benatkin | ,(bean :key) |
| 21:33 | clojurebot | {:namespace nil, :name "key", :class clojure.lang.Keyword} |
| 21:33 | benatkin | Why do keys have namespaces? Just curious/trying to understand. |
| 21:35 | laheadle | is this a good place to ask for help loading a java library into my clojure box on windows? |
| 21:36 | benatkin | laheadle: I don't see why not. |
| 21:36 | laheadle | ok here goes |
| 21:36 | laheadle | I've got slime-lisp-implementations set to include a directory with a tree that goes org/spearce/jgit/lib and then a bunch of .class files |
| 21:37 | laheadle | and then I do: |
| 21:37 | laheadle | user> (import '(org.spearce.jgit.lib Repository)) |
| 21:37 | laheadle | ; Evaluation aborted. |
| 21:38 | laheadle | java.lang.ClassNotFoundException: org.spearce.jgit.lib.Repository (NO_SOURCE_FILE:0 |
| 21:38 | hiredman | the directory the org folder is in should be on the classpath |
| 21:38 | hiredman | but not org/spearce/jgit/lib |
| 21:38 | laheadle | yes, I believe I have this right |
| 21:39 | hiredman | what does your (System/getProperty "java.class.path") say? |
| 21:39 | laheadle | It doesn't have the directory I added in it |
| 21:40 | hiredman | well |
| 21:40 | laheadle | I went through slime-lisp-implementations to pass it on the comand line |
| 21:40 | laheadle | you are right |
| 21:40 | hiredman | I dunno anything about emacs |
| 21:40 | laheadle | Can I just set a CLASSPATH env variable in my vista machine? |
| 21:40 | hiredman | depends |
| 21:41 | benatkin | laheadle: I'd search your .emacs file for anything resembling "classpath". |
| 21:41 | hiredman | the -cp option makes java ignore the classpath environment variable |
| 21:41 | laheadle | benatkin: yes, only I can't find the .emacs for "clojure box" |
| 21:41 | benatkin | you might have copied and pasted some code that has it in there, or referenced in a comment |
| 21:41 | hiredman | and I suspect slime uses the -cp option |
| 21:42 | laheadle | benatkin: I created a ~/.emacs.d/init.el and threw a little defun in there to change slime-lisp-implementations -- found the defun on somebody's blog |
| 21:42 | laheadle | is there an emacs variable for init file's location? |
| 21:43 | benatkin | I'm installing Clojure Box on my Windows VM right now. |
| 21:43 | laheadle | sweet |
| 21:43 | eee | i know how to do something imperatively . . . but not the clojure way |
| 21:44 | eee | would take me a sec to explain |
| 21:44 | eee | ... not to interrupt current conversation |
| 21:44 | benatkin | discussions on IRC are multithreaded |
| 21:44 | benatkin | :) |
| 21:44 | eee | to a degree |
| 21:45 | eee | i'm also thinking about trying on my own some more |
| 21:45 | benatkin | hmm, never thought of it that way...it is kinda like we're all in the same room |
| 21:46 | eee | but it has to do with taking a state as input . . .and returning up to 4 states as output |
| 21:46 | eee | butlot's of conditions determine which state |
| 21:46 | eee | s |
| 21:46 | eee | (plural) |
| 21:46 | eee | and |
| 21:46 | eee | it'd be nice to make it generic |
| 21:46 | eee | but what I'll do, is I'll hard code all the cases . . .then throw it out there |
| 21:47 | eee | (worked that out just now while typing :) |
| 21:50 | benatkin | laheadle: I might try adding it to c:/Program Files/Clojure Box/emacs/site-lisp/default.el |
| 21:51 | laheadle | ok |
| 21:51 | benatkin | laheadle: and putting it in the list on the fourth line from the bottom |
| 21:51 | eee | is there a function that takes a list or vector and swaps the element at position x with an element at position y? |
| 21:52 | eee | or hsould I figure it out |
| 21:52 | benatkin | after "clojure-contrib/clojure-contrib.jar" |
| 21:52 | eee | (think I just answered my question again) |
| 21:53 | benatkin | with an absolute path (e. g. "c:/path/to/directory/that/contains/org") |
| 21:54 | laheadle | user> (import '(org.spearce.jgit.lib Repository)) |
| 21:54 | laheadle | nil |
| 21:54 | laheadle | woot? |
| 21:54 | laheadle | me happy? |
| 21:55 | laheadle | I think I'm happy! |
| 21:55 | laheadle | now I get different kinds of errors! |
| 21:55 | laheadle | thanks benatkin |
| 21:56 | eee | ,(get (1 2 3) 2) |
| 21:56 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 21:56 | eee | ,(get '(1 2 3) 2) |
| 21:56 | clojurebot | nil |
| 21:56 | eee | ,(nth '(1 2 3) 2) |
| 21:56 | clojurebot | 3 |
| 21:57 | eee | ,(get '[1 2 3] 2) |
| 21:57 | clojurebot | 3 |
| 21:57 | eee | ,(nth '[1 2 3] 2) |
| 21:57 | clojurebot | 3 |
| 21:59 | benatkin | laheadle: You're welcome. I tried to get emacs working well with Clojure yesterday on OS X and have given up for at least a couple of days. |
| 22:01 | eee | is there something like chop or something that gets rid of the end of a list? |
| 22:01 | eee | like "give me up to position x" |
| 22:01 | clojurebot | x is y |
| 22:02 | durka42 | (doc take) |
| 22:02 | clojurebot | Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n.; arglists ([n coll]) |
| 22:02 | eee | ah yeah |
| 22:04 | eee | seems like it should like the n second |
| 22:05 | eee | the way get has the collection first |
| 22:05 | durka42 | i think it reads better the way it is |
| 22:05 | eee | or the way java is supported |
| 22:05 | eee | with the collection first |
| 22:05 | durka42 | ,(take 10 (repeatedly rand)) |
| 22:05 | clojurebot | (0.9861418493533219 0.5608679529019681 0.24952942970284786 0.27032434564480246 0.1833753869690512 0.5944293402154237 0.8878424495445804 0.5915650379730327 0.24255290949635444 0.9672878755036974) |
| 22:05 | eee | i get it |
| 22:05 | eee | but it seems like it should be the way nth is |
| 22:05 | eee | or get |
| 22:05 | eee | or java interrop |
| 22:06 | durka42 | i see your point |
| 22:06 | eee | hmmm |
| 22:09 | laheadle | wow clojure is fun |
| 22:10 | laheadle | got jgit working great |
| 22:10 | laheadle | (let [repo (new Repository (new File "../../Desktop/code/egit/.git"))] |
| 22:10 | laheadle | (. repo getFullBranch)) |
| 22:10 | laheadle | "refs/heads/master" |
| 22:10 | laheadle | TIME TO GIT BUSY! |
| 22:11 | durka42 | clojurebot: what time is it? |
| 22:11 | clojurebot | In Ordnung |
| 22:11 | durka42 | ~what time |
| 22:11 | clojurebot | what time is it? |
| 22:11 | durka42 | clojurebot: what time is <reply>TIME TO GIT BUSY! |
| 22:11 | clojurebot | You don't have to tell me twice. |
| 22:11 | durka42 | ~what time is it? |
| 22:11 | clojurebot | Alles klar |
| 22:11 | durka42 | i see |
| 22:12 | laheadle | ~what time is? |
| 22:12 | clojurebot | what time is it? |
| 22:12 | eee | i think I like take's style better. is it trying to indicate laziness? |
| 22:12 | durka42 | ~what time is it? is TIME TO GIT BUSY! |
| 22:12 | clojurebot | Ik begrijp |
| 22:13 | durka42 | quite possibly |
| 22:13 | hiredman | ~what time \is it? is TIME TO GIT BUSY! |
| 22:13 | clojurebot | Ik begrijp |
| 22:13 | hiredman | ~what time is it? |
| 22:13 | clojurebot | In Ordnung |
| 22:13 | durka42 | ~what time \is it? |
| 22:13 | clojurebot | what time is it? |
| 22:14 | laheadle | what do clojure source files end in? |
| 22:14 | hiredman | yeah well |
| 22:14 | durka42 | ~what time isn't it? |
| 22:14 | clojurebot | what time is it? |
| 22:14 | aosborne | laheadle: .clj |
| 22:14 | hiredman | clojurebot needs to be able to tell me the time in internet beats |
| 22:14 | laheadle | thanks |
| 22:21 | eee | ok now I need to take from the middle |
| 22:21 | eee | not the front |
| 22:21 | eee | based on two variable positions |
| 22:23 | eee | i guess drop |
| 22:23 | eee | (doc drop) |
| 22:23 | clojurebot | Returns a lazy sequence of all but the first n items in coll.; arglists ([n coll]) |
| 22:23 | eee | ah ha |
| 22:29 | p_l | Since quite a lot of people here use ViM, could someone direct me to a good all-in-one description of setting up ViM with completion for Java? (Unfortunately I can't use Clojure for this one project...) |
| 22:29 | clojurebot | for is not a loop |
| 22:35 | eee | does anyone here use clojure-dev? |
| 22:35 | clojurebot | clojure is cheating |
| 22:35 | eee | for eclispe? |
| 22:35 | eee | i can't get the up arrow to work, extremely frustrating to have to retype in the repl |
| 22:35 | eee | when i make a small error |
| 22:36 | eee | or want to tweak what I sent in |
| 22:36 | durka42 | isn't it alt-up or something? |
| 22:36 | eee | have found it on windows b4 |
| 22:36 | eee | but not on mac |
| 22:36 | eee | will try that |
| 22:37 | eee | nope |
| 22:45 | lisppaste8 | eee pasted "exchange function" at http://paste.lisp.org/display/79803 |
| 22:45 | eee | so here's my exchange function. is that silly? |
| 22:46 | eee | was a lot of work to just swap two elements |
| 22:47 | eee | fun but totally insane |
| 23:03 | durka42 | hiredman: too much work for too little gain: |
| 23:03 | durka42 | ,(let [tz (TimeZone/getTimeZone "CET") now (Calendar/getInstance tz) h (- (.get now Calendar/HOUR_OF_DAY) (if (.inDaylightTime tz (.getTime now)) 1 0)) m (.get now Calendar/MINUTE) s (.get now Calendar/SECOND)] (str "@" (Math/round (.floatValue (+ (* h 1000 1/24) (* m 1000 1/24 1/60) (* s 1000 1/24 1/3600)))))) |
| 23:03 | clojurebot | java.lang.Exception: No such namespace: TimeZone |
| 23:03 | durka42 | (import '[java.util Calendar]) |
| 23:03 | durka42 | ,(import '[java.util Calendar]) |
| 23:03 | clojurebot | nil |
| 23:04 | durka42 | ,(import '[java.util TimeZone]) |
| 23:04 | clojurebot | nil |
| 23:04 | durka42 | ,(let [tz (TimeZone/getTimeZone "CET") now (Calendar/getInstance tz) h (- (.get now Calendar/HOUR_OF_DAY) (if (.inDaylightTime tz (.getTime now)) 1 0)) m (.get now Calendar/MINUTE) s (.get now Calendar/SECOND)] (str "@" (Math/round (.floatValue (+ (* h 1000 1/24) (* m 1000 1/24 1/60) (* s 1000 1/24 1/3600)))))) |
| 23:04 | clojurebot | "@170" |
| 23:04 | durka42 | your clock is a little fast |
| 23:08 | chessguy | wow clojurebot allows arbitrary imports |
| 23:09 | eee | some new people joined so I'm gonna repaste |
| 23:09 | eee | eee pasted "exchange function" at http://paste.lisp.org/display/79803 22:43 eee so here's my exchange function. is that silly? 22:44 eee was a lot of work to just swap two elements 22:44 eee fun but totally insane |
| 23:10 | chessguy | eee: what is this, genetic algorithm? |
| 23:10 | eee | a state for a 15 puzle |
| 23:11 | eee | you know, 16 squares and one is missine a number |
| 23:11 | eee | and you slide them around |
| 23:11 | eee | writing a-star |
| 23:11 | eee | working on transition functino |
| 23:11 | eee | almost done |
| 23:11 | eee | except that I forgot again that conj works differently for different structures |
| 23:12 | chessguy | sure |
| 23:12 | chessguy | you mean add to front vs. add to back? |
| 23:12 | eee | is that a crazy way to exchange two positions? |
| 23:12 | eee | yeah |
| 23:12 | eee | so now if I switch to a list to fix one thing, I wonder if I break something somewhere else that is expecting a vector |
| 23:13 | chessguy | hmm, is it possible to do this all with a 16-element vector? |
| 23:13 | chessguy | might be better to have constant-time access |
| 23:14 | eee | how do you swap in an immutable system? |
| 23:14 | eee | i don't know how to do anything! :) |
| 23:14 | durka42 | eee: (assoc orig pos1 (orig pos2) pos2 (orig pos1)) |
| 23:14 | eee | wholey crap |
| 23:14 | durka42 | here orig is a vector |
| 23:14 | eee | so that wouldn't work with a list |
| 23:15 | eee | but I don't think it matters list or vec |
| 23:15 | chessguy | yeah |
| 23:15 | chessguy | i bet a vector will make your life much easeir |
| 23:15 | eee | i forget that a vector is a map |
| 23:15 | chessguy | and easier |
| 23:15 | eee | and you use assoc |
| 23:16 | eee | well, that's why I asked |
| 23:16 | clojurebot | why not? |
| 23:16 | chessguy | even if it weren't a map |
| 23:16 | eee | i did crazy stuff |
| 23:16 | eee | if it weren't a map assoc wouldn't work |
| 23:16 | chessguy | constant-time access has to be easier for a problem like this |
| 23:16 | eee | assoc used to be for maps back in my list class at least |
| 23:16 | chessguy | eee: no, but there would be some other easy way to do constant-time access |
| 23:16 | eee | i didn't know how to do contant time access |
| 23:17 | eee | well, I knew how to access |
| 23:17 | eee | get |
| 23:17 | eee | but |
| 23:17 | eee | not how to swap |
| 23:17 | chessguy | anyway |
| 23:17 | chessguy | this is how you learn :) |
| 23:17 | eee | i hope :) |
| 23:17 | eee | thanks |
| 23:17 | chessguy | it would have taken me an hour to put together what he just pasted anyway :) |
| 23:18 | eee | still looking at it myself |
| 23:19 | eee | you can assoc more than one thing at the same time? |
| 23:19 | eee | ('[1 2 3 4] 2) |
| 23:19 | eee | ,('[1 2 3 4] 2) |
| 23:19 | clojurebot | 3 |
| 23:19 | eee | why |
| 23:20 | eee | you don't even need to say get |
| 23:20 | eee | ,(get '[1 2 3 4] 2) |
| 23:20 | clojurebot | 3 |
| 23:20 | eee | grrrrr |
| 23:20 | eee | ,(assoc '[1 2 3 4] 2 'a) |
| 23:20 | clojurebot | [1 2 a 4] |
| 23:21 | eee | ,(assoc '[1 2 3 4] 2 'a 3 'b) |
| 23:21 | clojurebot | [1 2 a b] |
| 23:21 | eee | ,(assoc '[1 2 3 4] 2 'a 2 'b) |
| 23:21 | clojurebot | [1 2 b 4] |
| 23:21 | eee | wow |
| 23:21 | eee | durka42 are you a contributor? |
| 23:26 | eee | i had a question yesterday about (includes?) besides my question today about (take) |
| 23:27 | eee | and .... sort of a vote about (position) getting into core, since it's inverse (nth) is |
| 23:28 | durka42 | eee if i had more time :) |
| 23:29 | eee | well partially just an opionin question, but you're answering that you haven't enough time to be part of contributors. well, you certainly contribute a lot in here |
| 23:29 | eee | and thanks for that |
| 23:30 | durka42 | i suppose if i could channel the time i get distracted in here... :p |
| 23:31 | eee | you helped me fixed partition-by one time, and I think they added it |
| 23:31 | eee | due to us |
| 23:31 | eee | so you contribed there |
| 23:47 | hiredman | position would only work on ordered things and it would be linear time |
| 23:47 | durka42 | what would position do? |
| 23:48 | durka42 | indexOf? |
| 23:48 | eee | yeah |
| 23:48 | eee | nth only works on orthered things, too |
| 23:49 | durka42 | i mean, if they are already ordered it is log time |
| 23:49 | durka42 | or you are using a different definition of ordered |
| 23:49 | eee | good point |
| 23:49 | hiredman | ordered doesn't mean sorted |
| 23:50 | eee | he means a set |
| 23:50 | eee | without order |
| 23:50 | durka42 | right ok |
| 23:50 | eee | just has things floating around |
| 23:50 | eee | no position |
| 23:50 | eee | i agree |
| 23:50 | hiredman | maps |
| 23:50 | eee | but then can't ask nth either |
| 23:50 | eee | they are inverses |
| 23:50 | eee | consistency |
| 23:50 | durka42 | unless there are dupes |
| 23:51 | eee | well, yeah |
| 23:51 | eee | but |
| 23:51 | eee | how about |
| 23:51 | eee | (includes?) |
| 23:51 | eee | return the first position |
| 23:51 | eee | vice true |
| 23:51 | eee | it's in seq-utils |
| 23:51 | eee | there's find-first |
| 23:51 | eee | can't remember what that does |
| 23:52 | eee | oh that just returns an item |
| 23:52 | eee | based on predicate |
| 23:52 | eee | so you still don't know WHERE it was found |
| 23:52 | eee | but you helped me f minutes ago, where I clealy needed that |
| 23:52 | eee | clearly |
| 23:55 | durka42 | vectors appear to support indexOf |
| 23:55 | eee | yup |
| 23:55 | eee | so yesterday we debated on the merits or lack therof |
| 23:55 | eee | or wrapping it |
| 23:55 | eee | of |
| 23:55 | eee | i mean |
| 23:56 | eee | it seems so obvious ... i bet folks waste time searching for it, just like I did |