#clojure logs

2009-05-06

00:46lisppaste8dysinger pasted "clojure 1.1-SNAP on gentoo" at http://paste.lisp.org/display/79740
03:33RaynesIt's storming. :\
07:06cgrandwow it's very quiet this morning
07:06Carkhush !
07:06Cark=P
07:07RaynesWhat are the benefit's of using Git? (This ought to do it.)
07:28jdz_git is awesome
07:28jdz_but i'm repeating myself
07:29jdz_git bisect --help
07:39Carkanyone using compojure ?
07:40Carki can't seem to find a way to modify the session from a handler
07:41Carkahwell i guess i only had to ask here in order to find the solution
07:41Cark=P
08:19RaynesD'aw shit. TVS just tripped, moving in my direction. :\
08:29RaynesThere is a town near me named Arkadelphia. Neat.
08:44chessguy_workare clojure symbols case senssitive?
08:44Chouseryes
08:54chessguy_workok
08:54chessguy_workso i'm thinking of using anaphoric macros to build a chess pattern-recognizing system
08:54chessguy_worksometying along these lines: http://paste.lisp.org/display/79760
08:55chessguy_workpart of the idea is to separate the patterns from what to do with the matches
08:56chessguy_worksince i'm very new to macros, i'd love to know if i'm completely insane
09:02Chouseryou can't pass around macros like that
09:02Chouser*usually* trying to get at a macro as a function is not what you want, so you're prevented.
09:02jdz_macros are invoked before compiling code to transform the code
09:03Chouserin 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:04chessguy_workbut as a function, could it leave those variables defined the way i want it to?
09:07Chouser(defn kqk [& body] `(let [~'K "king" ~'Q "queen"] ~@body))
09:07Chouser(defmacro apply-pattern [pat & body] (apply (resolve pat) body))
09:07Chouser(apply-pattern kqk (println K Q))
09:07ChouserI'm not quite sure what you're trying to do, but something like that might work.
09:08Chousernote 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:08chessguy_workwhat is resolve?
09:09cgrayhi, i'm a bit confused by the .. macro. is it possible to turn (. foo (bar) (baz "quux")) into something more elegant using it?
09:11chessguy_workChouser, 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:12Chouserchessguy_work: because the macro is using that fn as a helper to produce a code form, which the macro will then return.
09:12chessguy_workohhhh
09:12chessguy_workbrilliant!
09:13ChouserI'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:13chessguy_workoh yes, many
09:15chessguy_workwhat's the down-side?
09:16Chouseryou 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:17chessguy_workyuck
09:18chessguy_workwhy does it need resolve?
09:22aosbornecgray: 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:22aosborne,(macroexpand '(.. foo (getA x) (getB y))
09:22clojurebotEOF while reading
09:22aosborne,(macroexpand '(.. foo (getA x) (getB y)))
09:22clojurebot(. (. foo (getA x)) (getB y))
09:23cgrayaosborne: I thought my code was equivalent to foo.bar().baz("quux")
09:23cgraymaybe I'm misunderstanding . as well :)
09:23chessguy_workChouser, i don't get this. why is resolve needed?
09:25aosbornehehe.. your example can't be written in java notation
09:26cgrayhmm, it works though
09:26aosbornereally? hmm.. maybe I'm misunderstanding the docs.. I hadn't tried using . like that before
09:30aosbornecgray: actually I think for your example it just drops the (baz "quux")
09:30cgrayaosborne: what do you mean?
09:31aosborne (. System/out (println) (str "quux"))
09:31aosborneprints nothing
09:31aosborneso I assuming it's just the same as: (. System/out (println))
09:31aosborne (. System/out println (str "quux")) works
09:32unlinkWhat's the easiest way of calling clojure from java without the boilerplate of interning Vars, etc.
09:32aosborne (. System/out (println (str "quux"))) <-- so does this
09:32aosbornejust not mixing the two forms
09:33cgraythe second one doesn't work for me
09:33cgrayin the form I'm using, (baz "quux") is called for a side-effect, and the side-effect is happening...
09:34aosborne (. System/out (println) (assert false)) <-- doesn't throw an exception for me
09:34aosborneI dunno then ;)
09:34cgrayyou're right
09:34aosborneoh wait
09:34aosborneassert is a macro
09:35cgraybut it's not quite the same thing... you're writing System.out.println().str("quux") if i understand correctly...
09:35aosborne (. System/out (println) (Th!s is invalid)) <-- no exception
09:36aosbornehmm
09:36Chousukehmmh
09:36Chousukeso . just ignores extra parameters? :/
09:37aosbornecgray: your example was this right: (. foo (bar) (baz "quux"))
09:37cgrayyep
09:37Chousukein that case (baz "quux") apparently gets silently ignored.
09:38cgrayoh crap, you might be right...
09:38aosborneyep, not even evaluated.. which is odd that you're seeing a side-effect happening
09:38cgraysorry, the side-effect didn't happen
09:38Chousukeif you want to do chaining, don't use . anyway. use -> or something
09:41cgraygood to know
09:41unlinkant
09:42aosborneunlink: depends how you want to call it: eval? run a script? use a class defined in Clojure code?
09:42ChousukeIt'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:43cgrayChousuke: so foo.bar().baz("quux") should be (-> foo (.bar) (.baz "quux")) ?
09:43unlinkaosborne: I just want to call a function in clojure code.
09:43unlink(.. foo bar (baz "quux")), no?
09:44Chousukecgray: yeah
09:44aosbornehttp://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Invoking_Clojure_from_Java
09:44Chousukeunlink: I don't like .. either. it doesn't allow mixing clojure functions and java methods
09:44Chousukecgray: though you can just say (-> foo .bar (.baz "quux"))
09:45cgrayChousuke: cool, thanks
09:46Chousukecgray: and as I said, you can mix in clojure functions as well
09:47Chousuke,(-> "foo" .toUpperCase (println "afterfoo"))
09:47clojurebotFOO afterfoo
09:54unlinkHow do you (set!) from java? e.g. *warn-on-reflection* or *command-line-args*
09:56RaynesTornado sirens are hurting my ears. :(
09:59cgrayRaynes: that usually means you should do something :)
09:59marklarcgray: usually? :)
10:00cgrandunlink: myvar.bindRoot(myObject)
10:03Raynescgray: 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:04RaynesTornadoes are isolated event's and only effect a small area, but the sirens go off for the entire county.
10:04RaynesAnnoying.
10:08unlinkthanks cgrand
10:09cgrayRaynes: out of curiosity, where are you? I used to live in Tulsa, and we'd get tornado sirens all the time...
10:16Raynescgray: Walker County in Alabama.
10:16RaynesExtreme Northwestern Walker County to be specific.
10:27HolcxjoWoot! Just got an email from pragmaticbookshelf.com -- in the "Coming up next" section I read: "Programming Clojure in print shortly"
11:06Chouserwell, I tried to deploy my little phone app to the first user. Failure.
11:06rhickeyChouser: :(
11:06Chouserthe jni piece is just too fragile
11:07Chouserthe 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:07Chouserbut 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:09Chouserwe 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:09Chouserof course with each of the attempts the tidy little command-line to launch it got more and more complicated...
11:09durka42can't you use regular sockets?
11:10durka42when i had to do serial ports i used a companion program that listened on a regular socket
11:10durka42still annoying
11:10Chouserdbus 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:10durka42oh, i see, you don't get to write the companion program :)
11:11rhickeyhttp://www.michaelnygard.com/blog/2009/05/kudos_to_relevance_and_clojure.html
11:11Chouserno, I'm talking to libpurple aka pidgin
11:11durka42you could still put some horrible hack of a C program in between you and dbus
11:12Chouseror 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:12durka42that too
11:13danlarkinright language for the right job
11:13Chouserbut I want Clojure to be the right language.
11:13danlarkin:) I do too, but sometimes it's not and we all have to accept that :'(
11:14durka42what does jruby do?
11:14durka42oh, they use jna
11:14Chouserpresumably just doesn't supply access to that part of its standard lib.
11:14Chouseroh, really? hm...
11:14Chouserhm...
11:17Chouserrhickey: nice writeup
11:17durka42http://stackoverflow.com/questions/170600/unix-socket-implementation-for-java
11:17Chouserdurka42: there's a debian/ubuntu package libunixsocket-java
11:18Chouserworks great locally, but deploying jni turns out to be hard.
11:19durka42i imagine
11:20rhickeyChouser: 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:20Chouserrhickey: exactly
11:20Chouserdurka42: 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:21Chouserbut apparently there are version incompatibilities or something.
11:21rsynnottdurka42: if it's just mysql access you want, you could potentially use UnixODBC
11:21rhickeyOne 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:21rsynnottpretty sure it supports using unix sockets
11:21stuhood~delicious
11:21clojurebotdelicious is http://delicious.com/clojurebot
11:23Chousersymbol macros??
11:25rsynnottwhere does clojurebot get material for its delicious?
11:25rsynnottjust every url posted here?
11:27Chouserwhoa. macrolet and symbol-macrolet implemented using code walkers, in clojure.contrib.macro-utils
11:28danleiinteresting
11:28twismhello clojure...
11:29twismquick question
11:30twismi have a function that takes a list and spits out the list as a string (serialize)...
11:30twism(my-func '(fn [x] x)) => "(fn [x] x)"
11:31stuhoodrsynnott: yea
11:31Chouser,(pr-str '(fn [x] x))
11:31clojurebot"(fn [x] x)"
11:31twismhow would i go about having the function just work with a form
11:31twismwithout the list suguar
11:32twismChouser: sweet
11:32Chouser(defmacro form-str [form] (pr-str form))
11:32Chouser(form-str (fn [x] x))
11:32twismChouser: thanks man
11:32Chousernp
11:35twismsweet: that works well with lambdas too!
11:35twismChouser:*
11:36ChouserI don't know what that means, but great! :-)
11:36twism(form-str #(test x)) => "(fn* [] (test x))"
11:37twismoh you mean me blowing you a kiss lol
11:38Chouserno, you answered my question. #() isn't really any more a lambda than (fn [])
11:38twismoh i meant the sugar for lambda
11:38Chouser#() is an Anonymous function literal.
11:39Chouserbut sure. I just wasn't sure what you meant by "lambda" there.
11:39danleilambda<->fn
11:39twismAnonymous function literal it is
11:40twismmy fault for the confusion
11:45konatoDoes 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:45konatoBut running my test outside emacs works
11:45marklarkonato: no, but I did get a similar arguement with =, doing a clean build fixed it
11:46marklars/arguement/error
11:46stuartsierrathe signature of test-is/report changed recently, may need a recompile
11:46konatoI did clear and rebuild
11:48konatoThank you, i'll check that everything is fresh
11:56konatoStill doesn't work, I'm at clojure-1.1.0-alpha-SNAPSHOT, anyone using emacs, slime with this version
12:27durka42aviread returns a height-by-width-by-3 array of values
12:28durka42sorry, wrong channel
12:46Chouserjna is fantastic.
13:00Lau_of_DKGood evening gents
13:01technomancyhi Lau_of_DK
13:01technomancyhey, were you interested in a toggle-between-test and implementation function for Emacs?
13:02Lau_of_DKCan you define that for me please? :)
13:02technomancythere's one in clojure-test-mode now: http://github.com/technomancy/clojure-mode/tree/master
13:02technomancyC-c t
13:03technomancyyou have to follow the layout convention listed in the header though
13:03Lau_of_DKI have no ide what youre talking about :)
13:03Lau_of_DK+a
13:03technomancyoh. right. must have been someone else. =)
13:04technomancyI thought you meant "can you define that function for me", like using defun. =)
13:04Lau_of_DKSorry, no
13:04Lau_of_DKI was asking around though, to hear if anybody had done anything JBossy with Clojure...?
13:07cgrayis there an equivalent function to scheme's `append' in clojure?
13:08Chouser,(conj [1 2 3] 4)
13:08clojurebot[1 2 3 4]
13:08Chouserlike that?
13:08dnolenconj- if you're using a vector
13:08cgrayok, thanks :)
13:08chessguy,(conj '(1 2 3) 4)
13:08clojurebot(4 1 2 3)
13:08chessguyoh right
13:09cgrayactually, I meant (append '(1 2 3) '(4 5 6)) -> (1 2 3 4 5 6)
13:10Chouser,(concat '(1 2 3) '(4 5 6))
13:10clojurebot(1 2 3 4 5 6)
13:10Chouserbut concat is lazy, so you're getting a lazy seq there, not a PersistentList
13:10chessguy,(concat '(1 2 3) 4)
13:10clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
13:10dnolen,(type (into [1 2 3] [4 5 6]))
13:10chessguy,(concat '(1 2 3) (seq 4))
13:10clojurebotclojure.lang.PersistentVector
13:10clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
13:11dnolen,(into [1 2 3] [4 5 6])
13:11clojurebot[1 2 3 4 5 6]
13:11chessguy,(concat '(1 2 3) (into 4))
13:11clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$into
13:11chessguy,(concat '(1 2 3) (into empty 4))
13:11clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
13:13chessguy,(not (seq 4))
13:13clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Integer
13:15Chouserwhat are you trying to do?
13:15Chouser(concat '(1 2 3) [4])
13:15chessguynothing in particular
13:15Chouser,(concat '(1 2 3) [4])
13:15clojurebot(1 2 3 4)
13:15Chouser(seq? 4)
13:15Chouser,(coll? 4)
13:15clojurebotfalse
13:15Chouser,(seq? 4)
13:15clojurebotfalse
13:15chessguyjust poking at the edges of my (very limited) knowledge of clojure
13:15Chouserok
13:15Chouseryou can probably get your own repl if you want one...
13:15chessguyoh i have one
13:16chessguyat home
13:16Chouserah
13:16chessguy_work:)
13:17chessguy_workfeel 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:17chessguy_workas long as it's not interfering with an ongoing discussion
13:17dysingerhiredman - I was doing it wrong :) I was packaging clojure jar without AOT
13:18dysingeronce I fixed everything went back to working
13:18chessguy_work,(concat '(1 2 3))
13:18clojurebot(1 2 3)
13:18chessguy_work,(not)
13:18clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$not
13:19chessguy_workit would be cool if we put currying in place of that exception
13:20chessguy_workthough potentially confusing
13:20Chouseryeah, and problematic in various other ways
13:21Chouserwhat if a fn take 1 or 3 args, but not 2?
13:21Chouserhm, that's not the most compelling. I've forgotten all the arguments against it.
13:21Chousersorry
13:24chessguy_workoh, so it's been discussed?
13:24cgrayare there any contrib libraries that pretty-print xml and that operate like clojure.xml?
13:24Chouserchessguy_work: indeed.
13:25chessguy_workah
13:25chessguy_workyeah in haskell they just bit the bullet of ugly messages for the sake of having more concise code
13:26Chouser,((partial not) false)
13:26clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$partial
13:26Chouserhm
13:27Chouser,((partial + 5) 10)
13:27clojurebot15
13:28Chouser,(#(apply + %&) 5 10)
13:28clojurebot15
13:29chessguy_workew
13:30Chouserdoes haskell support varargs?
13:35Lau_of_DKJBoss any1? :)
13:36danlarkinChouser: 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:37Chouserdunno. I got a haskell book from the library. Made it about page 5 before my 2 weeks were up, so I returned it.
13:37ChouserI'll try again later. :-)
13:59cemerickdanlarkin: I think all fn application in haskell is partial, yes
13:59cemerickChouser: just catching up on the logs --- could you use JNA to access your C API?
14:01cemerickChouser: 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:03walterscemerick: you can definitely cause segfaults
14:04cemerickmaybe 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:04waltersfor example calling .getString() on a Pointer that isn't pointing at a zero-terminated UTF-8 buffer
14:05waltersor just messing up a structure type definition
14:18marklarI'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:19technomancymarklar: you probably want to return a map rather than a list so each entry has a name
14:19technomancyother than that it's hard to say without knowing what you'd use it for
14:19marklartechnomancy: thats a very good point, thanks :)
14:20marklarNo plans to really use it for anything, just trying to learn
14:41mek||mallocDoes 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:43mek||mallocI guess my specific question would be, in this function, should I be performing (assoc graph this-node children) somewhere?
14:48hiredmanthat looks very complicated, my first suggestion would be to decompose it into shorter functions
14:48mek||mallocI'll see if I can do that.
14:49mek||mallocI 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:49mek||mallocI'm going to work on it for a bit -- sorry for asking such an ill-formed question.
14:49mek||mallocAnd thanks for taking a look, hiredman!
14:49marklarCan there be more than one recusion point?
14:50hiredmansure, just not using recur
14:50marklaryeah, I translated recusion to recur, thanks
14:52hiredmancontains-item? looks an aweful lot like contains?
14:52hiredman(doc contains?)
14:52clojurebotReturns 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:53hiredmanor even .contains
14:53hiredman,(.contains '(1 2 3) 3)
14:53clojurebottrue
14:54mek||mallocAh, I'll replace that. Thanks hiredman -- as I said, I'm very new to clojure.
14:54cemerickmek||malloc: no worries. This channel is quite friendly, regardless of one's level of expertise. :-)
15:10Chouseryou can have multiple recur's in a fn or loop.
15:11hiredmanChouser: but not like (fn [] (recur) (recur))
15:11hiredmanyou might not get an error, but it almost certainly will not do what you want
15:11Chouserno
15:11Chouserright, in fact you do get an error
15:11hiredmangood
15:11Chouserat compile-time, no less.
15:12Chouser,(fn [] (recur) (recur))
15:12clojurebotjava.lang.UnsupportedOperationException: Can only recur from tail position
15:12hiredmanbecuause the first recur is not in the tail position
15:12Chouser,(fn [x] (if x (recur) (recur))
15:12clojurebotEOF while reading
15:12Chouser,(fn [x] (if x (recur) (recur)))
15:12clojurebotjava.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 0
15:12Chouserbah
15:12Chouser,(fn [x] (if x (recur x) (recur x)))
15:12clojurebot#<sandbox$eval__4214$fn__4216 sandbox$eval__4214$fn__4216@ed15da>
15:12hiredmanwoa
15:12hiredmanthat is new
15:12hiredmanexpected: 1 args, got: 0
15:12hiredmanor maybe I just never noticed
15:12Chouserno, I think recur has always done that.
15:13Chouserit's regular fn calls that there's an Issue to catch at compile-time.
15:16kotarakIs it possible to do something like (let [klass String] (new klass))?
15:17Chouser,(let [k String] (.newInstance k))
15:17clojurebot""
15:20kotarakAh. Thanks. :)
15:30mek||mallocI 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:31dnolenmek||malloc are you using this to grab nodes on a web page?
15:31dnolenor just to get a feel for how Clojure works?
15:31mek||mallocBoth, kind of ;o)
15:32mek||mallocI 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:32mek||mallocThe successor function should just be the URLs found within a page.
15:32mek||mallocUltimately I'd like to do some parallel pagerank testing.
15:34mek||mallocI'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:34mek||mallocWhich is frusterating.
15:47Chousermek||malloc: the code you pasted doesn't make it past the compile step
15:48mek||mallocPoop.
15:48mek||mallocOne moment.
15:49Chouseras 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:49Chouser(let [[this-node next-nodes] candidate-list] ...)
15:50Chouserrather: (let [[this-node & next-nodes] candidate-list] ...)
15:50mek||mallocBut that would be bredth first.
15:50mek||mallocNo?
15:50mek||mallocAnd then my stack would eat the big one.
15:51ChouserYou don't have to change the structure of your code at all to use destructuring like that.
15:51mek||mallocThat was the significance of using concat to push the successors to the beggining of the candidate-set.
15:52Chouseryou're already do (first candidate-list) and (rest candidate-list).
15:52ChouserI'm just saying you can combine those into a single more succinct 'let'.
15:53mek||mallocAh, I think I see what you mean.
15:53ChouserI'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:53mek||mallocWell, the blacklist is just a closed-list.
15:54kotarak,(let [[x & y]�[1 2 3 4]] (println x) (println y))
15:54clojurebotjava.lang.IllegalArgumentException: let requires an even number of forms in binding vector
15:54mek||mallocEnsuring that the same node isn't expanded multiple times (and thus ensuring that the graph stays directed)
15:54kotarak??
15:54stuhoodyea... that's a set
15:54mek||mallocSame url, rather ... Not the same node.
15:55Chouserkotarak: you've got a weird non-space thing in there.
15:55kotarakhuh? Ok?
15:55Chouser,(let [[x & y] [1 2 3 4]] (println x) (println y))
15:55clojurebot1 (2 3 4)
15:58mek||mallocSo i want to be using a set instead of a list?
15:58Chouseryeah.
16:00Chouser,(let [a #{1 3 4 5 7}, b (conj a 8)] [(b 2) (b 3) (b 5) (b 6)])
16:00clojurebot[nil 3 5 nil]
16:00Chouserthen you won't need contains-item?
16:00Chouserand it'll run faster.
16:04mek||mallocSo instead of (let [whitelist (filter-successors ...)]) you're suggesting (set (successors this-node)) ?
16:05mek||mallocI have not yet been exposed to sets in clojure so I am trying to read the documentation now.
16:05ChouserI just gave you an example.
16:06mek||mallocI suppose I'm trying to make sense of your example -- sorry.
16:06ChouserI'm not sure how you're using whitelist, but backlist appears to be being treated as a set.
16:07Chouserthat is, you're mainly consing things onto it and then calling contains-item?
16:07mek||mallocRight.
16:07Chouserso make it be a set instead. Then you can conj onto and you get efficient look-ups for free.
16:07mek||mallocWhitelist is just the pruned (successor this-node)
16:07mek||mallocI see.
16:08mek||mallocWell, I suppose candidate-set, blacklist, and whitelist are all sets then.
16:08mek||mallocThank you for the guidance.
16:08Chouser(let [my-set #{:node-1 :node-3}, item :node-3] (contains? my-set item))
16:08Chouser,(let [my-set #{:node-1 :node-3}, item :node-3] (contains? my-set item))
16:08clojurebottrue
16:08Chouser,(let [my-set #{:node-1 :node-3}, item :node-3] (my-set item))
16:09clojurebot:node-3
16:09Chouser,(let [my-set #{:node-1 :node-3}, item :node-4] (my-set item))
16:09clojurebotnil
16:15mek||mallocIs there a straight forward way to make a set of a list?
16:15mek||mallocOr am I confused.
16:15Chouser,(set '(5 4 2 1))
16:15clojurebot#{1 2 4 5}
16:15mek||mallocFair enough.
16:15mek||mallocThank you kindly.
16:16Chousersure
16:18kotarak,(vec '(5 4 2 1)) ; mek||malloc
16:18clojurebot[5 4 2 1]
16:18triddellCompojure question: does the (decorate) macro for routes require "using" a new namespace?
16:19mek||malloc,(first (set '(1 2 3)))
16:19clojurebot1
16:19mek||mallocNeat.
16:26mek||malloc,(difference (set '("1" "3")) (set '("2" 1")))
16:26clojurebotEOF while reading string
16:26mek||mallocAw.
16:26Chouseryou missed a "
16:26mek||malloc,(difference (set '("1" "3")) (set '("2" "1")))
16:26clojurebotjava.lang.Exception: Unable to resolve symbol: difference in this context
16:26mek||mallocYeah.
16:27triddellFYI: to answer my own question, the decorate macro is in compojure.control
16:27mek||malloc,(difference (set '("1" "3")) (set '("2" "1")))
16:28clojurebotjava.lang.Exception: Unable to resolve symbol: difference in this context
16:28mek||mallocShucks, oh well.
16:28Chouser,(clojure.set/difference (set '("1" "3")) (set '("2" "1")))
16:28clojurebot#{"3"}
16:28mek||mallocOh, I see.
16:28mek||malloc:o) Thanks.
16:28Chouser,(clojure.set/difference #{1 3} #{2 1})
16:28clojurebot#{3}
16:28Chousersure
16:36mek||malloc,(conj '"item-c" (set '("item-a" "item-b")))
16:36clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection
16:36mek||mallocThat's what I thought.
16:36kotarak,(conj (set ["a" "b"]) "c")
16:36clojurebot#{"a" "b" "c"}
16:36mek||mallocYeah.
16:36mek||mallocOh, hmm.
16:37mek||malloc,(conj (set '("item-a" "item-b")) "item-c")
16:37clojurebot#{"item-a" "item-b" "item-c"}
16:37mek||malloc:o)
16:38kotarakmek||malloc: just a note: in clojure ["foo" "bar"] is preferred over '("foo" "bar")
16:44mek||mallockotarak: Noted.
16:44mek||mallocBut that too seems to depend, no?
16:45mek||mallocFor example, if you have a structure that requires rapid resizing.
16:45Chousersure, it depends. but if you don't specifically need list-like behavior, the vector literal is preferred.
16:45Chouservectors change size fine
16:45mek||mallocHm.
16:47mek||mallocForgive me for playing devil's advocate. I'm not trying to argue -- just trying to learn correctly :o)
16:48mek||mallocChouser and kotarak: You both have been very helpful and I greatly appreciate your time.
16:48maaclIs there a way to list all methods of a Java object from Clojure?
16:48Chousermaacl: clojure.contrib.repl-utils/show
16:49maaclChouser: thanks
16:57danleioh, show is in contrib, too? very nice.
17:02danleiand javadoc too ... perfect
17:03technomancy,(isa? "hi" String)
17:03clojurebotfalse
17:03technomancywhat's the deal with that?
17:03eevar_,(doc isa?)
17:03clojurebot"([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:04Chouser,(instance? String "hi")
17:04technomancyis that a primitive vs object problem?
17:04clojurebottrue
17:04Chouser,(instance? String Object)
17:04clojurebotfalse
17:04Chouser,(isa? String Object)
17:04clojurebottrue
17:05stuhood,(isa? String String)
17:05clojurebottrue
17:05dnolen,(instance? String "hi")
17:05clojurebottrue
17:05technomancyChouser: weird. thanks.
17:05stuhoodthe symbol is like a java 'Class' object
17:05dnolen,(isa? (type "hi") String)
17:05clojurebottrue
17:18hiredmanI hand this method call that would return an arraylist
17:19hiredmanso I wrapped it in reaptedly: (repeatedly #(.method obj))
17:19hiredmanand did (take 10 ...)
17:20hiredmanand it worked I got a seq of ten non-empty arraylists
17:20hiredmanbut (take-while identity ...) got me a list of 30 some empty array lists
17:21hiredmanso I fought and fought with this
17:21hiredmanand ended up with:
17:21hiredman(take-while #(> (count %) 0) (repeatedly #(vec (to-array (.read csv)))))
17:22kotarakDoes (take-while (comp identity seq) (repeadetly #(.method obj))) work?
17:23hiredmanI doubt it
17:24hiredmanthe final method I arrived at does filter based on the size of the resulting vector
17:24hiredmanbut, the method I am calling on the object returns an arraylist or null
17:24hiredmanso I was trying to stop on null
17:25clojurebotwe can't stop here! this is bat country!
17:25hiredmanwhich it would do
17:25hiredmanclojurebot: thanks
17:25clojurebotNo entiendo
17:25hiredmanbut the result would be a bunch of empty arraylists
17:25durka42,(count nil)
17:25clojurebot0
17:26hiredmanbut if I changed the (take-while identity ...) to (take 10 ...) it would give me ten non-empty arraylists
17:26durka42that's weird
17:26hiredmanat one point I tried using doseq and just dumping everything into a lbq and then calling seq on the lbq
17:26hiredmanand I started getting concurrent modification exceptions
17:27durka42blech
17:27hiredmanYes.
17:27hiredmanblech indeed
17:29kotarakI must confess, that I don't understand the problem exactly. (It's too late..) But for take-while above:
17:29kotarak,(take-while seq (list (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)) (java.util.ArrayList.) (doto (hava.util.ArrayList.) (.add :x))))
17:29clojurebotjava.lang.ClassNotFoundException: hava.util.ArrayList
17:29kotarak,(take-while seq (list (doto (java.util.ArrayList.) (.add 1) (.add 2) (.add 3)) (java.util.ArrayList.) (doto (java.util.ArrayList.) (.add :x))))
17:29clojurebot(#<ArrayList [1, 2, 3]>)
17:30hiredmankotarak: I am using SuperCSV (java class) to read CSV files
17:30hiredmancsv supplies a CSVListReader
17:30hiredmanwhich has a read method
17:30hiredmanread returns an ArrayList of fields or null
17:31hiredmanso I used repeatedly #(.read csv) to build an infite seq of calls to read
17:31kotarak,(take-while nil? (list :a :b nil :c))
17:31clojurebot()
17:31stuartsierraYou know you can iterate over an ArrayList just like an ordinary sequence, right?
17:31hiredman(take-while identity ...) would trim it off at the place where it starts to return nil
17:31hiredmanI am well aware
17:31stuartsierraok
17:31kotarak,(take-while (complement nil?) (list :a :b nil :c))
17:31clojurebot(:a :b)
17:31hiredmanthe problem is, when using take-while like that I would get a seq of empty arraylists
17:32stuartsierraMaybe you want mapcat?
17:32hiredmanbut using take and some number (take 10 ...) for example, would return a seq of non-empty arraylists
17:33hiredmanso obviously CSVListReader is doing some mutatble hanky panky
17:33stuhoodhaha
17:34hiredmanwhich is why I would get concurrent modification errors
17:34hiredmanso, in sort, bad Java, bad!
17:34stuhoodbad API designer, bad!
17:35hiredmanthat too
17:35stuartsierrasome libraries reuse the same structure for efficiency, but it can cause unexpected errors
17:35hiredmanyeah
17:35kotarakI'm not aware, which libraries are good or not, but I used OpenCSV for that without problems.
17:35hiredmanI have the past as well
17:35hiredmanwhich is why this was so frustrating
17:36hiredmanbecause it worked on another machine with the other code where I used this exact same pattern
17:37kotarakI really start getting allergic against mutable state...
17:37twismquick question... what the clojurey way of turning [["a" "1"] ["b" "2"]] => [["a" "b"] ["1" "2"]]
17:37hiredman,(into {} [["a" "1"] ["b" "2"]])
17:37clojurebot{"b" "2", "a" "1"}
17:37hiredman,(keys {"b" "2", "a" "1"})
17:37clojurebot("b" "a")
17:37hiredman,(vals {"b" "2", "a" "1"})
17:37clojurebot("2" "1")
17:38twismcool thanks hriedman... where would i be without you
17:38kotarak,(for [[[x y] [a b]] [["a" 1] ["b" 2]]] [[x a] [y b]])
17:38clojurebotjava.lang.UnsupportedOperationException: nth not supported on this type: Integer
17:39hiredmanI imagine you could use reduce too
17:40stuhoodthere is a function with a name like 'alternate' that would do the right thing too
17:40twism,find-doc alternate
17:40clojurebot#<core$find_doc__4566 clojure.core$find_doc__4566@e7d658>
17:40stuhoodits a synonym =./
17:41twism,(find-doc alternate)
17:41clojurebotjava.lang.Exception: Unable to resolve symbol: alternate in this context
17:41stuhood,(doc interleave)
17:41clojurebot"([& colls]); Returns a lazy seq of the first item in each coll, then the second etc."
17:41hiredman,(reduce (fn [a b] [(conj (first a) (first b)) (conj (second a)(second b))]) [[][]] [["a" "1"] ["b" "2"]])
17:41clojurebot[["a" "b"] ["1" "2"]]
17:42twismhiredman: that seems a bit verbose
17:42kotarak,(partition 2 (apply interleave ["a" "1"] ["b" "2"]))
17:42clojurebot(("a" \b))
17:42stuhoodkotarak: that's the ticket
17:42kotarakIt's definitively too late... Time for bed..
17:43kotarak,(partition 2 (interleave ["a" "1"] ["b" "2"]))
17:43clojurebot(("a" "b") ("1" "2"))
17:43hiredmantwism: but the verbosity exactly describes what you are doing
17:43dnolendoes Java have built in number formatters? like for presenting prices?
17:51cgranddnolen: here I am
18:03twism,(partition 2 (apply interleave [["a" "1"] ["b" "2"] ["c" "3"]))
18:03clojurebotUnmatched delimiter: )
18:03twism,(partition 2 (apply interleave [["a" "1"] ["b" "2"] ["c" "3"]]))
18:03clojurebot(("a" "b") ("c" "1") ("2" "3"))
18:04stuhoodthe '2' needs to match the number of lists you expect
18:06twism,(partition 3 (apply interleave [["a" "1"] ["b" "2"] ["c" "3"]]))
18:06clojurebot(("a" "b" "c") ("1" "2" "3"))
18:06twismhmm why did it not do that for me when i was in my own repl
18:08stuhood,(let [struct [["a" "1"] ["b" "2"] ["c" "3"]]] (partition (count struct) (apply interleave struct))
18:08clojurebotEOF while reading
18:08stuhood,(let [struct [["a" "1"] ["b" "2"] ["c" "3"]]] (partition (count struct) (apply interleave struct)))
18:08clojurebot(("a" "b" "c") ("1" "2" "3"))
18:09twismoh nah it was the count
18:09ciaran?>
18:09twismthanks stu
18:09twismstuhood*
18:09twismdon't know if you are "the stu"
18:10stuhoodhaha... there are a ridiculous number of stus in the community
18:23brentphi, 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:23brentpany ideas on what i can try?
18:29durka42what is that options...
18:31durka42:set omnifunc? => omnifunc=vimclojure#OmniCompletion for me
18:34mek||mallocI'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:37stuhoodmek||malloc: it would probably be better to pass it around attached to some kind of context
18:37mek||mallocAh.
18:37stuhood(= evil (+ :global :mutable))
18:37mek||mallocYes, agreed.
18:37mek||mallocI am trying to practice good functional style.
18:38mek||mallocI basically have an object which has a function getLinks (which parses a url and returns a list of urls found in it)
18:38mek||mallocNot quite sure how I would "pass it around"
18:39stuhooddoes the method really need to be a method?
18:39stuhoodcould it be a function instead?
18:39stuhoodaka, does it use the 'this' keyword?
18:40mek||mallocAre you suggesting I have a clojure function which just makes a call to (new Obj (method args))?
18:40stuhoodthat's an option.
18:40mek||mallocI just feel like there would be a lot of overhead constructing a obj every time.
18:41stuhoodbut 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:41mek||mallocFair enough.
18:41mek||mallocThanks for the advice :o)
19:10laheadlehoooo boy is my java rusty!
21:32eeehi
21:33benatkin,(bean :key)
21:33clojurebot{:namespace nil, :name "key", :class clojure.lang.Keyword}
21:33benatkinWhy do keys have namespaces? Just curious/trying to understand.
21:35laheadleis this a good place to ask for help loading a java library into my clojure box on windows?
21:36benatkinlaheadle: I don't see why not.
21:36laheadleok here goes
21:36laheadleI'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:37laheadleand then I do:
21:37laheadleuser> (import '(org.spearce.jgit.lib Repository))
21:37laheadle; Evaluation aborted.
21:38laheadlejava.lang.ClassNotFoundException: org.spearce.jgit.lib.Repository (NO_SOURCE_FILE:0
21:38hiredmanthe directory the org folder is in should be on the classpath
21:38hiredmanbut not org/spearce/jgit/lib
21:38laheadleyes, I believe I have this right
21:39hiredmanwhat does your (System/getProperty "java.class.path") say?
21:39laheadleIt doesn't have the directory I added in it
21:40hiredmanwell
21:40laheadleI went through slime-lisp-implementations to pass it on the comand line
21:40laheadleyou are right
21:40hiredmanI dunno anything about emacs
21:40laheadleCan I just set a CLASSPATH env variable in my vista machine?
21:40hiredmandepends
21:41benatkinlaheadle: I'd search your .emacs file for anything resembling "classpath".
21:41hiredmanthe -cp option makes java ignore the classpath environment variable
21:41laheadlebenatkin: yes, only I can't find the .emacs for "clojure box"
21:41benatkinyou might have copied and pasted some code that has it in there, or referenced in a comment
21:41hiredmanand I suspect slime uses the -cp option
21:42laheadlebenatkin: 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:42laheadleis there an emacs variable for init file's location?
21:43benatkinI'm installing Clojure Box on my Windows VM right now.
21:43laheadlesweet
21:43eeei know how to do something imperatively . . . but not the clojure way
21:44eeewould take me a sec to explain
21:44eee ... not to interrupt current conversation
21:44benatkindiscussions on IRC are multithreaded
21:44benatkin:)
21:44eeeto a degree
21:45eeei'm also thinking about trying on my own some more
21:45benatkinhmm, never thought of it that way...it is kinda like we're all in the same room
21:46eeebut it has to do with taking a state as input . . .and returning up to 4 states as output
21:46eeebutlot's of conditions determine which state
21:46eees
21:46eee(plural)
21:46eeeand
21:46eeeit'd be nice to make it generic
21:46eeebut what I'll do, is I'll hard code all the cases . . .then throw it out there
21:47eee(worked that out just now while typing :)
21:50benatkinlaheadle: I might try adding it to c:/Program Files/Clojure Box/emacs/site-lisp/default.el
21:51laheadleok
21:51benatkinlaheadle: and putting it in the list on the fourth line from the bottom
21:51eeeis there a function that takes a list or vector and swaps the element at position x with an element at position y?
21:52eeeor hsould I figure it out
21:52benatkinafter "clojure-contrib/clojure-contrib.jar"
21:52eee(think I just answered my question again)
21:53benatkinwith an absolute path (e. g. "c:/path/to/directory/that/contains/org")
21:54laheadleuser> (import '(org.spearce.jgit.lib Repository))
21:54laheadlenil
21:54laheadlewoot?
21:54laheadleme happy?
21:55laheadleI think I'm happy!
21:55laheadlenow I get different kinds of errors!
21:55laheadlethanks benatkin
21:56eee,(get (1 2 3) 2)
21:56clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
21:56eee,(get '(1 2 3) 2)
21:56clojurebotnil
21:56eee,(nth '(1 2 3) 2)
21:56clojurebot3
21:57eee,(get '[1 2 3] 2)
21:57clojurebot3
21:57eee,(nth '[1 2 3] 2)
21:57clojurebot3
21:59benatkinlaheadle: 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:01eeeis there something like chop or something that gets rid of the end of a list?
22:01eeelike "give me up to position x"
22:01clojurebotx is y
22:02durka42(doc take)
22:02clojurebotReturns a lazy sequence of the first n items in coll, or all items if there are fewer than n.; arglists ([n coll])
22:02eeeah yeah
22:04eeeseems like it should like the n second
22:05eeethe way get has the collection first
22:05durka42i think it reads better the way it is
22:05eeeor the way java is supported
22:05eeewith the collection first
22:05durka42,(take 10 (repeatedly rand))
22:05clojurebot(0.9861418493533219 0.5608679529019681 0.24952942970284786 0.27032434564480246 0.1833753869690512 0.5944293402154237 0.8878424495445804 0.5915650379730327 0.24255290949635444 0.9672878755036974)
22:05eeei get it
22:05eeebut it seems like it should be the way nth is
22:05eeeor get
22:05eeeor java interrop
22:06durka42i see your point
22:06eeehmmm
22:09laheadlewow clojure is fun
22:10laheadlegot jgit working great
22:10laheadle(let [repo (new Repository (new File "../../Desktop/code/egit/.git"))]
22:10laheadle (. repo getFullBranch))
22:10laheadle"refs/heads/master"
22:10laheadleTIME TO GIT BUSY!
22:11durka42clojurebot: what time is it?
22:11clojurebotIn Ordnung
22:11durka42~what time
22:11clojurebotwhat time is it?
22:11durka42clojurebot: what time is <reply>TIME TO GIT BUSY!
22:11clojurebotYou don't have to tell me twice.
22:11durka42~what time is it?
22:11clojurebotAlles klar
22:11durka42i see
22:12laheadle~what time is?
22:12clojurebotwhat time is it?
22:12eeei think I like take's style better. is it trying to indicate laziness?
22:12durka42~what time is it? is TIME TO GIT BUSY!
22:12clojurebotIk begrijp
22:13durka42quite possibly
22:13hiredman~what time \is it? is TIME TO GIT BUSY!
22:13clojurebotIk begrijp
22:13hiredman~what time is it?
22:13clojurebotIn Ordnung
22:13durka42~what time \is it?
22:13clojurebotwhat time is it?
22:14laheadlewhat do clojure source files end in?
22:14hiredmanyeah well
22:14durka42~what time isn't it?
22:14clojurebotwhat time is it?
22:14aosbornelaheadle: .clj
22:14hiredmanclojurebot needs to be able to tell me the time in internet beats
22:14laheadlethanks
22:21eeeok now I need to take from the middle
22:21eeenot the front
22:21eeebased on two variable positions
22:23eeei guess drop
22:23eee(doc drop)
22:23clojurebotReturns a lazy sequence of all but the first n items in coll.; arglists ([n coll])
22:23eeeah ha
22:29p_lSince 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:29clojurebotfor is not a loop
22:35eeedoes anyone here use clojure-dev?
22:35clojurebotclojure is cheating
22:35eeefor eclispe?
22:35eeei can't get the up arrow to work, extremely frustrating to have to retype in the repl
22:35eeewhen i make a small error
22:36eeeor want to tweak what I sent in
22:36durka42isn't it alt-up or something?
22:36eeehave found it on windows b4
22:36eeebut not on mac
22:36eeewill try that
22:37eeenope
22:45lisppaste8eee pasted "exchange function" at http://paste.lisp.org/display/79803
22:45eeeso here's my exchange function. is that silly?
22:46eeewas a lot of work to just swap two elements
22:47eeefun but totally insane
23:03durka42hiredman: too much work for too little gain:
23:03durka42,(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:03clojurebotjava.lang.Exception: No such namespace: TimeZone
23:03durka42(import '[java.util Calendar])
23:03durka42,(import '[java.util Calendar])
23:03clojurebotnil
23:04durka42,(import '[java.util TimeZone])
23:04clojurebotnil
23:04durka42,(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:04clojurebot"@170"
23:04durka42your clock is a little fast
23:08chessguywow clojurebot allows arbitrary imports
23:09eeesome new people joined so I'm gonna repaste
23:09eee 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:10chessguyeee: what is this, genetic algorithm?
23:10eeea state for a 15 puzle
23:11eeeyou know, 16 squares and one is missine a number
23:11eeeand you slide them around
23:11eeewriting a-star
23:11eeeworking on transition functino
23:11eeealmost done
23:11eeeexcept that I forgot again that conj works differently for different structures
23:12chessguysure
23:12chessguyyou mean add to front vs. add to back?
23:12eeeis that a crazy way to exchange two positions?
23:12eeeyeah
23:12eeeso 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:13chessguyhmm, is it possible to do this all with a 16-element vector?
23:13chessguymight be better to have constant-time access
23:14eeehow do you swap in an immutable system?
23:14eeei don't know how to do anything! :)
23:14durka42eee: (assoc orig pos1 (orig pos2) pos2 (orig pos1))
23:14eeewholey crap
23:14durka42here orig is a vector
23:14eeeso that wouldn't work with a list
23:15eeebut I don't think it matters list or vec
23:15chessguyyeah
23:15chessguyi bet a vector will make your life much easeir
23:15eeei forget that a vector is a map
23:15chessguyand easier
23:15eeeand you use assoc
23:16eeewell, that's why I asked
23:16clojurebotwhy not?
23:16chessguyeven if it weren't a map
23:16eeei did crazy stuff
23:16eeeif it weren't a map assoc wouldn't work
23:16chessguyconstant-time access has to be easier for a problem like this
23:16eeeassoc used to be for maps back in my list class at least
23:16chessguyeee: no, but there would be some other easy way to do constant-time access
23:16eeei didn't know how to do contant time access
23:17eeewell, I knew how to access
23:17eeeget
23:17eeebut
23:17eeenot how to swap
23:17chessguyanyway
23:17chessguythis is how you learn :)
23:17eeei hope :)
23:17eeethanks
23:17chessguyit would have taken me an hour to put together what he just pasted anyway :)
23:18eeestill looking at it myself
23:19eeeyou can assoc more than one thing at the same time?
23:19eee('[1 2 3 4] 2)
23:19eee,('[1 2 3 4] 2)
23:19clojurebot3
23:19eeewhy
23:20eeeyou don't even need to say get
23:20eee,(get '[1 2 3 4] 2)
23:20clojurebot3
23:20eeegrrrrr
23:20eee,(assoc '[1 2 3 4] 2 'a)
23:20clojurebot[1 2 a 4]
23:21eee,(assoc '[1 2 3 4] 2 'a 3 'b)
23:21clojurebot[1 2 a b]
23:21eee,(assoc '[1 2 3 4] 2 'a 2 'b)
23:21clojurebot[1 2 b 4]
23:21eeewow
23:21eeedurka42 are you a contributor?
23:26eeei had a question yesterday about (includes?) besides my question today about (take)
23:27eeeand .... sort of a vote about (position) getting into core, since it's inverse (nth) is
23:28durka42eee if i had more time :)
23:29eeewell 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:29eeeand thanks for that
23:30durka42i suppose if i could channel the time i get distracted in here... :p
23:31eeeyou helped me fixed partition-by one time, and I think they added it
23:31eeedue to us
23:31eeeso you contribed there
23:47hiredmanposition would only work on ordered things and it would be linear time
23:47durka42what would position do?
23:48durka42indexOf?
23:48eeeyeah
23:48eeenth only works on orthered things, too
23:49durka42i mean, if they are already ordered it is log time
23:49durka42or you are using a different definition of ordered
23:49eeegood point
23:49hiredmanordered doesn't mean sorted
23:50eeehe means a set
23:50eeewithout order
23:50durka42right ok
23:50eeejust has things floating around
23:50eeeno position
23:50eeei agree
23:50hiredmanmaps
23:50eeebut then can't ask nth either
23:50eeethey are inverses
23:50eeeconsistency
23:50durka42unless there are dupes
23:51eeewell, yeah
23:51eeebut
23:51eeehow about
23:51eee(includes?)
23:51eeereturn the first position
23:51eeevice true
23:51eeeit's in seq-utils
23:51eeethere's find-first
23:51eeecan't remember what that does
23:52eeeoh that just returns an item
23:52eeebased on predicate
23:52eeeso you still don't know WHERE it was found
23:52eeebut you helped me f minutes ago, where I clealy needed that
23:52eeeclearly
23:55durka42vectors appear to support indexOf
23:55eeeyup
23:55eeeso yesterday we debated on the merits or lack therof
23:55eeeor wrapping it
23:55eeeof
23:55eeei mean
23:56eeeit seems so obvious ... i bet folks waste time searching for it, just like I did