#clojure log - May 06 2009

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:46 lisppaste8: dysinger pasted "clojure 1.1-SNAP on gentoo" at http://paste.lisp.org/display/79740

3:33 Raynes: It's storming. :\

7:06 cgrand: wow it's very quiet this morning

7:06 Cark: hush !

7:06 =P

7:07 Raynes: What are the benefit's of using Git? (This ought to do it.)

7:28 jdz_: git is awesome

7:28 but i'm repeating myself

7:29 git bisect --help

7:39 Cark: anyone using compojure ?

7:40 i can't seem to find a way to modify the session from a handler

7:41 ahwell i guess i only had to ask here in order to find the solution

7:41 =P

8:19 Raynes: D'aw shit. TVS just tripped, moving in my direction. :\

8:29 There is a town near me named Arkadelphia. Neat.

8:44 chessguy_work: are clojure symbols case senssitive?

8:44 Chouser: yes

8:54 chessguy_work: ok

8:54 so i'm thinking of using anaphoric macros to build a chess pattern-recognizing system

8:54 sometying along these lines: http://paste.lisp.org/display/79760

8:55 part of the idea is to separate the patterns from what to do with the matches

8:56 since i'm very new to macros, i'd love to know if i'm completely insane

9:02 Chouser: you can't pass around macros like that

9:02 *usually* trying to get at a macro as a function is not what you want, so you're prevented.

9:02 jdz_: macros are invoked before compiling code to transform the code

9: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.

9:04 chessguy_work: but as a function, could it leave those variables defined the way i want it to?

9:04 * Raynes braces himself for the massive amount of wind that's about to slap his house.

9:07 Chouser: (defn kqk [& body] `(let [~'K "king" ~'Q "queen"] ~@body))

9:07 (defmacro apply-pattern [pat & body] (apply (resolve pat) body))

9:07 (apply-pattern kqk (println K Q))

9:07 I'm not quite sure what you're trying to do, but something like that might work.

9:08 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,.

9:08 chessguy_work: what is resolve?

9: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?

9: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?

9: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.

9:12 chessguy_work: ohhhh

9:12 brilliant!

9: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?

9:13 chessguy_work: oh yes, many

9:15 what's the down-side?

9: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.

9:17 chessguy_work: yuck

9:18 why does it need resolve?

9: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

9:22 ,(macroexpand '(.. foo (getA x) (getB y))

9:22 clojurebot: EOF while reading

9:22 aosborne: ,(macroexpand '(.. foo (getA x) (getB y)))

9:22 clojurebot: (. (. foo (getA x)) (getB y))

9:23 cgray: aosborne: I thought my code was equivalent to foo.bar().baz("quux")

9:23 maybe I'm misunderstanding . as well :)

9:23 chessguy_work: Chouser, i don't get this. why is resolve needed?

9:25 aosborne: hehe.. your example can't be written in java notation

9:26 cgray: hmm, it works though

9:26 aosborne: really? hmm.. maybe I'm misunderstanding the docs.. I hadn't tried using . like that before

9:30 cgray: actually I think for your example it just drops the (baz "quux")

9:30 cgray: aosborne: what do you mean?

9:31 aosborne: (. System/out (println) (str "quux"))

9:31 prints nothing

9:31 so I assuming it's just the same as: (. System/out (println))

9:31 (. System/out println (str "quux")) works

9:32 unlink: What's the easiest way of calling clojure from java without the boilerplate of interning Vars, etc.

9:32 aosborne: (. System/out (println (str "quux"))) <-- so does this

9:32 just not mixing the two forms

9:33 cgray: the second one doesn't work for me

9:33 in the form I'm using, (baz "quux") is called for a side-effect, and the side-effect is happening...

9:34 aosborne: (. System/out (println) (assert false)) <-- doesn't throw an exception for me

9:34 I dunno then ;)

9:34 cgray: you're right

9:34 aosborne: oh wait

9:34 assert is a macro

9:35 cgray: but it's not quite the same thing... you're writing System.out.println().str("quux") if i understand correctly...

9:35 aosborne: (. System/out (println) (Th!s is invalid)) <-- no exception

9:36 hmm

9:36 Chousuke: hmmh

9:36 so . just ignores extra parameters? :/

9:37 aosborne: cgray: your example was this right: (. foo (bar) (baz "quux"))

9:37 cgray: yep

9:37 Chousuke: in that case (baz "quux") apparently gets silently ignored.

9:38 cgray: oh crap, you might be right...

9:38 aosborne: yep, not even evaluated.. which is odd that you're seeing a side-effect happening

9:38 cgray: sorry, the side-effect didn't happen

9:38 Chousuke: if you want to do chaining, don't use . anyway. use -> or something

9:40 * Chousuke advocates not using . in pretty much all cases where it could be used

9:41 cgray: good to know

9:41 unlink: ant

9:42 aosborne: unlink: depends how you want to call it: eval? run a script? use a class defined in Clojure code?

9: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 ..)

9:43 cgray: Chousuke: so foo.bar().baz("quux") should be (-> foo (.bar) (.baz "quux")) ?

9:43 unlink: aosborne: I just want to call a function in clojure code.

9:43 (.. foo bar (baz "quux")), no?

9:44 Chousuke: cgray: yeah

9:44 aosborne: http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java

9:44 Chousuke: unlink: I don't like .. either. it doesn't allow mixing clojure functions and java methods

9:44 cgray: though you can just say (-> foo .bar (.baz "quux"))

9:45 cgray: Chousuke: cool, thanks

9:46 Chousuke: cgray: and as I said, you can mix in clojure functions as well

9:47 ,(-> "foo" .toUpperCase (println "afterfoo"))

9:47 clojurebot: FOO afterfoo

9:54 unlink: How do you (set!) from java? e.g. *warn-on-reflection* or *command-line-args*

9:56 Raynes: Tornado sirens are hurting my ears. :(

9:59 cgray: Raynes: that usually means you should do something :)

9: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 Tornadoes are isolated event's and only effect a small area, but the sirens go off for the entire county.

10:04 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 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 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 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 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 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 when i had to do serial ports i used a companion program that listened on a regular socket

11:10 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 oh, they use jna

11:14 Chouser: presumably just doesn't supply access to that part of its standard lib.

11:14 oh, really? hm...

11:14 hm...

11:17 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 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 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 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 * durka42 has to run

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 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 quick question

11:30 i have a function that takes a list and spits out the list as a string (serialize)...

11:30 (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 without the list suguar

11:32 Chouser: sweet

11:32 Chouser: (defmacro form-str [form] (pr-str form))

11:32 (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 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 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 but sure. I just wasn't sure what you meant by "lambda" there.

11:39 danlei: lambda<->fn

11:39 * danlei is too late

11:39 twism: Anonymous function literal it is

11:40 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 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 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 Thank you, i'll check that everything is fresh

11:56 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 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 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 C-c t

13:03 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 +a

13:03 technomancy: oh. right. must have been someone else. =)

13:04 I thought you meant "can you define that function for me", like using defun. =)

13:04 Lau_of_DK: Sorry, no

13:04 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 * chessguy apologizes to clojurebot

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 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 (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 ,(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 you can probably get your own repl if you want one...

13:15 chessguy: oh i have one

13:16 at home

13:16 Chouser: ah

13:16 chessguy_work: :)

13:17 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 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 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 though potentially confusing

13:20 Chouser: yeah, and problematic in various other ways

13:21 what if a fn take 1 or 3 args, but not 2?

13:21 hm, that's not the most compelling. I've forgotten all the arguments against it.

13:21 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 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 ,((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 I'll try again later. :-)

13:59 cemerick: danlarkin: I think all fn application in haskell is partial, yes

13:59 Chouser: just catching up on the logs --- could you use JNA to access your C API?

14:01 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 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 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 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 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 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 I'm going to work on it for a bit -- sorry for asking such an ill-formed question.

14:49 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 (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 ,(.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 you might not get an error, but it almost certainly will not do what you want

15:11 Chouser: no

15:11 right, in fact you do get an error

15:11 hiredman: good

15:11 Chouser: at compile-time, no less.

15:12 ,(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 ,(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 that is new

15:12 expected: 1 args, got: 0

15:12 or maybe I just never noticed

15:12 Chouser: no, I think recur has always done that.

15:13 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 or just to get a feel for how Clojure works?

15:31 mek||malloc: Both, kind of ;o)

15:32 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 The successor function should just be the URLs found within a page.

15:32 Ultimately I'd like to do some parallel pagerank testing.

15:34 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 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 One moment.

15:48 * mek||malloc magic ensues.

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 (let [[this-node next-nodes] candidate-list] ...)

15:50 rather: (let [[this-node & next-nodes] candidate-list] ...)

15:50 mek||malloc: But that would be bredth first.

15:50 No?

15:50 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 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 ,(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 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 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 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 I see.

16:08 Well, I suppose candidate-set, blacklist, and whitelist are all sets then.

16:08 Thank you for the guidance.

16:08 Chouser: (let [my-set #{:node-1 :node-3}, item :node-3] (contains? my-set item))

16:08 ,(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 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 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 ,(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 :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 Oh, hmm.

16:37 ,(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 But that too seems to depend, no?

16:45 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 vectors change size fine

16:45 mek||malloc: Hm.

16:47 Forgive me for playing devil's advocate. I'm not trying to argue -- just trying to learn correctly :o)

16:48 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.

16:59 * danlei should spend some more time figuring out what's already in contrib

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 punches java libraries with weird behavior

17:18 hiredman: I hand this method call that would return an arraylist

17:19 so I wrapped it in reaptedly: (repeatedly #(.method obj))

17:19 and did (take 10 ...)

17:20 and it worked I got a seq of ten non-empty arraylists

17:20 but (take-while identity ...) got me a list of 30 some empty array lists

17:21 so I fought and fought with this

17:21 and ended up with:

17:21 (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 the final method I arrived at does filter based on the size of the resulting vector

17:24 but, the method I am calling on the object returns an arraylist or null

17:24 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 clojurebot: thanks

17:25 clojurebot: No entiendo

17:25 hiredman: but the result would be a bunch of empty arraylists

17:25 * kotarak just realises that (comp identity seq) is the same as seq...

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 and I started getting concurrent modification exceptions

17:27 durka42: blech

17:27 hiredman: Yes.

17:27 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 ,(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 csv supplies a CSVListReader

17:30 which has a read method

17:30 read returns an ArrayList of fields or null

17:31 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 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 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 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 which is why this was so frustrating

17:36 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 ,(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 stuhood*

18:09 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 any ideas on what i can try?

18:29 durka42: what is that options...

18:31 :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 I am trying to practice good functional style.

18:38 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 Not quite sure how I would "pass it around"

18:39 stuhood: does the method really need to be a method?

18:39 could it be a function instead?

18:39 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 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 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 and then I do:

21:37 user> (import '(org.spearce.jgit.lib Repository))

21:37 ; Evaluation aborted.

21:38 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 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 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 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 would take me a sec to explain

21:44 ... not to interrupt current conversation

21:44 benatkin: discussions on IRC are multithreaded

21:44 :)

21:44 eee: to a degree

21:45 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 butlot's of conditions determine which state

21:46 s

21:46 (plural)

21:46 and

21:46 it'd be nice to make it generic

21:46 but what I'll do, is I'll hard code all the cases . . .then throw it out there

21:47 (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 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 nil

21:54 woot?

21:54 me happy?

21:55 I think I'm happy!

21:55 now I get different kinds of errors!

21:55 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 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 seems like it should like the n second

22:05 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 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 but it seems like it should be the way nth is

22:05 or get

22:05 or java interrop

22:06 durka42: i see your point

22:06 eee: hmmm

22:09 laheadle: wow clojure is fun

22:10 got jgit working great

22:10 (let [repo (new Repository (new File "../../Desktop/code/egit/.git"))]

22:10 (. repo getFullBranch))

22:10 "refs/heads/master"


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 not the front

22:21 based on two variable positions

22:23 i guess drop

22:23 (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 i can't get the up arrow to work, extremely frustrating to have to retype in the repl

22:35 when i make a small error

22:36 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 but not on mac

22:36 will try that

22:37 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 was a lot of work to just swap two elements

22:47 fun but totally insane

23:03 durka42: hiredman: too much work for too little gain:

23:03 ,(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 ,(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 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 you know, 16 squares and one is missine a number

23:11 and you slide them around

23:11 writing a-star

23:11 working on transition functino

23:11 almost done

23:11 except that I forgot again that conj works differently for different structures

23:12 chessguy: sure

23:12 you mean add to front vs. add to back?

23:12 eee: is that a crazy way to exchange two positions?

23:12 yeah

23:12 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 might be better to have constant-time access

23:14 eee: how do you swap in an immutable system?

23:14 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 but I don't think it matters list or vec

23:15 chessguy: yeah

23:15 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 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 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 well, I knew how to access

23:17 get

23:17 but

23:17 not how to swap

23:17 chessguy: anyway

23:17 this is how you learn :)

23:17 eee: i hope :)

23:17 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 you can assoc more than one thing at the same time?

23:19 ('[1 2 3 4] 2)

23:19 ,('[1 2 3 4] 2)

23:19 clojurebot: 3

23:19 eee: why

23:20 you don't even need to say get

23:20 ,(get '[1 2 3 4] 2)

23:20 clojurebot: 3

23:20 eee: grrrrr

23:20 ,(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 durka42 are you a contributor?

23:26 i had a question yesterday about (includes?) besides my question today about (take)

23:27 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 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 due to us

23:31 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 indexOf?

23:48 eee: yeah

23:48 nth only works on orthered things, too

23:49 durka42: i mean, if they are already ordered it is log time

23:49 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 without order

23:50 durka42: right ok

23:50 eee: just has things floating around

23:50 no position

23:50 i agree

23:50 hiredman: maps

23:50 eee: but then can't ask nth either

23:50 they are inverses

23:50 consistency

23:50 durka42: unless there are dupes

23:51 eee: well, yeah

23:51 but

23:51 how about

23:51 (includes?)

23:51 return the first position

23:51 vice true

23:51 it's in seq-utils

23:51 there's find-first

23:51 can't remember what that does

23:52 oh that just returns an item

23:52 based on predicate

23:52 so you still don't know WHERE it was found

23:52 but you helped me f minutes ago, where I clealy needed that

23:52 clearly

23:55 durka42: vectors appear to support indexOf

23:55 eee: yup

23:55 so yesterday we debated on the merits or lack therof

23:55 or wrapping it

23:55 of

23:55 i mean

23:56 it seems so obvious ... i bet folks waste time searching for it, just like I did

Logging service provided by n01se.net