#clojure logs

2009-11-07

00:20konrIs there a way to call a protected method besides using gen-class?
00:20hiredmanI am glad you asked
00:20hiredmanhttp://gist.github.com/226726 <-- wall-hack-method
00:21konrhiredman: haha, I just ran into that piece of code wondering if it was trying to do that
00:31chouserhiredman: we could smuggle that into contrib. what do you think?
00:34hiredmansure
00:35hiredmanI hate java.uti.Date
00:54somniumhey, is this obviously broken for any reason -> http://paste.lisp.org/display/89933
00:54somniumtrying to make a when-let for multiple bindings and it seems to work without much code
00:55hiredmanyou're missing a quote
00:55somniumwhere? it runs in my repl
00:55somniumah, in the example
00:55somniummy bad
00:59somniumI meant the semantics I guess, I saw several people asking about multiple when-let if-let bindings recently and it doesn't *seem* so hard
01:05chouserhiredman: I think it has to be a patch via clojure-contrib assembla. Maybe again java-utils?
01:06hiredmanok
01:06chouserhiredman: go ahead and assign it to me
01:07hiredmanI remembered my password on the first go round!
01:14chouserI don't think any one person watches every commit that goes into contrib
01:17hiredmanI'm not a member of the space
01:18hiredmanso I can't do much
01:18hiredmanhttps://www.assembla.com/spaces/clojure-contrib/support/tickets/43-add-wall-hack-method-and-wall-hack-field-to-java_utils-clj
01:19_atoah ha! I fixed Chousuke's problem
01:20hiredman!
01:20_atoall I did was rearrange his classpath a bit
01:20hiredman:|
01:20_atoproblem was it was compiling itself over itself and getting all confused because gensym makes things change name
01:21hiredmaninteresting
01:21hiredmanhave you seen my reader?
01:21_atono I hadn't
01:21_atothere's two competing readers is there? :)
01:22hiredmanwell, competing? I dunno
01:23_atoah so yours is all one function, that probably helps you avoid Chousuke's problem
01:23hiredmansort of
01:24hiredmanit's one top level function
01:24hiredmanwith the letfns, but the letfns are locals
01:24_atooh right, but the inner closures and stuff will still come out as multiple class files
01:33chouserhiredman: it's done.
01:33hiredmanhuzzah!
01:34somniumare you going to keep the cool name?
01:34hiredmanit's in the tree with the name
01:34somniumnice
01:34chouser"hack" in the name is very appropriate
01:35chouseradd-classpath should probably have that too
01:40selector-gadget?quit
01:53chouser~tarpit
01:53clojurebotHuh?
02:12konrIs there a variation of filter that splits the lists into matching and not-matching parts?
02:13hiredmanreduce
02:13hiredmanthere is split-with but that only works on a sorted list
02:14hiredmanwell
02:14hiredmanit sort of only works on a sorted list
02:18somnium,(doc separate)
02:18clojurebot"clojure.contrib.seq-utils/separate;[[f s]]; Returns a vector: [ (filter f s), (filter (complement f) s) ]"
02:19konrsomnium: oh :( I was starting to code that!
02:20somniumkonr: I've found that simply reading contrib is a great way to save time :)
02:20somnium(and core for that matter...)
02:20somniumif only there wasn't so much to read
02:25somniumis contrib.core a place for 'soon to be in clojure'?
02:30lisppaste8krumholt pasted "problem with agents" at http://paste.lisp.org/display/89934
02:31krumholtcan somebody see an obvious error with that code?
02:32hiredman #'minus is unusual
02:32hiredmanI think old versions of ants.clj had that(maybe it still does?)
02:32hiredmanbut #' is not needed
02:33hiredmanwhat problem are you having?
02:33krumholtok but that doesn't seem to be the problem
02:33krumholti get an out of memory error on the agent
02:34hiredmanpossibly you are queing up a ton of agent actions
02:35krumholtException in thread "Swank Control Thread" java.lang.OutOfMemoryError: Java heap space
02:35hiredmanwhat happens if you up the sleep times?
02:36krumholti tried i went: Exception in thread "Read Loop Thread" java.lang.OutOfMemoryError: Java heap space
02:37krumholt:)
02:37krumholtnot much better
02:37hiredmanhave you tried it outside of slime?
02:38krumholtno i will one second
02:38hiredmanit's humming along here
02:42hiredman(#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>)
02:42hiredmanthere we go
02:42hiredmancould just be the number gets too large
02:44krumholthm it's not doing anything if not used from slime
02:44krumholtno error
02:44krumholtmaybe if i wait longer
02:44krumholtah now
02:45hiredmanI dunno
02:46krumholtwell thanks anyway
02:46hiredmanoh duh
02:46hiredmanuse when
02:46hiredmannot while
02:47hiredman,(doc while)
02:47clojurebot"([test & body]); Repeatedly executes body while test expression is true. Presumes some side-effect will cause test to become false/nil. Returns nil"
02:47krumholtoh man
02:47krumholtthanks
02:47hiredman,(doc when)
02:47clojurebot"([test & body]); Evaluates test. If logical true, evaluates body in an implicit do."
02:47krumholtof course i meant when
02:47hiredmanvery easy to overlook
02:48jamesswiftHey! I thought I might post here a small program I wrote as a learning exercise http://wiki.github.com/phraemer/Boggle-Solver
02:48krumholthiredman, thanks again could have look hours over that vode without figuring that out
02:48hiredmanso it was the agent queues overflowing after all :P
02:48krumholtyes
02:48hoeck1hiredman: good catch : )
02:48krumholtvode = code
07:31javuchi1what do you thing about CL+FSET versus Clojure?
07:41Licenser_what is CL FSET?
07:43Licenser_ah google told me
07:44javuchi1FSET are inmutable collections for Common Lisp
08:20Chousukeyay
08:21Chousukeeverything builds and all contrib and clojure tests pass!
08:27gbtcongrats Chousuke :) I was lurking yesterday so I know you were having a few 'minor' troubles ;)
08:27Chousukeyeah, _ato solved them for me :P
08:28Chousukeapparently it was some classloader thingy and not an actual problem with my code
08:28gbtshhhh, you're meant to keep that sort of thing to yourself :D
08:28gbtthats ok then. So is this reader just for yourself or an addition to clojure proper?
08:30ChousukeWell, I started writing it just to see how it'd turn out.
08:31ChousukeI think it'll still need some tweaking before I dare suggest it for inclusion though. But at least I have something that works as a base now.
08:32gbtI'm a noob, so its beyond anything I can understand. But its great to see so many people actively trying to improve what is already an impressive language :)
08:34The-KennyChousuke: What's the difference between yours and the "original" reader?
08:34Chousukemine is written in Clojure :)
08:35The-KennyOh, that's cool :)
08:35Chousukeit also uses multimethods, but otherwise it's pretty similar to the java reader.
08:53thomasleecompojure question -- any ideas why the :user-id session variable would not be set despite the redirect-to in login-action being executed? http://pastebin.com/d29a8c7ed
08:54thomasleewell it's not an *actual* redirect-to, but a redirect all the same. :)
10:03scodeI'm looking to implement an LRU cache based on immutable data structures. I can't figure out how to do so using Clojure data structurs, due to the problem of keeping track of recenticity.
10:04scodeEffectively I need an efficient priority queue (the priority in this case being the recenticity) where the priority of individual items can change. It's fine if it's log(n) or better, but n is not acceptable.
10:04scodeAm I missing something obvious?
10:04scodeIf the clojure vector did logn32() removal at arbitrary indexes I'd be okay.
10:06The-Kenny:)
10:06The-Kennywrong window, sorry.
10:26chouserscode: would a sorted map do it?
10:26scodechouser: I thought so at first, but as far as I can tell I can't "grab the first element" out of a sorted map.
10:27scodeOr rather, I can't produce the "rest" of the sorted map.
10:27chouseruse 'first' to get the first, and then remove it from the map
10:27scodeI think. :) It was one or the other.
10:27scodeRight. I think I found some problem with that. *reconsiders*
10:28chouserI've not actually used a sorted map that way, so there may be a use case where it falls down, but it's the most likely of what we've got so far.
10:28chouserfinger trees should be able to do it too, but they're not ready yet.
10:30scodeWas not aware of those (http://en.wikipedia.org/wiki/Finger_tree) - I'll read up on them. Thanks :)
10:30scodeAs for sorted map, I think you're right. I think I made a mistake when I went down that path before.
10:36scodeYeah. I'll need an additional mapping to cross-reference values in that sorted map, but it should work.
10:37chouserscode: if your keys are not naturally unique, you can use a vector of [priority uuid] as the key
10:38chouserwhere uuid is not necessarily anything industrial-strength, just something to keep your priorities from colliding.
10:38chouserscode: If you get it working (or find why it doesn't), I'd appreciate knowing about it. The question comes up occasionally.
10:39scodechouser: I was planning on keeping an ever increasing counter to keep track of recencitity.
10:39chouserah, so naturally unique. good.
10:39scodeThe keys will be uique, but since the sorted map is sorted on key (which in this case is recenticity), I must keep a separate mapping to find the [recenticity, key] tuple for a given key
10:40scodechouser: And yes I'll let you know.
10:40scodechouser: I am doing this to make some comparisons on the effects on GC performance/latency as a result of avoiding mutations (making incremental collections less expensive).
10:42chouserClojure's sorted-maps haven't gotten the same optimization effort that its hash-maps and vectors have gotten, I think.
10:42chouserno transient sorted-map for example.
10:42scodeTransient, in this context?
10:42scodeI do not care too much about absolute performance right now, as long as complexity is reasonable.
10:42scodeIt's more about seeing how CMS/G1GC behaves with no writes to older generations.
10:43scode(Or very few writes; there won't be zero.)
10:43scodeAnd an LRU is a good practically relevant use case. I wasn't able to get good enough behavior on multi-gigabyte heaps mostly containing LRU-cached data.
10:44chouserclojurebot: transient?
10:44clojurebotDon't bash in place
10:44chouserhmph. I'm not finding useful docs on transients.
10:44scodechouser: Oh, you're saying the implementation is in fact mutation based?
10:44chouserclojurebot's advice is accurate, but a bit incomplete. :-)
10:44scodeRather then copy-on-write "all the way down".
10:45scodeThat was my interpretation of 'don't bash in place'. So if it's not transient, I guess it's bashing in place? :)
10:46chouserscode: hash-map and vector support a special "mode" where some mutation is allowed for performance.
10:46scodechouser: http://clojure.org/transients
10:46chouserah, yes, that's it.
10:46scodeAh, I didn't know that. I thought there was never any mutation.
10:46scodeI'll read that one. A bit later; gotta go away atm.
10:46scodechouser: Thanks for your help!
10:46chouserscode: sure
10:48scodeBut I did peak right away; sounds like it's transient mutation in the sense of temporary values during creation, rather than any mutation of the actual data structure being operated upon. Which is fine in this case; writing to newly created data is okay for my purposes.
10:50chouserscode: you may be being mislead by the introduction. transient can be used later in the life of the collection if its useful, for example for "batch updates"
10:51chouserIf you're doing one-at-a-time inserts and updates to your maps, you're likely to not call anything that uses transient/persistent! internally and using them explicitly yourself may not change very much.
11:38krumholthi, does anyone have java completion in emacs?
11:51leafwkrumholt: goodle knows.
11:51leafwgooGle
11:53krumholtsry i didn't mean java java completion but clojure java completion. so it can complete i.e (.printSt to (.printStackTrace
11:55kefka,(class (- 12345678901234567890 12345678901234567889))
11:55clojurebotjava.lang.ExceptionInInitializerError
11:55kefka,(- 12345678901234567890 12345678901234567889)
11:55clojurebotjava.lang.ExceptionInInitializerError
11:55kefka,(- 6 5)
11:55clojurebot1
11:55kefka,1
11:55clojurebot1
11:55kefka,12345678901234567
11:55clojurebot12345678901234567
11:55kefka,12345678901234567890
11:56clojurebot12345678901234567890
11:56kefka,(- 12345678901234567890 1)
11:56clojurebotjava.lang.ExceptionInInitializerError
11:56kefka,(- (new java.lang.BigInteger 6) (new java.lang.BigInteger 5))
11:56clojurebotjava.lang.ClassNotFoundException: java.lang.BigInteger
11:56kefka,(- (new java.math.BigInteger 6) (new java.math.BigInteger 5))
11:56clojurebotjava.lang.IllegalArgumentException: No matching ctor found for class java.math.BigInteger
11:57kefka,(- (new java.math.BigInteger "6") (new java.math.BigInteger "5"))
11:57clojurebot1
11:57kefka,(- (new java.math.BigInteger "12345678901234567890") (new java.math.BigInteger "1"))
11:57clojurebot12345678901234567889
11:57kefka,(class (- (new java.math.BigInteger "12345678901234567890") (new java.math.BigInteger "12345678901234567889")))
11:57clojurebotjava.lang.Integer
11:58kefka,(class (- 12345678901234 12345678901233))
11:58clojurebotjava.lang.ExceptionInInitializerError
11:58kefka,(class (- (long 12345678901234) (long 12345678901233)))
11:58clojurebotjava.lang.ExceptionInInitializerError
11:58kefkaweird.
11:58chouserthose all work fine in my repl
11:58kefkathey work fine in mine too
11:58kefkaalthough (- 12345678901234567890 12345678901234567889) is an Integer
11:58gbtkrumholt: clojure-mode seems to do it. well I just tried (.printSt and it worked
11:58kefkawhile (- 12345678901234 12345678901233) is a Long
11:59kefkaWhy does BigInteger get downcast but not Long?
11:59kefkaIn my mind, (long 1) is a bit pathological.
11:59kefkaObviously, (unchecked-subtract 12345678901234 1245678901233) should be a Long.
12:00kefka(long 1) is pathological because of the nasty map behavior
12:00kefka,(get {(long 1) "one"} 1)
12:00clojurebotnil
12:00krumholtgbt, hm doesn't work for me for some reason
12:01gbtkrumholt: what version of clojure-mode you got? I'm on 1.5
12:01onigirikefka, chouser what's the problem? all these clojurebot requests made me curious
12:01gbtI'm new though, so I don't know if its always worked?
12:02kefkaThe clojurebot exception is not the problem; we don't have that in our Repls.
12:02kefkaSubtle issue with Clojure is that while 1 and (long 1) are semantically equal, hash-maps treat them as different.
12:02krumholtgbt, uh i am on 1.0
12:02krumholtgbt, thanks gone update
12:03kefkaonigiri: So that can be an issue if you're dealing with, say, sparse matrices/vectors
12:03kefka,(get {(long 4) "four"} 4)
12:03clojurebotnil
12:03onigirikefka: oh I see, thanks
12:03kefkaAlso...
12:03kefka,(hash-set 1 (long 1))
12:03clojurebot#{1 1}
12:04kefka,(sorted-set 1 (long 1))
12:04clojurebot#{1}
12:04kefkaI think that if you're relying upon numerically equal things comparing equal, better to use sorted maps/sets for now.
12:04kefkaI generally think (long 1) is a pathological value but there are times when it's appropriate (e.g. a function takes only a long).
12:04kefkaA java function that is... obviously, clojure numerical functions don't care.
12:12chouserthere are several objects that can represent 1 -- if you're using them as keys in a collection it's probably worth making sure you always use the same type.
12:12chouserusing numbers as keys
12:17Chousukehmm
12:17Chousuke,(get {(long 4) "foo"} (long 4))
12:17clojurebot"foo"
12:26kefkachouser: agreed, but this is hard to guarantee.
12:26kefkaBecause (- 12345678901234567890 12345678901234567889) is the Integer 1 but (- 12345678901234 12345678901233) is the Long 1.
12:26kefkaWhich is counterintuitive. It'd be better if - were consistent, IMO.
12:26kefkaEither it always downcasts, or it never does.
12:27kefka* In my example, the first is a subtraction of two BigIntegers and the second is one of two Longs
12:53cuphowdy, is there a standard recommendation for how to structure a compojure site?
13:12javuccihello there
13:48ericthorsenIs there a correlate to proxy-super for gen-class(ed) class methods?
13:49rhickeyericthorsen: see :exposes-methods in the gen-class doc
13:49rhickeyshould do the trick
13:49rhickeyif slightly differently
13:50ericthorsenrhickey: I saw that..just checking to see if there was a magic function. Thanks!
14:10javi_rhickey, what do you think about FSET?
14:11rhickeyjavi_: I haven't used it, but it seems like a good idea if you are in CL
14:16javi_i see the problem with FSET is the interaction with the remaining Lisp
14:29scodechouser: I have a preliminary LRU now at http://github.com/scode/plrutest/
14:30scodechouser: But it's definitely preliminary (needs docs, needs some additional features, and can definitely be optimized)
14:41chouserscode: great!
14:41chouserscode: another perfect candidate for deftype/protocols once those are ready.
14:48djpowelli've just been added to the contrib page; is it possible to subscribe to clojure-dev without a google account?
15:06ericthorsenrhickey: Anything I have to so for overloads on the expose methods for gen-class? Cannot seem to get it to see a no arg version of the function...I'm passing this to both versions
15:06ericthorsen...:exposes-methods {read superRead unread superUnread}
15:06ericthorsenboth read and unread have overloads
17:02scodechouser: Amusingly when I googled the first hit was what you just said - apparantly Google indexes faster than I catch up on IRC
17:02scodechouser: But were you referring to http://www.assembla.com/wiki/show/clojure/Datatypes (deftype/protocols)?
17:04rhickeyericthorsen: what you get is another method with the name you specify, to call use (.superRead this)
17:05chouserscode: ooh, if so that's new -- google's generally been a couple weeks behind on our irc logs
17:05chouserscode: but yes, datatypes
17:08scodeRoger, sounds interesting. I admit to not having kept up with the movements in clojure as well as I would like.
17:21ben_mGreetings :)
17:21ben_mIs there a way to load some definitions from a file into the REPL, so I can do interactive development?
17:23Chousuke(doc load-file)
17:23clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
17:24Chousuke(doc load) ; this also
17:24clojurebot"([& paths]); Loads Clojure code from resources in classpath. A path is interpreted as classpath-relative if it begins with a slash or relative to the root directory for the current namespace otherwise."
17:24ben_mThanks :)
17:25ben_mWould you generally recommend Clojure to a functional programming fan (I love Haskell, Common Lisp, ...), who likes the JVM, but not Java the language?
17:26ben_mFrom what I've seen when I last played with Clojure is that you do have to use Java-esque code frequently when interfacing with the JVM.
17:31_atoben_m: yes, idiomatic Clojure is very functional.
17:32ben_mThis mentality of "embracing the jvm" puts me off a bit
17:32ben_mBut we'll see :)
17:34_atowell, it's a choice between that and rewrite everything yourself, I guess. In practice I find interfacing with Java code works fine. If the library has a particularly horrible API a couple of wrapper functions and the odd macro can clean it up
17:35ben_mSounds reasonable.
17:46fradiavaloHi, is it possible to write multi-line code on slime (swank clojure)?
17:47_atofradiavalo: in the REPL?
17:48fradiavalo_ato: yes
17:48_atoyeah... just don't close your parens and it'll continue on the next line
17:48_atoalthough I prefer to do multi-line things in a .clj for and evaluate with C-x C-e
17:48_atos/.clj for/.clj file/
17:49javi_who's using clojure?
17:49javi_is enterprise ready?
17:49fradiavaloah, I see. I am using paredit mode, so that doesn't let me not enter an closing paren
17:50_atojavi_: gosh I hope not. Most thing labeled "enterprise" are terrible. ;-)
17:50fradiavaloI can't just put my cursor before the closing paren and hit return
17:50ben_mfradiavalo: ^d then press return?
17:50ben_mI don't know about paredit so that's just a guess :)
17:50javi__ato, then i don't understand why to use the jvm, as it is very much enterprise "oriented"
17:51javi_in other words
17:51javi_is clojure ready in reability and stability terms?
17:51fradiavaloben_m: thx, but that doesn't work
17:52javi_reliability
17:52ben_mfradiavalo: What keeps you from writing the code in some buffer and loading that?
17:52ben_mAs _ato said
17:52fradiavaloben_m: yeah, I could do that. Its just that I love typing at the REPL :)
17:53ben_mheh
17:53ben_mWell, you just type at another buffer and evaluate the last s-expression.
17:53ben_mI think you don't even have to save the buffer or anything.
17:53ben_mI'm a Vim user who uses Emacs only for Common Lisp and Haskell, so these are all just assumptions.
17:53fradiavaloYou mean just like other lisp expressions in the scratch buffer?
17:53ben_mright
17:54fradiavaloI will give it a shot
17:54_atojavi_: uhh... yes, it doesn't crash randomly? is that what you mean by reliable? ;-)
17:55fradiavaloben_m: That does work if I turn on clojure more on the buffer
17:55ben_myeah
17:55ben_mthat's pretty nice :)
17:55fradiavaloben_m: yeah! Thanks
17:55ben_mI should tidy up my .emacs file (that's what is keeping me from using Emacs more) and get used to it for clojure
17:55ben_mfradiavalo: Thank _ato for that
17:56fradiavaloyeah thanks _ato too
17:56fradiavaloben_m: Take a look at emacs starter kit
17:57_atofradiavalo: another handy key combo is C-c C-c which will compile the top-level form you're in the middle of. Which is great for working on functions as you don't have to navigate to the end of it to compile it
17:58fradiavalo_ato: Yeah, that is pretty cool. I also like how code navigation just works
17:58ben_mcode navigation? :)
17:58fradiavaloben_m: Jumping to definations and back
18:00_atoben_m: M-. to go to a definition and M-, to go back
18:00ben_mThat's nice.
18:02ben_mI hate configuring Emacs :D
18:03fradiavaloIt is not possilble to change your classpath from the REPL, is it?
18:04_atothere's an add-classpath function, I don't know how reliably it works though
18:05fradiavaloI will take a look at that. Java's classpath is so rigid, I still haven
18:06fradiavalohaven't figured out a system to manage my code well
18:06ben_myeah...
18:06Raynesfradiavalo: I believe the add-classpath function is rather frowned upon.
18:07RaynesUsually when people recommend it they say something along the lines of "But don't get too used to it."
18:08fradiavaloRaynes: :), I will keep that in mind
18:08fradiavaloAnything that makes classpath managable has to be black magic.
18:08RaynesIndeed.
18:10fradiavaloWhat makes Raynes not hate it now?
18:10RaynesI got used to it.
18:11fradiavaloHow you keep from adding every new jar to it?
18:11fradiavaloHow do* you
18:17_atofradiavalo: personally I just have ~/.clojure/* on my classpath an symlink in any jars I need. not great but I haven't bothered to come up with something better. If it's a more complex project (like some existing java monster with a million jars) I'll put the swank.jar in it's classpath, start it from a terminal and use M-x slime-connect in emacs
18:17_atoI think some of the maven users came up with some emacs magic for automatically switching the classpath depending on the project you're working on, reading the dependencies from pom.xml. I haven't looked into that yet
18:19_atoyeah, here we go: http://github.com/talios/clojure-maven-plugin
18:19_atothey have a clojure:swank task
18:19fradiavalo_ato: I have something similar to you now. But sometimes when I add symlinks to new jars, it doesn't work. I will take a look at Maven
18:19fradiavalothanks!
18:29st3fanhmm is there a (find-first collection fn) ?
18:29st3fani need to find a matching item in a (small) sequence
18:30st3fansequence of maps
18:31_ato,(use 'clojure.contrib.seq-utils)
18:31clojurebotnil
18:31st3fanah seq-utils :-)
18:32_ato,(find-first #(> % 4) [1 2 1 3 6 3 2])
18:32clojurebot6
18:32_atonot sure if that's exactly what you meant
18:35_ato,(find-first :a [{:b 2} {:c 3} {:d 7, :a 4}])
18:35clojurebot{:d 7, :a 4}
18:37st3fanyeah it is
18:37st3fani should really use a map though
18:37st3fanto do a direct lookup
18:40ben_mfradiavalo: the emacs starter kit is great, thanks for the recommendation
18:41fradiavaloben_m: you are welcome. Thank the author for it :)
18:44fradiavaloben_m and _ato: C-j will do \n and indent at the slime REPL :)
18:45ben_mmhh
18:45ben_mM-x slime opens up two buffers with a REPL
18:45ben_m:/
18:46fradiavaloben_m: one is inferior lisp, avoid that one
18:47ben_mok
18:47ben_mStill ugly :D
18:47_atofradiavalo: ah, cool. that's handy. That reminds me I should turn on paredit at the REPL was well (I use it when editing source)
18:49fradiavaloyeah paredit is awesome, it feels a little weird at first, but once you are a little used to it, it becomes indispensible
18:49ben_mI feel that way about the Emacs in general
18:49fradiavalotrue
18:49ben_mI'm a Vim poweruser though
18:50ben_mI'm not used to editing things in Emacs :/
18:50_atoben_m: I think *inferior-lisp* is the stdin/stdout of the clojure process, and then the other REPL slime connects to via a socket which does all the funky slime stuff
18:50_atoeg. if you use slime-connect to a remote process you don't get *inferior-lisp*
18:50ben_mWhen you load a file via C-c C-l, both buffers load the file
18:52digashlets say I have a vector of integers. How do I find the index of the smallest one?
18:53_ato,(apply min-key second (indexed [90 50 40 70 30]))
18:53clojurebot[4 30]
18:53_ato,(first (apply min-key second (indexed [90 50 40 70 30])))
18:53clojurebot4
18:54_atothere's probably a simpler way
18:54djpowell,(doc indexed)
18:54clojurebot"([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])"
18:54djpowellis that from contrib?
18:54djpowell,indexed
18:54clojurebot#<seq_utils$indexed__697 clojure.contrib.seq_utils$indexed__697@8fc519>
18:54djpowellk
18:57_ato,(first (apply min (indexed [90 50 40 70 30])))
18:57clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
18:57_atooh right
18:58fradiavalo,(doc min-key)
18:58clojurebot"([k x] [k x y] [k x y & more]); Returns the x for which (k x), a number, is least."
19:02digashthanks, for the pointers i will need to adapt it to clojure 1.0 w/o contrib
19:08st3fanhmm what is the non-read-macro equivalent of #'foo ?
19:09st3fanisn't that (function foo) in common lisp?
19:09djpowell(var foo)
19:09st3fanah :-)
19:10digash,'#'foo
19:10clojurebot(var foo)
19:12st3fanhmm does not work in my case
19:12st3fani need to do something like this:
19:12st3fan(find-first #(= "Test" (:webservice-action (meta (var %)))) [test-action hello-action])
19:12st3fanwhere the actions are functions with :webservice-action meta-data
19:13ben_mHas anybody used java-sdl with clojure with success?
19:17chouserst3fan: resolve
19:18chouser,(meta (resolve "map"))
19:18clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol
19:18_atost3fan: it doesn't work because [test-action] resolves to a value so your vector contains two functions, not two symbols/vars
19:18chouser,(meta (resolve 'map))
19:18clojurebot{:ns #<Namespace clojure.core>, :name map, :file "clojure/core.clj", :line 1705, :arglists ([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]), :doc "Returns a lazy sequence consisting of the result of applying f to the\n set of first items of each coll, followed by applying f to the set\n of second items in each coll, until any one of the colls is\n exhausted. Any remaining items in other colls are ignored. Function\n
19:19_ato,(map #(meta (resolve %)) '[inc dec])
19:19clojurebot({:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 618, :arglists ([x]), :inline #<core$fn__4427 clojure.core$fn__4427@4e1e4>, :doc "Returns a number one greater than num."} {:ns #<Namespace clojure.core>, :name dec, :file "clojure/core.clj", :line 763, :arglists ([x]), :inline #<core$fn__4516 clojure.core$fn__4516@86b899>, :doc "Returns a number one less than num."})
19:19_ato,(map #(meta (resolve %)) [inc dec])
19:19clojurebotjava.lang.ClassCastException: clojure.core$inc__4430 cannot be cast to clojure.lang.Symbol
19:30RaynesHow would I repeat a function call a set number of times? I naively figured that (repeat 6 (rand-int 10)) would work, but I was wrong. :>
19:31RaynesWhat I'm trying to do is get a sequence of 6 random numbers.
19:31raekdoes the function have side effects?
19:31raekah
19:31RaynesThe function is rand-int.
19:32raek(doc repeatedly)
19:32clojurebot"([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it"
19:32raek,(take 6 (repeatedly #(rand-int 10)))
19:32clojurebot(9 4 7 9 6 0)
19:32RaynesI see.
19:32RaynesI should have thought of that. :)
19:32RaynesThank you.
19:33raeknp
19:44ben_mgroar
19:44ben_mparedit is annoying :D
19:45_atohehe, takes getting used to
19:45ben_mI have (((/ n 2)))
19:45ben_mBecause I removed some things
19:45ben_mAnd I can't remove the outer parantheses :P
19:45_atoM-s
19:45st3fan_ato, i still don't fully understand the function meta-data stff, but i'll read more first
19:46ben_mI have to use Esc-s because urxvt grabs M-s, but thanks :)
19:48_atoyeah, the whole point of paredit is the hotkeys for manipulating S-expressions, until you intern them it is a bit annoying, but then you can't live without it
19:49ben_mguess so
19:50_atost3fan: yeah it's a little counter-intuitive. metadata is associated with vars, not the actual functions the var is bound to. I don't remember why that is, there's no doubt a good reason
19:51_atooh wait.. I just remembered why it is :p
19:52_atoit's to do with importing things from namespaces. for example you can mark a var private and it won't be imported and you want to be able to do that whether the var is bound to a function or something else
20:44fradiavaloben_m: C-q (paren) to insert single parens
20:45fradiavaloand C-u del to delete single parens
20:46ben_mThanks :)
20:50fradiavaloI wonder if there is a functino ot fix missing parens
20:51ben_mI know that there's a function to close all open parens at the end, even without paredit
20:51ben_mDon't remember the name or key though
20:52fradiavaloI will try to find that
20:55ben_mC-c C-q slime-close-parens-at-point
20:56ben_mI read about it in Practical Common Lisp
20:57ben_mThere _is_ a slime-close-all-parens-in-sexp
20:57ben_mC-c C-]
20:57fradiavaloexcellent! Thanks
21:15Raynesben_m: While I'm memorizing the important keys for Paredit, I've set my desktop background to the Paredit cheatsheet. Comes in handy.
21:19cupwhen fetching n items from a vector, is there a performance difference between getting from the front or the back?
21:21ben_mRaynes: I use a tiling window manager, so I don't really have a desktop :)
21:22ben_mRaynes: I'll just keep it open in a browser though until I memorize it.
21:22ben_mNight guys :)
22:30shmayi'm going line by line through ants.clj to learn clojure. i'm looking at this line: (defn place [[x y]] (-> world (nth x) (nth y))). why does it use the '->' operator, and what exactly does that operator do (i've looked at the online examples, but am still a bit confused)?
22:31hiredmanit threads an expression
22:32hiredman(nth (nth world x) y)
22:32hiredmanor
22:32hiredman(-> world (nth x) (nth y)) ~ (-> (nth world x) (nth y)) ~ (nth (nth world x) y)
22:36shmayhiredman: thanks, so it embeds the expression with the previous expression?
22:36chousershmay: -> is never required, it just allows a smoetimes more convenient arrangement of the code
22:36hiredmanshmay: the next expression
22:36hiredman,(-> 1 inc inc inc)
22:36clojurebot4
22:37shmayhiredman: right, i think i got it, thanks a lot
22:37hiredmanthere is also a new related macro
22:37hiredman->>
22:38hiredman,(-> 1 (nth [:a :b]))
22:38clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
22:38hiredmanoh
22:38hiredman,(->> 1 (nth [:a :b]))
22:38clojurebot:b
22:39annealeri have what's probably a really dumb macro question. does what im trying to do in this trite example code https://gist.github.com/97ffff695c43b28d3f2b make sense? and if so, why doesn't it.... work
22:40hiredman:(
22:40hiredmanparens should not be on a new line like that
22:41hiredmanand it looks like you are trying to call a macro at runtime
22:41hiredmanwhich you should not do
22:42shmayso it becomes the 3rd item rather than the 2nd?
22:43hiredmanshmay: it becomes the last
22:43shmaygotcha
22:43hiredman,(-> 10 range (->> (map inc)))
22:43clojurebot(1 2 3 4 5 6 7 8 9 10)
22:45shmay:)
22:51annealerhiredman: well, im not trying to call a macro at runtime so much as i'm trying to define a macro that calls other macros based on its arguments
23:31_atoannealer: is this what you're trying to do? http://gist.github.com/229099
23:31_atonot sure as your gist seems to have dissappeared
23:42annealer_ato: pretty much. thanks