#clojure logs

2010-01-24

00:24RaynesBecause Clojure isn't CL! :D
00:25quotemstrErr, but why the gratuitous incompatibility?
00:29Raynesquotemstr: I don't actually know. I just wanted to sound cool.
00:40hiredmanis it gratuitous?
00:40hiredmanclojure is not compatible in general with CL
00:42quotemstrI suppose I can just define a mac.h set of macros that make it look like CL. :-)
00:42quotemstrmac.h-style, that is.
00:43hiredmanclojurebot: what about the hyperspec?
00:43clojurebothyperspec is not applicable
03:28Hali_303hi! technically what is the difference between a struct and a seq? for example, how to get the keys of a struct? simply using "keys" is not working, as the struct cannot be converted to ISeq
03:29hiredmankeys of a struct?
03:30Hali_303hiredman: well if i do (defstruct person :name :age) then I'd like to create a struct that contains name and age
03:30hiredman(struct person 1 2)
03:30Hali_303so I know what properties are declared in the struct
03:31Hali_303ok I think i was not clear then. I'd not like to create an instance, but create a seq that contains "name" and "age"
03:32hiredmanI don't know of a way to get the names of the keys out of the definition of the struct
03:33hiredmanwhy do you want that?
03:33Hali_303so that I can list all stuff in the struct itself
03:33hiredmanuh
03:33Hali_303hm. maybe I should just use keys on a person_instance then
03:33hiredmanthe struct doesn't have stuff in it
03:34hiredmanor
03:34hiredmanthe definition of a struct does not have stuff in it
03:34hiredmanit is a pattern for creating structs that have stuff in them
03:35Hali_303hm. then I just don't get what's the purpose of having this in Clojure. this could be simple "emulated" by having a map of properties and then the function struct would just work by having this map and all values as arguments
03:36hiredmana struct is a map
03:36hiredmana struct is a map optimized for sharing some set of keys with a bunch of other maps
03:37Hali_303ok, but if I have a struct, and I'd like the user to type in all the fields, how do I know what fields to ask for?
03:39Hali_303or maybe struct is just there to make things faster when I'm having many maps with the same structure, but otherwise I should store such metadata elsewhere?
03:39hiredmanthat is rather nonsensical, a struct is a datastructure, what does it care about fields in a form?
03:40hiredmanstructs are not even tagged with the "type" of struct that they are
03:41Hali_303hm. that is new to me then. then how does the struct function know what keywords to associate the given values?
03:42hiredmanyou pass in the pattern, but the name of the pattern in not exposed in the resulting struct
03:42Hali_303I see
03:43hiredmanstructs are not an object system
03:43hiredmanthey are types
03:43hiredmanthey are just a kind of optimized map
03:44hiredmaner
03:44hiredmannuts
03:44hiredman"they are not types"
03:44Hali_303I see. so if I want to achieve the above functionality, then i should just have a list of "name", "age", etc. use that to create a struct definition, and then use the resulting struct to store instances, right?
03:44hiredmanresulting structs
03:44hiredmanwhy bother?
03:45Hali_303what do you mean?
03:45hiredmanif you want :name and :age, just pass [:name :age] into the function and get {:name "foo" :age 42} out
03:46hiredmanor even {:name nil :age nil} => {:name "foo" :age 42}
03:46Hali_303what I'm saying is that I don't know what to pass until runtime
03:46hiredmanI don't see how that change anything?
03:47hiredmanmaps, vectors, keywords all can be contructed and manipulated at runtime
03:48Hali_303yeah, probably I'm still living in compiled OO world :)
03:49Hali_303thank you for the insights anyways, I'll continue fiddling and see what's the result
03:50hiredmanoo is such a drag :/
04:51kibahello
04:53kibaI am new to clojure
08:37avarushi
10:54alexykso you guys still do nickserv identify upon each opening of a laptop lid?
10:55the-kennyalexyk: hm.. yes. Why are yoy asking?
10:56alexykthe-kenny: to see why isn't there a revolt or something :)
10:57alexykor perhaps programmers enjoy procedures, even annoying and repetitive ones
10:57the-kennyMy client does the identify-stuff for me.
10:58angermansame for me
11:12alexykchouser: did you see this? http://paste.pocoo.org/show/169141/
11:26alexykso I forgot again to add contrib to repl, and then spent 2 hours computing an evolved data structure there. How can I dynamically add contrib to the classpath from inside repl?
11:28qbgadd-classpath is there, but deprecated
11:30Chousukeyou could also print the data structure into a file and restart the repl :)
11:31qbgAnd make sure that contribs are always on the classpath
11:31Chousukethat is, if it is printable as such that you can read it back in without loss of information
11:31qbgAren't the Clojure data structures also Serializable?
11:32alexykChousuke: someone has shown before how to add to classpath dynamically... the structure is too big, I actually need partition-all from seq-utils to use my mongo0stuffing function
11:32alexykI guess I can just paste partition-all
11:33Chousuke(doc add-classpath)
11:33clojurebot"([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
11:37chouseralexyk: or load-file
11:38alexykchouser: you mean the file with seq-utils?
11:38chouseralexyk: yeah, I saw that. amazing. is DateTime from YodaTime? JediTime?
11:38chouseralexyk: yeah
11:38alexykchouser: DateTime is Joda Time
11:39alexykit's immutable too
11:39chouseryeah. sounds like good stuff
11:41alexykin fact, I did add contrib to classpath, but apparently it's a 1.1.0-master-SNAPSHOT not compatible with the same-named clojure... from 1/14. These two diverged annoyingly lately, hope they converge again with a clear naming!
11:42alexyksince lein repl failed me, I stopped doing lein deps regularly, although that still works
11:44joegg(subseq foo >= 4) --> "Get the subsequence of all keys whose position is >= the position where '4' would be, if it were a key." Is that a correct interpretation?
11:46chouserjoegg: I think your use of the word 'position' may lead you astray in some circumstances.
11:48chouserjoegg: hm... or perhaps not.
11:48joegg(subseq (sorted-set (comparator >) 1 10 100) >= 19)
11:48joegg,(subseq (sorted-set (comparator >) 1 10 100) >= 19)
11:48clojurebotjava.lang.ClassCastException: clojure.core$comparator__5224$fn__5226 cannot be cast to java.lang.Number
11:49chouser,(subseq (sorted-set-by > 2 4 6 8) >= 4)
11:49clojurebot(4 2)
11:49joeggOh, thanks.
11:49chouser,(subseq (sorted-set-by > 2 4 6 8) > 5)
11:49clojurebot(4 2)
11:49chouser,(subseq (sorted-set-by < 2 4 6 8) > 5)
11:49clojurebot(6 8)
11:50chouserso I think you're right. that's not quite what I expected. "position" does seem to be the right concept
11:50joeggYeah, when it is in increasing order, >= can be misinterpreted to mean "the key is greater than"
11:50chouserright
11:50joeggBut when it is in decreasing order, >= will actually mean "all the keys less than"
11:50joeggWhich threw me for quite a loop while trying to come up with a way of putting subseq into words.
11:51joeggBesides, "does the right thing when in increasing order, does the opposite of the right thing in decreasing order" :)
11:51chouserheh
11:52joeggWhy did I need to register my nick today? Did something happen in this channel recently that lead to a change?
11:53chouserI always register so hadn't notice, but apparently freenode is in a mighty battle against spam
11:53alexykjoegg: spam attack apparently
11:54joeggAh, okay.
11:55joeggIn addition to be a new clojurians and a new lisper, I'm also new to irc, so I didn't understand what was being asked of me for a little while. I figured it out, though. :)
11:55joeggApparently, based on that last sentence, I'm also new to the rules of english grammar. Sigh.
11:56chouserjoegg: heh. well, glad you figured out the irc anyway. welcome. :-)
11:59joeggThanks!
12:13bobo_any good tutorial on clojure with some nosql storage?
12:15avarusbobo_: http://github.com/ragnard/redis-clojure
12:22bobo_avarus: thank you, will try it ouy
12:43Scriptorhi everyone
12:44ScriptorI've been thinking of trying clojure, but kinda intimidated by maybe having to learn another editor all over again
12:44Scriptorhow important is having emacs when you want to develop in clojure?
12:45clojurebotwith style and grace
12:47somejanYou at least need something that checks parens (including [ and ] )
12:47Scriptordoes that just mean highlighting matching parens?
12:48somejanwell, some way to find out if you've mismatched parens, and to find out /which/ paren is wrong
12:49Scriptorah
12:49somejanThe indenting based on paren structure emacs does is also nice, but I guess you could use whatever indenting support your editor has
12:50somejanAnd you'll probably have to do without syntax highlighting, at least I don't think many editors support clojure syntax highlighting
12:50somejanbut it's up to you if you find that a problem
12:51somejanthere are plugins for Eclipse and IDEA, but I haven't tried them
12:52ScriptorI've tried installing the one for vim, but without much luck
12:52Scriptormight try again ow
12:52Scriptor*now
13:03somejanDoes anyone know if it's possible to reload a modified java class from within the clojure REPL? Or does the jvm not support that?
13:11chouserScriptor: there's no need to learn emacs. if you like IDEs, I'd recommend NetBeans
13:12chousersomejan: a stock jvm doesn't really support that. Clojure goes to some lengths to allow you to redefine things without actually trying to load a new version of a named class.
13:14Scriptorchouser: thanks, I prefer vim though, is vimclojure the only option for that?
13:23kotarakvc is not enough?
13:24avaruschouser: I have tried enclojure yesterday with the latest stable netbeans and it fails with nullpointerexception...are you running it with 6.8?
13:24avarusit installs fine but after I create a new project -> nullpointer exception
13:33chouseravarus: no, I don't particularly like IDEs in general, so haven't gotten very far with enclojure.
13:33avarussame here :(
13:34avarusI started with clojure yesterday and I thought I'd give enclojure a try
13:34avarusis there any editor that has some highlighting for clojure?:)
13:34chouserI mostly use vim with just syntax coloring and indentation support, without the interactive stuff.
13:35avarusk
13:35Scriptorchouser: where did you get the syntax coloring?
13:38chouserScriptor: vimclojure includes that
13:41avarusI watched a video from peepcode yesteday (and I hate the example project), but they used textmate that seemed to support the syntax
14:04grammati,(doc deftype)
14:04clojurebot"clojure.contrib.types/deftype;[[type-tag constructor-name docstring? attr-map?] [type-tag constructor-name docstring? attr-map? constructor] [type-tag constructor-name docstring? attr-map? constructor deconstructor]]; Define a data type by a type tag (a namespace-qualified keyword) and a symbol naming the constructor function. Optionally, a constructor and a deconstructor function can be given as well, the defaults being
14:05joshua-choiI've got a question on Clojure's reader's treatment of the slash symbol: is '/ hardcoded on the reader level to always be 'clojure.core//?
14:06chousernope
14:07Chousukehmm
14:07Chousukethe symbol / is special-cased though.
14:07joshua-choiYeah, that's what I thought
14:08joshua-choiI can't figure out a way to redefine '/ in any namespace other than clojure.core
14:08chouser,(binding [*ns* (the-ns 'foo)] (read-string "`/"))
14:08clojurebotjava.lang.Exception: No namespace: foo found
14:08chouser,(binding [*ns* (in-ns 'foo)] (read-string "`/"))
14:08clojurebot(quote foo//)
14:08Chousuke,foo//
14:08clojurebotInvalid token: foo//
14:08Chousuke,clojure.core//
14:08clojurebot#<core$_SLASH___4534 clojure.core$_SLASH___4534@77cddd>
14:08kotarakI would think messing with / is a bad idea.
14:09joshua-choiI'm writing a Clojure parser in Clojure, so I need to know how this works
14:09Chousukeso yeah, clojure.core// is a special case
14:09kotarakThen looking at the special casing in the reader would be of intereset.
14:10joshua-choiYeah, I'm having trouble with reading LispReader.java—I'm actually not very good at reading regular expressions and Java code...:(
14:10joshua-choiIn any case, I did find a special case for / in LispReader.java
14:10joshua-choiBut Chouser's example seems to show that it's redefinable into other namespaces
14:11ChousukeI would say that's a bug
14:11joshua-choiHmm
14:11Chousuke,'foo// ;does not work
14:11clojurebotInvalid token: foo//
14:11joshua-choiWell, there are two issues
14:11Chousukehowever
14:11joshua-choiOne is the bare slash symbol: /
14:12Chousuke,`/
14:12clojurebotclojure.core//
14:12joshua-choiThe other is the qualified slash symbol: a//
14:12Chousukethat works in the foo namespace and produces foo//, but only because the symbol / is read first and ` then expands it programmatically
14:12kotarak,`a//
14:12clojurebotInvalid token: a//
14:12joshua-choiI also couldn't find a way to qualify the slash symbol with any namespace other than clojure.core; that might be hardcoded too
14:12joshua-choiHmm
14:12Chousukethere are no checks in place ensuring consistency of symbols
14:13Chousuke,(symbol "foo bar")
14:13clojurebotfoo bar
14:13joshua-choiYeah, the symbol function is weird
14:13joshua-choi,(symbol "a/b" "c")
14:13clojurebota/b/c
14:13joshua-choi,(symbol "a" "b/c")
14:13clojurebota/b/c
14:13Chousukeit trusts you not to create invalid symbols with it
14:13joshua-choiYeah
14:14joshua-choiThe thing is: what are the official rules when it comes to the slash symbols?
14:14Chousukebut you could use it in a macro to create code that would be unreadable.
14:14joshua-choiclojure.org/reader just says that "/ means the division operator."
14:14Chousukeyeah, and that would be clojure.core//
14:14joshua-choiYeah
14:14Chousukeso I guess you'll have to assume / is reserved
14:14joshua-choiBut does that mean that / cannot be defined in any other namespace too?
14:14joshua-choiOkay
14:15joshua-choiWhat about the qualified clojure.core//?
14:15joshua-choi,'a//
14:15clojurebotInvalid token: a//
14:15joshua-choiIs that hardcoded too?
14:15Chousukethat's hard-coded too.
14:15joshua-choiOkay, good
14:15joshua-choiThen I know what to do know; thanks for the help
14:15joshua-chois/know/now ugh
14:24kotarakDoes anyone here have contact to Alex Osborne?
14:25RaynesNope, can't hear me. Sorry. :|
14:28kotarakRaynes: maybe Australia is too far. ;)
14:29Rayneskotarak: It's... It's just too far. :(
14:46LauJensenJust pulled the latest clojure/contrib from github, ant compiled them, then I pulled swank, lein compiled and not Swank cant started because swank.swank/start-server and /ignore-protocol-version aren't defined - How do I get around this?
14:47dnolenLauJensen: are you using lein from source?
14:48LauJensenNot following
14:48dnolenlike are you line from source or did you create a lein jar
14:48dnolen?
14:49LauJensengit pull && lein jar
14:49dnolenLauJensen: hmm, I thought in order to build lein from source you needed a stable version of lein.
14:50LauJensenSorry, I thought you meant swank
14:50LauJensenFor lein I just downloaded the shell script and ran self-install, thats a while ago now
14:51dnolenthings might be out of date then, I only know how to use lein from source really.
14:54LauJensenany tips you need to pass on before I pull it ?
14:55dnolenlein-swank needs to be built from source and placed in lein/lib/ replacing whichever lein-swank is there.
15:15somejanI made a running-sum function, that lazily generates a seq with the running total of the input seq
15:15avaruswow :)
15:16somejanbut it is 7 lines long, and in a functional language supporting lazy sequences, I think it should be more like a 3-liner or something. http://pastebin.com/m3a479ac
15:16somejanis there a way to do this much shorter?
15:49LauJensen~source reductions
15:49LauJensenThat also looks lazy somejan
15:57qbgDoes the appearance of &env in defmacro mean that we might get first class environments?
16:02the-kennyLooks like vijual isn't very fast with draw-directed-graph-image...
16:03the-kenny357 edges is too much
16:09the-kenny(I just wanted to do this for fun.. but it doesn't look very good)
16:32the-kennyUh, I broke vijual
16:51quidnuncIs swank-clojure HEAD supposed to be working with clojure HEAD?
17:35RaynesI just love null.
17:36hiredmannil
17:54neotykHi
17:54neotykcongomongo: how do I (insert! ...) ignoring reesults?
17:55neotykdocs says: To insert as a side-effect only specify :to as nil.
17:55neotykbut trying {:to nil} throws exceptions
21:33chouseranyone have a link to ctx?
21:43chousernevermind
21:44joshua-choiI have a question on the Clojure parser: namely, its ability to resolve namespace aliases in symbols and keywords
21:44joshua-choiHow does it do it? It must maintain some sort of state when it parses Clojure forms
21:45joshua-choiBut aliases are created by functions, so I don't know how it would figure it out before it even finishes reading; does it do two passes?
21:48mquanderclojure newbie q: what is the most clojureish way to interpolate various values into the middle of a string? is there a more idiomatic way than (str "first-part:" v1 "another-part:" v2 "yet-another-part:") etc
21:49tolstoy(format "something %s or %s" "foo" "bar")
21:49tolstoy,(format "something '%s' or '%s'!" "foo" "bar")
21:49clojurebot"something 'foo' or 'bar'!"
21:50mquanderty time to go read about java string.format then
21:51somniumjoshua-choi: how do you mean? the reader doesn't evaluate symbols
21:51somnium,(read-string "(foo s2/zonk :boom ::bam)")
21:51clojurebot(foo s2/zonk :boom :sandbox/bam)
21:51joshua-choi@somnium: I didn't realize that. But what about double-coloned keywords?
21:52joshua-choiThe reader must know the current namespace's name to resolve them
21:52tomojaw, I thought symbols evaluated to themselves?
21:52somniumI guess it checks *ns*
21:52joshua-choiBut *ns* cannot be known until forms are read anyway, since it depends on ns or in-ns or whatever...right?
21:52somniumhmm
21:53joshua-choiAlso, double-coloned keywords resolve namespace aliases when they are prefixed
21:53joshua-choi,::a/b
21:53joshua-choiWell, if there was a namespace aliased to a, then it would resolve to it
21:54chouser,(do (in-ns 'foo) ::bar)
21:54clojurebot:sandbox/bar
21:54hiredmantomoj: uh, symbols definitely do not resolve to themselves
21:55joshua-choiCan the sandbox alias namespaces?
21:56joshua-choi,(do (require '[clojure.core :as c]) ::c/a)
21:56chouserjoshua-choi: try that at your repl. you'll see the same thing.
21:56hiredmanthe do somehow messes it up
21:57hiredman,(require '[clojure.core :as c])
21:57clojurebotnil
21:57hiredman,::c/a
21:57clojurebot:clojure.core/a
21:57joshua-choiRighto, the reader seems to store namespace aliases...apparently
21:57hiredmaneh? no
21:57joshua-choiHmm
21:58hiredmanthe reading happens in a context
21:58joshua-choiWhen the reader reads a file that contains
21:58joshua-choi(require '[clojure.core :as c]) ::c/a
21:58joshua-choiIt cannot determine the context of ::c/a without parsing—and *evaluating*—the require call
21:58joshua-choiI think
21:59hiredmanthe code in lireader makes reference to Compiler.currentNS()
21:59hiredmanlispreader
21:59tomojhiredman: oops, I meant keywords
21:59tomojI was thinking ruby for a second
22:00hiredmanjoshua-choi: ::c/a is evaluated in the context of the read
22:00joshua-choiHmm, I'm not sure I understand
22:00somniumis ::a/b a valid keyword? it seems like namespacing a namespaced keyword
22:00hiredmanclojure generally reads a file form by form
22:00hiredmanwell
22:00joshua-choiBut does it evaluate form by form?
22:00hiredmanreads and evalutes
22:00hiredman,(doc load-file)
22:00clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
22:01hiredman^-
22:01joshua-choiThat is interesting, and unfortunate
22:01hiredmansomnium: it resolves through aliased namespaces
22:01hiredmanjoshua-choi: how so?
22:01joshua-choiWell, unfortunate for me :P
22:02joshua-choiIt means that, for my Clojure in Clojure parser, I cannot read a series of forms and turn them completely into their equivalent Clojure data structures without evaluation
22:02joshua-choiI suppose that I can make unresolved-namespace-qualified keywords a different data structure...
22:03hiredman*shrug*
22:03joshua-choiBut that is very interesting: I did not realize that the reader actually evaluates each form before the next form in a given Clojure file
22:03joshua-choiThat explains a lot
22:03hiredmannono
22:03hiredmanthe reader does not evaluate
22:03joshua-choiI mean the complier
22:04joshua-choiBut the reader cannot resolve namespace-qualified keywords without the compiler and its knowledge of the current namespace
22:04hiredmanwell
22:04joshua-choiI was under the impression that the Clojure reader was stateless, but this is not so; it's okay though
22:05hiredmanI am pretty sure Compile.currentNS() is just *ns*
22:06joshua-choiYeah, but the fact that the reader needs to know *ns* means that it (or rather, the compiler) has to evaluate previous forms, or the namespace that the reader is called in
22:06joshua-choiIt makes sense
22:08joshua-choi,(defn a [] (in-ns 'foo) ::bar)
22:08clojurebotDENIED
22:08joshua-choiDang
22:21mquanderwhen i am in a slime buffer and i c-x c-e to eval (ns fresh-ns) it sets *ns* to fresh-ns and further evaluations from that buffer seem to correctly use fresh-ns
22:22mquanderhowever, if i then go to the REPL and check *ns*, it's still whatever it was before
22:22RaynesATTENTION: I hate JavaMail.
22:22mquanderif i eval (ns fresh-ns) in the REPL, it sets it in the context of the REPL, but i wonder doing it from the other buffer didn't do the same
22:23mquandercan someone identify the odd misconceptions i have about the connection between the REPL and my evaluated expressions :|
22:24mquanderoh, and i just noticed that my repl prompt is the current namespace. i'm a quick one
22:27mrmargolisIs there some sort of trick for running the clojure-contrib tests? "ant test" works for clojure core but doesn't appear to actually run tests for clojure-contrib. Not seeing anything else that works in build.xml.
22:34mrmargolisnevermind. I didn't set my clojure.jar path.
22:39alexykI need to define a short defn which will pass all its args to another, adding one more. How do I define its arg list so it's easily passed on?
22:40chouser(defn foo [& args] (apply bar new-arg args))
22:40alexykthx!
22:41chouserhm... or even better, (def foo (partial bar new-arg))
22:41alexyko!
22:59alexykchouser: I got: java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword, trying to do: (apply fetch args :as :cursor). since [& args] makes them a seq, perhaps I have to conj the rest?
23:00chouseralexyk: apply wants the last arg you give it to be the seq it should expand
23:00chouserif you need to add args to the right-hand-side, you'll have to muck around a bit. use 'concat' or something
23:01hiredmanyou can just throw in a nil
23:01alexykchouser: ah ok, so if I give two more they should go first and args last?
23:01chouser(apply fetch (concat args [:as :cursor])) or something.
23:01alexykfetch converts to a map so the order doesn't matter
23:02chouserah, ok. so yse, (apply fetch :as :cursor args)
23:02alexykcool
23:02chouseror (partial fetch :as :cursor)
23:06chouserg'night!
23:06alexyknight!
23:07alexykhiredman: turns out need to append at right; if I do (apply fetch args :as :cursor nil), this is what you mean? will args be flattened?
23:08alexykargs is a seq already...
23:09hiredmanalexyk: sorry, came in half way through
23:09hiredmanargs will not be flattened in that case
23:09hiredmanbut apply won't complain about not being able to turn stuff into an ISeq
23:10alexykso (apply fetch (concat args [:as :cursor])) is the prettiest we got?
23:16somniummaybe (def foo (apply partial fetch args))
23:17somnium,(let [f (apply partial + (range 5))] (f 42 72))
23:17clojurebot124
23:23alexykmm ok
23:23alexyksomnium: btw this is all adding to comnomongo :)
23:24alexykanother refinement: in these args, there may be two, :progress <number>, which I then need to extract. How do I check if a seq contains such a pair?
23:26somnium,(some #(= '(3 4) %) (partition 2 (range 6)))
23:26clojurebotnil
23:26somnium(some #(= '(4 5) %) (partition 2 (range 6)))
23:26somnium,(some #(= '(3 4) %) (partition 2 (range 6)))
23:26clojurebotnil
23:26somniumbah
23:27alexyksomnium: they may be in a wrong-parity position...
23:28alexykalso I'm not knowing the number in advance
23:28alexykso I guess I'll get the :progress and then check the num
23:28alexyki.e. is it a num
23:28somnium,(let [r (partition 2 (range 6))] (println r) (some #(= '(4 5) %) (partition 2 (range 6))))
23:28clojurebottrue
23:28clojurebot((0 1) (2 3) (4 5))
23:29somniumhmm, his *out* is slow
23:31somnium,(partition 2 (interleave (range 6) (rest (range 6))))
23:31clojurebot((0 1) (1 2) (2 3) (3 4) (4 5))
23:31somniummaybe something like that and check for pairs?
23:31somniumlooking forward to the additions, already well behind on merging stuff :)
23:32alexykyep
23:35alexykis this how I check which position is an element in in a seq:
23:35alexyk,(some (fn [[e pos]] (when (= e :progress) pos)) (map (fn [x y] [x y]) '(:a :b :progress) (iterate inc 0)))
23:35clojurebot2
23:35alexyksurely there's some find or something :)
23:36alexykI can replace the map my interleave ok
23:37somniumthere's indexed in c.c
23:37alexykindexed?
23:37somnium(doc indexed)
23:37clojurebot"clojure.contrib.seq-utils/indexed;[[s]]; Returns a lazy sequence of [index, item] pairs, where items come from 's' and indexes count up from zero. (indexed '(a b c d)) => ([0 a] [1 b] [2 c] [3 d])"
23:37alexykyeah... still ass-backwards use of some, seems like
23:37somniumsome is just a very poorly named fn
23:37alexykwhere's some (find seq elem)??
23:38alexykmeaning English some? :)
23:38alexykreturn pos if found, nil if not, for chrissake
23:39somniumyou can do (comp first filter) if it makes you feel better :)
23:39alexykwell...
23:39alexyk(doc find)
23:39clojurebot"([map key]); Returns the map entry for key, or nil if key not present."
23:40alexyksomething completely different
23:42alexyk,(find (apply hash-map (interleave [:a :b :c] (iterate inc 0))) :b)
23:42clojurebot[:b 1]
23:42alexyk,((apply hash-map (interleave [:a :b :c] (iterate inc 0))) :b)
23:42clojurebot1
23:44alexykhow do I take two last elements of a seq?
23:44tolstoyanonymous funs implement callable and runnable, right?
23:45tolstoyCan't seem to get the ScheduleExecutorService to work.
23:46tolstoyAh. integers are not longs.
23:51alexykhow do I maintain a counter in a (while ...)
23:52tolstoyalexyk: Use for instead? Or map? Or loop?
23:53alexyktolstoy: I have a fast tight while... will loop be as fast?
23:54tolstoyprobably not.
23:54tolstoyFor some reason, I'm thinking that "maintain a counter" is non-functional, so not really all that easy to do.
23:55tolstoyWhenever I start thinking things like that, I know I'm thinking in Java (or Cish).
23:55alexyktolstoy: yeah... someone has shown me an atom-based way which I forgot
23:56tolstoyAre you wanting to process a list and count up only some of the items?
23:57alexyktolstoy: no, it's a database cursor
23:57alexykthe while is: (while (.hasNext cursor) ...) ; somnium would recognize this one :)
23:58tolstoyCan't use reduce?
23:59somniumyou can use loop, better if you want to keep an index I guess