#clojure logs

2011-07-18

00:47ieureCan someone explain this seemingly insane MessageDigest behavior? https://gist.github.com/e8cead34d39c2b93fae1
00:47ieureI get a different hash value every time I hash the same text.
00:47ieureAt least, that’s what it looks like.
00:48brehautieure: are you sure thats not just the address of the byte array?
00:49ieurebrehaut, No, but I’m not sure how to get any other value out of it, and (.compareTo a b) results in "No matching method found: compareTo for class [B"
00:51brehautieure: deprecated but you can use ##(String. (.getBytes "abc"))
00:51lazybot⇒ "abc"
00:52ieureKilled slime. :(
00:52brehaut,(dotimes [n 3] (prn (String. (.digest (doto (java.security.MessageDigest/getInstance "MD5") (.update (.getBytes "abc")))))))
00:52clojurebot"�P�<�O�֖?}(�r"
00:52clojurebot"�P�<�O�֖?}(�r"
00:52clojurebot"�P�<�O�֖?}(�r"
00:52brehauthaha
00:53brehautyeah the digest isnt a string; probably want to base64 encode it if you want to print it ;)
00:54ieureAnd of course there isn’t a Base64 codec in the stdlib.
00:54brehautindeed
00:54Blackfootsha1 gist for files https://gist.github.com/377964
00:54brehauttheres an apache commons one though
00:54ieureYeah, I just wanted to avoid another dependency.
00:55brehautieure: are you trying to compare digests, or get a string repr of them?
00:55ieurebrehaut, Both.
00:55technomancyit's more common to represent md5 as a hex string rather than base64
00:55technomancyfwiw
00:56technomancyyou might be able to do that with format?
00:56brehauttechnomancy: oh duh of course.
01:02ieureCommons-codec’s DigestUtils is way less hassle.
01:02ieureAnother dep on the pile, I guess.
01:04brehautieure: crappy imp (str/join "" (map (comp #(format "%h" %) (partial + 128)) bytes))
01:06brehautieure: im pretty sure my + 128 is wrong
01:18HavvyHmm, what is the easiest way to remove the added spaces between each parameter sent to (println)?
01:18amalloyieure: fwiw, i recently noticed Vash, who produce pretty images (like gravatar's defaults but much nicer) out of md5s
01:18amalloyHavvy: use str
01:18amalloy&(println (str "A" "B"))
01:18lazybot⇒ AB nil
01:18brehautieure: better version (str/join (map #(format "%02x" %) b1))
01:19ieurebrehaut, That’s awesome, thanks.
01:19ieureamalloy, Interesting, link?
01:19brehautieure: no problem. credit goes to timc on the ML
01:19amalloyhttps://github.com/thevash/vash/
01:19brehautieure: http://groups.google.com/group/clojure/msg/3cba3a68b477b39a
01:19Havvybrehaut: But I'm trying to remove the characters that are joined between parameters. While str/join is useful, it's the opposite of what I was looking for. :P
01:19brehautieure: ive checked the output aginst python hashlib
01:19HavvyOh, for somebody else;
01:19Havvyamalloy: Yeah, thanks.
01:20ieurebrehaut, I only care about internally consistent, but you are a champ.
01:20brehautHavvy: added spaces? println adds newlines
01:20amalloybrehaut: you're a champ, but you're just not internally consistent
01:20amalloybrehaut: it adds spaces too
01:20amalloy&(println 1 2 3)
01:20lazybot⇒ 1 2 3 nil
01:20brehautamalloy: oh right
01:21brehaut&(str 1 2 3)
01:21lazybot⇒ "123"
01:22brehautamalloy: lol re:internal consistency
01:28HavvyIs there a way to shutdown just one agent?
01:29amalloyHavvy: uhhh, it's not clear what the point of that would be
01:31HavvyI'm recreating wolf through Clojure, and don't want to keep the agent holding its state to exist where there is no game going.
01:31amalloyso let it get GCed. no big deal
01:32amalloyjust drop your references to it, and the jvm will pick up after you
01:32Havvy"to it" being the agent or the data in the agent?
01:33amalloythe agent, i meant, but i suppose either could be right
01:33HavvyAnd how do you drop a reference to an agent?
01:34amalloyjust...no longer have a reference to it
01:34ibdknoxlol
01:34amalloystop keeping pointers to it
01:48PupenoWhy is there a clojars when there's already a maven?
01:49amalloyPupeno: good luck pushing your half-baked library to maven central
01:50Pupenoamalloy: the filter what they accept? I'm honestly asking, I don't know.
01:51amalloyPupeno: i'm pretty sure your product has to be pretty polished to get into maven central
01:51amalloybut i haven't tried
01:51PupenoOk, got it.
02:00Havvyamalloy: Thanks;
02:12technomancythey also require silly things like domain-name group-ids
02:16amalloytechnomancy: when you're typing java package names all day at work, being asked to specify just a domain name must feel like a real relief
02:45Havvy(I return.) How do I get a record from a vector of records if it has :id equal to "Havvy"?
02:47kumarshantanuHavvy: (map (= "Havvy" (:id %)) records-vector)
02:47kumarshantanus/(=/#(=/
02:47kumarshantanumember:Havvy: (map #(= "member:Havvy" (:id %)) records-vector)
02:50amalloy(filter (comp #{"Havvy"] :id) records)
02:51kumarshantanuHavvy: amalloy: amalloy's version is correct - it should be filter instead of map
02:51Havvyamalloy: That works (after changing ] to a }).
02:52HavvyGracias;
02:53HavvyOh, a set.
03:06amalloyHavvy: clear how that works, then?
03:11HavvyYeah.
03:12Havvy(comp) is one of my more favorite functions. But I'm not used to using sets and keywords as executables.
03:12Havvys/executables/callables
03:12lazybot<Havvy> (comp) is one of my more favorite functions. But I'm not used to using sets and keywords as callables.
04:57jeffrey04erm, i am a bit lost here
04:58jeffrey04i want to build an application that uses some machine learning libraries
04:58jeffrey04currently looking at weka and mahout
04:58jeffrey04if i am to use mahout, where do i start? hadoop? mahout?
05:07clgvjeffrey04: are there no project related "getting started" pages or tutorials?
05:08jeffrey04yes, there is, trying to read thru them, looks like a lot to pick up before i can use mahout in java
05:09clgvmaybe they have an irc channel as well then you probably have better success chances over there I guess
05:09jeffrey04clgv: i hope so
05:10clgv jeffrey04: otherwise try setting some example up step by step
06:08dbushenkoI have updated my web-framework a bit (former ClojureBlog). It is located here now: https://github.com/dbushenko/Clojure-WebApp
06:08dbushenkofor now it is easier to reuse it and the exmaple code
06:41bsteuberdbushenko: looks interesting
06:41bsteuberbut I wonder, why do you put the framework source in a webapp subdir instead of just a dependency?
06:51dbushenkobsteuber: I'm a bit new to all of this. Good idea, btw! I definitely should split it and make a clojar!
06:52bsteuber^^
07:04lnostdal-laptop(let [[a b] '(1 2)] (+ a b)) => 3 ;; is very nice, but is the same thing possible with `binding' ..?
07:04lnostdal-laptopat the moment i'm getting; "clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol"
07:28sritchielnostdal-laptop: binding doesn't do destructuring -- it rebinds a current symbol, outside the scope of the function
07:34lnostdal-laptopyeah, it'd be trivial to create a binding* macro i guess
08:18CozeyHello. I want to create a deftype which behaves like a map but is backed by a java bean
08:18Cozeywhere field access is passed to setX getX
08:18Cozeywhich interface should i use? IPersistentMap or ITransientMap ?
08:36fulletsAny suggestion as to why (pmap identity [1]) would be throwing RejectedExecutionException when eval'd in a slime session, but not when eval'd in e.g. lein repl
08:53bendlasfullets: that looks like a bug in swank-clojufre
08:53bendlas/s/swank-clojufre/swank-clojure/
08:53bendlasfeel free to open an issue here https://github.com/technomancy/swank-clojure/issues
08:55fulletsbendlas: looks like i'm a bit out of date, i'll try 1.3.2 first
08:56bsteuberfullets: yes, that should be fixed now
08:57bsteuberso better update both lein and swank
09:02bendlasbsteuber, fullets: Oh, now I know why that sounded familiar. Verified on an outdated version myself. Sorry about that.
09:03Cozeyhow do i set deftypes fields ? assoc? they are mutable - so assoc will return the same object right ?
09:03stuartsierradeftype fields are not mutable.
09:04Cozey"deftype supports mutable fields, defrecord does not" @ http://clojure.org/datatypes
09:04bsteubernot per default, that is
09:05stuartsierraYou have to add ^{:unsynchronized-mutable true} or ^{:volatile-mutable true} metadata to the fields. Then they can be modified with `set!`
09:06tomojisn't there a warning
09:06stuartsierrayes.
09:06stuartsierra"Don't do this." :)
09:07Cozeyhere be dragons
09:07tomojah, right - "They are for experts only - if the semantics and implications of :volatile-mutable or :unsynchronized-mutable are not immediately apparent to you, you should not be using them."
09:07tomojI still have no clue what they do :/
09:07Cozeybtw : what is the difference between them?
09:07stuartsierraRead "Java Concurrency in Practice"
09:08Cozey:unsynchronized-mutable means just 'there's no lock here'
09:08stuartsierraNo!
09:08stuartsierravolatile != locking
09:08Cozeyand volatile-mutable means - some other thread may modify it ?
09:09stuartsierraLike I said, read Goetz.
09:09stuartsierraThe definition of 'volatile' is subtle and complicated.
09:09tomojis there no way to make those fields private?
09:11tomojI mean, so anybody who has a reference to one of these can mutate those fields? sounds scary
09:12Cozeyok. i'll check out the book.
09:12Cozeyone question though: in the 'persistent/transient' context, how are normal java objects treated?
09:12Cozeyor is this a wrong question ?
09:13Cozeyor are their methods treated like any other 'side effect' call
09:13bendlasCozey: when using java interop, you're on your own
09:13TimMcpersistent/transient are guarantees some Clojure objects make
09:13bendlasthat especially include mutable fields
09:13Cozeymhm
09:14TimMc,(transient (Object.))
09:14clojurebotjava.lang.ClassCastException: java.lang.Object cannot be cast to clojure.lang.IEditableCollection
09:14TimMc,(persistent! (Object.))
09:14clojurebotjava.lang.ClassCastException: java.lang.Object cannot be cast to clojure.lang.ITransientCollection
09:14Cozeymhm
09:15Cozeyi wanted to be able to pass a java object to clojure functions, where object's properties would be accessed via getX/setY/isZ methods
09:15Cozeyi thought that i might create a deftype implementing some of clojure's interfaces
09:16Cozeyand reference the object in its field
09:16Cozeybut now i'm a little bit afraid i will get all the persistent/transient semantics wrong
09:16Cozeyespecially that i can't find documentation for those interfaces - what do they promise etc.
09:18buddywilliamsGood morning
09:19buddywilliamsI was hoping someone could tell me why I cannot sharp-quote an anonymous function
09:19buddywilliams#'(fn [x] (* x 2))
09:19buddywilliamsbut I am allowed to sharp-quote a named fn
09:19fulletsbendlas, bsteuber: thanks - upgrading to the current versions of lein & swank-clojure did indeed fix the problem
09:19tomojwhat would you expect that to do?
09:19stuartsierrabuddywilliams: sharp-quote means "get the Var named …"
09:19Scriptor#'(fn foo [x] (* x 2))
09:20Scriptor,#'(fn foo [x] (* x 2))
09:20clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
09:20TimMcI suspect buddywilliams is trying to do something like #'some-fun
09:20buddywilliamsgotha
09:20buddywilliamsgotcha*
09:20buddywilliamssince there is no var named.. it fails
09:20stuartsierrayep
09:20buddywilliamsA friend and I are going through onlisp and converting all the examples to clojure
09:21buddywilliamsto both read a good book and learn clojure
09:21Scriptorbuddywilliams: yep, fn just returns the function object while any def form returns a var, which is what sharp-quote uses
09:21TimMcCozey: Those interfaces are not really for user consumption, unless you really want to introduce a new transient/persistent pair, which is probably not really what you want.
09:21bendlas#' does indeed work on all vars, not just named fns
09:21stuartsierraAnd #' means something very different in Common Lisp.
09:21buddywilliamsapparently, this works in common lisp: #’(lambda (x) (* x 2))
09:22buddywilliamsso from what I am gathering, this is impossible in clojure
09:22Scriptoryay for lisp 2's
09:22TimMcWhat does it do in CL?
09:22bsteuberCozey: but you don't need mutable references to hold mutable objects
09:22Scriptorbuddywilliams: that's because CL is a lisp-2
09:22buddywilliamsreturns #<Interpreted-Function C674CE>
09:22stuartsierraFunctions and variables have different namespaces in CL. #' means "use the function namespace"
09:22bsteuberso even a record might be fine
09:23buddywilliamsI haven't heard of lisp-2
09:23Cozeybsteuber: yes ok, i thought it might be ther right way
09:23Scriptorbasically, whereas in clojure you can pass an actual function object to another function as a parameter
09:23Cozeybut apparently it's not
09:23Cozeywhen would one use mutables? for speed?
09:23bendlasso a plain (lambda (x) ...) in CL would be an error?
09:23buddywilliamsgotcha stuart
09:23buddywilliamsno
09:23buddywilliamsbendlas
09:24Scriptorso if the parameter is called 'a' and it contains a function object, clojure is perfectly happy doing (a arg1 arg2...)
09:24fulletsbendlas: no; #'(lambda ...) and (lambda ...) are equivalent
09:24bsteuberCozey: yes if you implement somethig very low-level and very performance-critical yourself
09:24bendlasI see
09:24bsteuberlike a new collection type
09:24buddywilliamsstuart I was reading somewhere that you went through onlisp and converted some of the examples - do you have that posted anywhere?
09:24fulletsbendlas: 'foo : (quote foo) :: #'foo : (function foo)
09:24Cozeymhm ok
09:24buddywilliamsmaybe I could reference it if I get stuck
09:24stuartsierrabuddywilliams: wasn't me
09:25buddywilliamsok, I wasn't sure
09:25Scriptorbuddywilliams: other stuart, I think
09:25Scriptorhttp://thinkrelevance.com/blog/2008/12/12/on-lisp-clojure.html
09:25buddywilliamsthanks Scriptor
09:26buddywilliamsI am very new to Clojure/LISP but I want to say that it is very compelling
09:26bendlasfullets: yep, been aware of that. Therefore I found #'(lambda ..) confusing
09:27fulletsbendlas: I think lambda is just special cased because lambda is special. I remember reading somewhere lambda not requiring #' was a change late in the standardisation process, but I may well be wrong
09:28fulletsSo, incanter has swank-clojure 1.3.0-SNAPSHOT in its :dependencies, and I want to use swank-clojure 1.3.2 that I have in my :dev-dependencies. Is there a way to resolve this in favour of 1.3.2?
09:28bendlasfullets: I see, thanks
09:29stuartsierrafullets: use an exclusion.
09:29fulletsstuartsierra: ah, thankyou
09:40dbushenkohow to access HttpRequest from the Ring web-application?
09:40dbushenkoand the same for HttpResponse?
09:43Scriptordbushenko: check the docs, requests are passed to the function and responses are returned
09:45dbushenkoScriptor: I still don't get it. where is HttpServletResponse in the response map?
09:45stuartsierraI don't think Ring exposes those.
09:46dbushenkostuartsierra: so it is not possible?
09:46stuartsierraProbably not with Ring. But you can use the Servlet API directly from Clojure.
09:46dbushenko:-( I wanted to use the JavaSequrity from a Ring-based app
09:47dbushenkobut I need the httpservletrequest to get the context and the current user
09:51stuartsierraCheck the source - the servlet object must exist somewhere, perhaps you can get at it.
09:52joegalloi don't think it does, sadly
09:52joegallohttps://github.com/mmcgrana/ring/blob/master/ring-jetty-adapter/src/ring/adapter/jetty.clj#L10
09:52joegallothey're there alright (the request and response that it), but i don't think you can get at them easily
09:53joegallothat said, you could easily copy&paste your own new ring jetty adapter that stored the request object in a var or something
09:53dbushenkoshit happens.....(((((
10:00dbushenkoare there any examples of using wrap-flash ?
10:16bendlaswhen using M-x clojure-jack-in, where does the stdout go?
10:18bendlaslooking at the source, i suspect it just gets muted
10:18Fossianybody else who always reads that as "stout"?
10:18bendlaswith (set-process-filter process nil)
10:19bendlasFossi: I'm not a native speaker, so till now: no ;)
10:20bendlastechnomancy: any comments on that?
10:20bsteuberFossi: normally to the swank-repl
10:20bsteuberare you in another thread?
10:20bendlasbsteuber: yes, I'm talking about BG threads
10:20bsteuberthe thing is, *out* just points to swank in the main thread
10:21bsteuberso what you can do
10:21bendlaslike logging from a jetty, or something
10:21bsteuber(alter-var-root #'*out* (constantly *out*))
10:21bsteuberthen it'll be the same in all threads
10:21bendlasbsteuber: right, that should do
10:22bendlasand it really should be made so by default
10:22bsteuberoups it was you, not fossi :)
10:23bendlashm, but still, it won't work for java code, writing directly to System.out
10:23bendlasor native libs, printf'ing
10:25bsteuberhmm
10:25bsteuberso better change System.out?
10:26bendlasyou thing native code isn't an issue?
10:26bendlass/thing/think
10:26lazybot<bendlas> you think native code isn't an issue?
10:27bsteuberwell no idea
10:27bsteuberfor me, rebinding *out* is enough
10:28bsteuberbut if you have a clean way to redirect everything, why not
10:28bendlaswe could just redirect it into an emacs buffer
10:29bendlascalled *swank stdout/stderr* or smth
10:35bendlasactually, stdout *goes* to the buffer right now
10:35bendlasit's just appended on top, which is why i overlooked it till now
10:51dnolenthis is awesome, https://github.com/frenchy64/Logic-Starter/wiki
10:53dnolenambrose explains in great and entertaining detail the simple type checker for the simply typed lambda calc that I posted a while back.
11:08vijaykiranHi all .. I've a noob question editing clojure in Emacs - how can I wrap the existing code in a new function ? is there a shortcut for it ?
11:10vijaykirannevermind found it: M-x paredit-wrap-round :-)
11:11kumarshantanuvijaykiran: Alt+Shift+Left_bracket
11:11kumarshantanuafter placing the cursor at the beginning of the s-exp
11:12vijaykirankumarshantanu: sweet - thanks !
11:13kumarshantanuvijaykiran: another way is to type an empty parens first...any kind of bracket, then press Ctrl+Right_arrow_key
11:13Scriptorconfusing, brackets can specifically be [] in British English and () and US English
11:13Scriptorer, the reverse of that
11:14kumarshantanuScriptor: :-) regular brackets in Lisp are these --- ()
11:15HodappScriptor: How is it in British English? In US English the convention seems to be to use the latter for outermost, and [] if you're doing that inside of parentheses.
11:16jolyUS here, and I've always heard "brackets" or "square brackets" for [], "parens" or "parentheses" for (), and "angle brackets" for <>
11:16HodappSame here.
11:16vijaykirankumarshantanu: Ctrl+Right_arrow doesn't work for me - the mac spaces takes over that shortcut. But the Alt+Shift+LeftBracket will help me.
11:16ScriptorHodapp: I'm going by what's in http://en.wikipedia.org/wiki/Bracket#List_of_types
11:17Scriptorbut what joly said is how I think of it
11:18kumarshantanuvijaykiran: Ctrl+Cmd+Right_arrow is the switch-space keystroke on my Snow Leopard, so Ctrl+Right_arrow works for me
11:18Hodappdamn, I don't much like #java.
11:18jolyInteresting list. I don't think of {} as "curly brackets". I've always heard "braces"
11:18HodappI get that they get a lot of dumb questions, but I really don't like the sorts of dismissive replies that are common.
11:19ScriptorI've had cs teachers say curly brackets, probably because it was easier to remember
11:19Hodappjoly: I always hear them as "curly brackets" or "curly braces" mostly because "brackets" or "braces" on their own would always be confused with something else.
11:19jolyyeah
11:19vijaykirankumarshantanu: I'm using lion - anyway - I'll remap the keyboard :-) thanks for the tip.
12:08dnolensorenmacbeth: my take, https://github.com/swannodette/query-extractor/blob/master/src/query_extractor/core.clj
12:12sorenmacbethdnolen: awesome, I like it. you didn't copy/paste the query-key map, but I still see it referenced (line 24). I assume you meant for it to still exist?
12:13sorenmacbethdnolen: nm, I see what you did.
12:16sorenmacbethdnolen: if you wanna do a pull request, I'll merge it. Otherwise, I'll probably just copy/paste your changes manually ;)
12:17dnolensorenmacbeth: done
12:17sorenmacbethdnolen: cheers and thanks!
12:21technomancyholy crap, scala.net attempts to automatically map JDK classes to their .NET equivs. that sounds impossibly shaky.
12:23Scriptortechnomancy: under which question in the release page does it say that?
12:24Scriptornvm, think I found it
12:26technomancyit sounds like they have a lot of wrapper classes the likes of which Clojure explicitly avoids
12:27Scriptorsuch as Scala.IO?
12:27pjstadigyes, but Scala is statically typed, so presumably it can compile away wrapper classes when necessary?
12:27technomancyah, hadn't thought of that. possibly.
12:29pjstadigbut maybe that is the "assume a sufficiently smart compiler" fallacy
12:39sorenmacbethI've got 3 irccloud.com invites. If anyone is interested, shoot me an email to soren {at} dopeness {dot} org
12:39Scriptorjust asked in #scala, apparently JIT inlining is enough to make it not as bad
12:44gfrlogis there any reason that calling (slurp) on the org.mortbay.jetty.HttpParser$Input that is my ring request body would be in inappropriate way of processing it?
12:45gfrlogI'm having this strange problem where my json data works from browser/ajax, but fails from curl.
12:45gfrlogfrom curl the content-length header is plainly 23, as reported by curl and the ring request, but slurping the body returns the empty string.
12:47gfrlogI'm not sure how to debug this :/
12:57gfrlogapparently setting the correct content-type (application/json) makes it work :/
12:57gfrlogseems pretty weird to me.
12:58Scriptorgfrlog: what content-type were you using before?
12:58gfrlogI guess compojure probably eager-reads forms so it can provide it to the routes
12:58gfrlogScriptor: it was the curl default, application/x-www-form-urlencoded
13:18voltonHi, I am currently reading The Joy of Clojure and I don't understand this function: https://gist.github.com/1090074
13:18voltonWhy does it return a PersistentVector?
13:19raekheh, that looks strange...
13:19raekmaybe a typo
13:19voltonI copied it from the book tho and it works
13:21voltonnow I get it, it adds the result of f to a vector
13:21sorenmacbethvoltron: it returns a PersistentVector because everything is wrapped in square brackets
13:21voltonsorenmacbeth: you said it so much better
13:25volton,()
13:25clojurebot()
13:26voltonSo the main difference between Lists and Vectors is that elements are added to the front of the list and to the back of the vector?
13:27voltonAnd the following:
13:27volton,('(\a \b \c) 1)
13:27clojurebotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
13:27volton,([\a \b \c] 1)
13:27clojurebot\b
13:27amalloyvolton: well, you also don't have to quote vectors, as you demonstrated
13:27kumarshantanuvolton: ,[\a \b \c]
13:28amalloyvolton: the fact that lists are not callable is not just an inconvenience, either: nth provides fast random access to vectors, but slow random access to lists
13:30voltonso Vector ~ ArrayList and List ~ Linked List?
13:30amalloyuhhh
13:31amalloykinda? i mean, that's more true than if you reversed the associations, but mutability creates a number of other asymmetries
13:31raekvolton: basically. they are immutable (and persistent), so there are some other differences
13:31voltonyes of course I know that but just regarding the runtime complexity of basic operations
13:31raekvolton: to create a new list with one element in the middle changed, you need to create new nodes for all elements before the middle one
13:32raekvectors have more sophisticated random access and update capabilities
13:32raekyes. kinda.
13:33raekand a clojure list is singly linked, unlike the java LinkedList
13:33voltonah, good to know
13:33amalloyvolton: that kinda falls out of the immutability
13:34amalloyhaving a backlink is fairly pointless if you can't update it, and it would mean that every change to a list requires recreating every entry
13:41raekname-this-function time! https://gist.github.com/1090133
13:42amalloyraek: imo error-fn should accept [res & args]
13:42raekthat makes sense.
13:43amalloyi'd call it something like attempt
13:43raekthen should success-fn accept [res & args] too? :-)
13:43raekamalloy: good name
13:47voltonthanks for your help guys!
13:52cemerickI'd become the biggest google+ booster *ever* if it provided a way to vote GGroups threads down into oblivion.
13:54mayankkohaleyHello Guys
13:55mayankkohaleyI want to learn clojure , can somebody please let me know some good books for learning clojure
13:59dnolenmayankkohaley: http://www.amazon.com/s/field-keywords=clojure
13:59dnolenI have Programming Clojure & Joy of Clojure, both are good.
14:00mayankkohaleydnolen thanks a lot
14:02amalloyoh dnolen, i see you responded to my tweet-question. mispaste would be weird, because the (run 4) example sxhibits similar behavior
14:04dnolenamalloy: so you're running this on your machine? I don't see _.0. clojure 1.2.1 + core.logic 0.6.2 right?
14:04amalloydnolen: no, i'm not
14:04dnolenamalloy: both examples are wrong, I've sent ambrose corrections.
14:05amalloydnolen: whew, thanks
14:05dnolenamalloy: _.0 is ridiculous, that type can only be a function.
14:05dnolenfor those cases
14:05amalloyright
14:06dnolenamalloy: good catch, thx.
14:28buddywilliams,(println "hello world")
14:28clojurebothello world
14:28buddywilliamsvery cool
14:33pmbauerbotsnack
14:34amalloy~botsnack ;; pmbauer
14:34amalloyhm. apparently clojurebot doesn't like excess args
14:34clojurebotforget botsnack is Thanks, but I prefer chocolate
14:35pmbauerah :)
14:35amalloy$botsnack ;; or this
14:35lazybotamalloy: Thanks! Om nom nom!!
14:35technomancyclojurebot: forget forget botsnack |is| Thanks, but I prefer chocolate
14:35clojurebotI forgot that forget botsnack is Thanks, but I prefer chocolate
14:35technomancygeez
14:35amalloyhahaha
14:35technomancyhow did that get in there
14:35amalloytechnomancy: ISTR someone getting very excited about clojurebot accepting instructions from random strangers
14:36amalloyand teaching him a bunch of nonsense
14:36technomancyThe Internet: it's new to some people.
14:36technomancyamalloy: just don't tell him about Wikipedia
14:36amalloyhaha
14:37technomancythough I guess you could always point him to the page about chickens
14:37technomancybecause dudes already know a lot about chickens
14:37technomancyas do ladies, typically
14:37technomancyhttp://www.everytopicintheuniverseexceptchickens.com/
14:39amalloytechnomancy: fascinating
14:40amalloyhah. and the writing style is so distinctive, i almost didn't have to doublecheck that it was ryan
14:40technomancyso true
14:40bultersyou've got to love the sound of memes swooshing by...
14:41Scriptorno wonder I kept picturing a T-re
14:41Scriptorx
14:44amalloytechnomancy: and yet that article seems unmolested. does this explain all the vandalism on the rest of wikipedia?
14:47technomancyyeah, entirely too tame: http://en.wikipedia.org/w/index.php?title=Chicken&amp;action=historysubmit&amp;diff=418205235&amp;oldid=418205062
14:52pmbauerHere we are, Wikipedia chicken vandalism ... all because I couldn't remember the delimiter for botsnack
14:53pmbauer;)
14:54bultersmankind will remember you
14:54bultersthey will talk about you when discussing the beginning of the end of Wikipedia
15:33danscan anyone help me with setting up vimclojure? cant get the ng console to work: https://gist.github.com/1090423
15:33dansi've installed it with leiningen
15:50markskilbeckdans: I never even got that far. Had to bite the bullet and use emacs. Mucho simpler.
15:52dansi have never used emacs, not really an option
15:54Somelauwdans: I have the same problem. Right now I use vim for writing + syntax highlighting + autocompletion and copy pasting to console for testing.
15:54markskilbeckSomelauw: sounds long-winded.
15:54Scriptordans: have you looked into slimv?
15:54Scriptormight be enough to replace nailgun
15:55markskilbeckActually, it was slimv that I couldn't get installed.
15:55markskilbeckI think... My memory isn't cooperating.
15:56Somelauwmarkskilbeck: When using emacs I am always fighting with it. Like if I want to surround a form by another one, I put a ( before it and it creates (). Then I press backspace and it deletes ().
15:56chouserI recommend https://bitbucket.org/agriffis/screenrepl
15:56dansSomelauw: i think i will do the same, at least the syntaxhighlighting is sort of working
15:57Scriptorhow do I wrap a sexpr in square brackets with paredit?
15:57amalloyScriptor: M-x paredit-wrap-square
15:57raekSomelauw: that's paredit (which can be disabled). just select the thing you want to wrap and then press (, or type the ( and then press C-<right>
15:57amalloybind that to a key if you want
15:57ScriptorSomelauw: that's because you have paredit enabled
15:57amalloyraek: (or just M-(, which seems easier to me)
15:58ScriptorI'm trying to learn it though and it's actually pretty cool, http://www.emacswiki.org/emacs/PareditCheatsheet helps a ton
15:58Scriptoramalloy: thanks
15:58danslets face it, vim is so much cooler
15:58raekamalloy: oooh, nice!
15:59amalloyraek: yeah, i only recently bound M-[ and M-{ to similar things
15:59SomelauwI wonder if there are many people that use emacs for lisp languages and vim for everything else.
15:59markskilbeckSomelauw: I do.
16:00amalloySomelauw: gfrlog uses emacs just for irc, i think. madman
16:01ScriptorSomelauw: that's what I'm using
16:01Scriptor*doing
16:02Scriptorthough if it wasn't for slime being so easy I'd be pure vim
16:02markskilbeckScriptor: ++
16:03SomelauwBut thanks for helping me with paredit. I will remember it for when I give emacs another go.
16:03amalloyparedit is solid gold
16:04amalloyonce you stop fighting it, anyway. a settling-in period is inevitable
16:04SomelauwOkay, I am going to try it right now.
16:06amalloySomelauw: and when you get really desperate or frustrated with paredit, you can always insert a character manually with C-q
16:06amalloybut it's super-handy to, eg, just hit ] whenever you want to close any kind of bracket, and let paredit figure out which kind and where it belongs
16:06ejacksonor, in aquamacs, with an OSX copy paste. sneaky.
16:07amalloyejackson: just an emacs kill/yank works fine too
16:07dnolenSomelauw: depends on what languages, Emacs support for functional/logic programming languages seems superior.
16:07ejacksonok, wasn't sure.
16:07amalloyejackson: even M-x delete-backward-char is fine; paredit only rebinds the backspace key, not the function it's usually bound to
16:08ejacksonthat's polite !
16:08Somelauwdnolen: logic programming languages? Do you mean the set of languages consisting solely of prolog? :P
16:08ejacksonanyway, copy paste of ) etc is a very handy paredit override
16:09amalloyejackson: blech. it's useful to know, but if you use it often enough for it to be "very handy" i'm concerned
16:09ejacksonno, its just when you need it, you need it.
16:09dnolenSomelauw: there are many Prolog variants, Mozart/Oz, Mercury
16:10SomelauwBut paredit seems to work well, now that I understand it.
16:10ejacksonoh yeah, its fantastic.
16:11amalloyalso probably worth remembering are M-r, M-UP, and C-}
16:12amalloyC-} looks like some kind of crazy emoticon
16:20Scriptorwhat's the shortcut for switching to the slime repl? (other than C-x b'ing into it)
16:21bsteuberC-c C-z
16:22Scriptorah, thanks!
16:23amalloyScriptor: see also C-c M-p: "set the repl's namespace to this file's namespace"
16:24Scriptordude...
16:24Scriptorso I don't have to keep doing use?
16:24amalloywell, C-c M-p won't do that, it just issues an (in-ns) call, i think
16:25amalloybut C-c C-k compiles/loads the current buffer
16:25Scriptorright
16:26amalloyin that case you never had to do (use), i think
16:27Scriptorhmm, I still did if I have functions in my-project.core and I didn't want to have to prefix every function call in the repl with that
16:28amalloyScriptor: you're missing a feature of clojure's repl, not of slime
16:28amalloy&(doc in-ns)
16:28lazybot⇒ "([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."
16:28amalloyso you could, eg, in a plain repl: (require 'myproj.core) (in-ns 'myproj.core) (my-unprefixed-fn 1)
16:29Scriptoramalloy: right, just saying that having to do (use ...) every time I added a new function got tedious
16:29pmbauerdans: I tried vimclojure and had much more success with slimv. Swank, paredit, repl buffer, completion are all built-in
16:29amalloyScriptor: i don't understand. you don't have to do that
16:29Scriptoramalloy: ah, didn't realize that, thanks
16:29Scriptor(regarding the in-ns code)
16:30amalloytechnomancy's much-loved shortcut for that is (doto 'myproj.core require in-ns)
16:32bsteuberI prefer C-c C-k, C-c M-p, C-c C-z
16:32bsteubermaybe I should define a shortcut for the three in a row ^^
16:33ejacksoni feel so backwards. I just keep (use :reload-all ...) in the command buffer and M-p
16:33amalloybsteuber: yeah, i keep meaning to shortcut some combination of those
16:33amalloyprobably just the last two
16:33michaelr524hello everybody
16:33amalloyejackson: shhh, if you say that aloud nobody will ever respect you again
16:34ejackson:p
16:34bsteuberamalloy: yeah, last two sounds reasonable
16:35michaelr524what's the shortcut in emacs to switch to the slime window at the bottom and then back to the code window at the top?
16:36iceySo, any truth to the rumor that on Wednesday Rich is going to be announcing Smjalltjalk?
16:36ejacksonmichaelr524: C-x o ?
16:37Scriptoricey: I'd figure if there's gonna be anything about a new language it'd be more prolog-y
16:37Scriptormaybe finally clj-in-clj?
16:37michaelr524ejackson: thanks!!!
16:37amalloyScriptor: i imagine we'd have seen git commits leading up to that
16:37ejacksonnp
16:38bsteubermaybe clojure's collection types are mutable now for performance reasons :P
16:38iceyI think it's interesting that nobody's really sure what's going to be talked about
16:39ejacksonicey: we call it frijjon.
16:39technomancyicey: that's clojure/core for you
16:39Scriptorif he started targetting php I'll be pissed
16:40iceyejackson: lol
16:40iceytechnomancy: it's very apple-y of them... not that i really mind
16:40Scriptorthe thing is, both rich and sierra were at the last meetup, are they just really good at keeping secrets?
16:40iceytechnomancy: although, I also don't write tons of libs that would be impacted by language changes
16:42raekmichaelr524: if you use the emacs starter kit, you can use shift and the arrow keys to switch between buffers
16:43michaelr524raek: ah, i'm using the clojure-jack-in stuff from technomancy. just starting with emacs, used vim for years... :)
16:43bendlasis there some kind of clojure meeting at wednesday?
16:43amalloybendlas: rich is presenting at the nyc meetup
16:44pmbaueramalloy: rich hasn't committed very often to clojure's github this year. My guess is there's development going on that's not public.
16:44amalloypmbauer: good point
16:44Scriptorbendlas: yep, in nyc
16:44Scriptorbut they'll be streaming it live
16:45bendlasi see
16:45pmbauerhttp://www.ustream.tv/channel/clojurenyc
16:45pmbauer6:45 PM EST
16:50ejacksonmy money is on streams
16:51Scriptorwould streams offer anything new from lazy-seqs?
16:52raekEST = UTC-5 ?
16:52amalloyraek: yeah
16:53technomancyshould beEDT
16:54islonthis code: (let [cal (as-calendar date)
16:54islon year (.get cal Calendar/YEAR)]
16:54islon (.isLeapYear cal year))
16:54islongives me: Reflection warning, /home/islon/Dropbox/date-clj/src/date_clj.clj:108 - call to isLeapYear can't be resolved.
16:54islonas-calendar is already typehinted
16:54raektechnomancy: so the 6:45 PM time is in UTC-4 then?
16:55islonanyone knows how can I remove the warning?
16:55raek02:45 at thursday here, then... :)
16:55technomancyraek: I don't know, you should ask hiredman to load clojurebot with joda so you could ask him =)
16:57sorenmacbethislon: have you seen https://github.com/getwoven/clj-time ?
16:58islonsorenmacbeth: I don't know how looking at clj-time will solve my type hint removing problem
16:59islon*reflection-warning removing
16:59Raynestechnomancy: fwiw, lazybot has joda on the classpath.
16:59raekjoda-time (clj-time is a wrapper for it) is a much better date and time library
17:00Raynesislon: The answer to any question related to dates and times in Java is 'joda'. Period.
17:00dabddoes anyone know how can I apply the latex listings patch http://alexott.net/common/clojure/clj-latex.txt to include clojure source code in latex documents?
17:01islonRaynes: sorry, but I didn't ask anything about dates, i asked about how to remove a reflection warning
17:03benreesmanhow do i check if a reference points to an instance of a primitive array? i can't remember how to spell that
17:04pmbauerislon: what is the type returned from as-calendar? isLeapYear is defined on GregorianCalendar, not Calendar.
17:04amalloy&(instance? (class (int-array 0)) 10)
17:04lazybot⇒ false
17:04kjeldahlAny nrepl client running on Emacs yet, or updates on recommended method of running clojure from emacs?
17:05kjeldahl(yeah, I've managed to hack together slime stuff and gotten it working before, but it seems less than ideal..)
17:05islonpmbauer: (defn- ^Calendar as-calendar ...
17:06benreesmanamalloy: cool thanks
17:06technomancydid someone find the name sexpbot offensive?
17:06technomancyI feel like I may have missed out on some Internet Drama.
17:06Somelauwvery offensive
17:06pmbauerislon: That would be why you are getting the reflection warning. isLeapYear isn't defined on the Calendar interface.
17:06Somelauw:P
17:07amalloytechnomancy: there wasn't much drama
17:07Raynestechnomancy: No. We're using it in a work-related channel and ninjudd gave me a $50 amazon gift card to rename it so that he wouldn't have to explain to his wife what 'sexpbot' had to do with work.
17:07RaynesIt was actually a pretty fun day.
17:07technomancyhah; classic.
17:08islonpmbauer: hmmm... you are right, thank you =) i'll try to cast to GregorianCalendar
17:08amalloyi figure we'll rename him every week now to make it harder for hiredman to keep him on /ignore
17:12fliebelwhat, sexpbot is now lazybot?
17:12RaynesYessir.
17:12fliebel:)
17:20michaelr524is there a trick to use (map) int (->)?
17:20michaelr524s/int/in
17:20lazybot<michaelr524> is there a trick to use (map) in (->)?
17:20fliebelmichaelr524: how do you want to use it?
17:20michaelr524I want to trim every string in a list
17:21fliebelmichaelr524: So what do you need -> for?
17:22michaelr524I already use ->
17:23fliebelyou can do (-> some code (->> (map fn)) other code
17:23michaelr524ahh
17:23michaelr524good idea
17:23michaelr524let me try that
17:23michaelr524:)
17:25michaelr524worx!!
17:25michaelr524thanks
17:25michaelr524fliebel
17:26bsteubermichaelr524: but -> inside ->> won't work
17:26bsteuberwhich makes sense when you think about it
17:26fliebelDos anyone have a neat trick for going the other way around? like (->> seq map filter reduce (<<- (nth 4))
17:26michaelr524btw, anyone knows why C-C C-C compiling a function is really quick buy C-C C-K compiling the whole buffer takes like 30-40 seconds here?
17:27amalloyfliebel: anonymous functions
17:27amalloy&(->> (range) (filter even?) (take 10) (#(nth % 4)))
17:27lazybot⇒ 8
17:27stuartsierramichaelr524I think It's a bug in Emacs on some windowing systems (e.g. OSX) - it takes too long to draw the progress bar.
17:28amalloymichaelr524: try (setq font-lock-verbose nil)
17:28michaelr524stuartsierra: i'm on xp, here I don't get a progress bar even :)
17:28fliebelamalloy: hm, yea, that might work.
17:28stuartsierramichaelr524: dunno then
17:29michaelr524amalloy: what's that supposed to do?
17:30fliebelmichaelr524: the reverse of what I showed you.
17:30michaelr524fliebel: yeah. I was asking regarding the elisp snippet :)
17:33michaelr524amalloy: didn't help, took 38 seconds
17:33amalloymichaelr524: the part that's slow is usually emacs running a bazillion regexps on the compiler output, or something crazy like that
17:33michaelr524amalloy: yeah, who knows... it might be calling home to andromeda or something :)
17:35bendlasmichaelr524: in that case you should contact NASA, cause 38 seconds would be wicked fast for that
17:35bendlas;)
17:35michaelr524didn't they close nasa already?
17:41bsteuberdamn, I was just writing a cool "-> inside ->>" macro for fliebel and now he left
17:41bsteuberbut for the fun
17:41bsteuber(defmacro ->* [& args] `(-> ~(last args) ~@(butlast args)))
17:43bendlasheh, one of our bots should keep a mailbox for offline users
17:43bsteubergood idea
17:47amalloybendlas: lazybot already does
17:47amalloy$mail bendlas hey a message for you
17:47lazybotMessage saved.
17:47bsteubercool
17:47clojurebotPardon?
17:48amalloythen next time you join/talk, he /msgs you
17:48bendlaswut?
17:48Raynesamalloy: He sends a NOTICE, I believe.
17:48bendlasok, it didnt message me
17:48bendlasbrb
17:49RaynesSome people have weird settings and don't NOTICE the NOTICEs.
17:49amalloyRaynes: yeah, but i don't really understand notices
17:49bendlasok, i didn't get anything
17:49amalloyi think it may be a default erc setting. the last guy who had trouble was using erc too
17:49bendlaswould ERC notify me in a fairly std config?
17:49amalloy*shrug*
17:50raekwhen reading the RFC, you get the impression that notices would be ideal for bot utterances
17:50Raynesamalloy: It definitely has to be notices though. PMs would get really annoying really fast.
17:50Raynesbendlas: In any case, you can /msg lazybot $mail to get the message.
17:50raekbut for some reason clients seem to interpret notices as announcements
17:50raekand trigger the bell, etc
17:50bendlasi see
17:50bendlasit worked
17:50Raynesraek: Or ignore them altogether. Which is what ERC seems to be doing.
17:51bendlasRaynes: no, i just saw it
17:51RaynesOh.
17:51RaynesCool.
17:51bendlasbut it is fairly well camouflaged
17:51bendlasin the irc.freenode buffer
18:17miltondsilva~30 min to live feed right?
18:17clojurebotThe Clojury says to stop making puns.
18:20iceymiltondsilva: are you asking about the ClojureNYC meetup?
18:20miltondsilvaohh... forget it, I see I got the wrong date ;)
18:20iceymiltondsilva: :)
18:25bendlasI have written a dir macro: http://paste.lisp.org/display/123338
18:25bendlasfeedback very welcome!
18:30bsteuberbendlas: why does it need to be a macro?
18:30bendlaspure convenience
18:30raekmiltondsilva: hrm. that time seems 2 hours off to me... are my calculations wrong?
18:30bendlasit's for repl use
18:30bendlasso you can write (dir clojure.java.io)
18:30amalloybendlas: (if (= `*ns* dir) *ns* ...) is madness
18:32raek...or one hour, I think
18:32amalloyraek: the meetup starts 48 hours and 15 minutes from now
18:32bendlasamalloy: let me think for a moment, what that was the workaround for
18:32amalloybendlas: it was for you quoting *ns* incorrectly in the other clause
18:33miltondsilvaraek: hmm... I got the wrong day... about the time, according to this http://24timezones.com/world_directory/current_new_york_time.php and this http://www.google.com/url?sa=D&amp;q=http://www.meetup.com/Clojure-NYC/events/16166953/ I think I'm right.. or am I missing something?
18:33raekamalloy: eh. my calculations were wrong...
18:33raekmiltondsilva: no, you were right! (modulo the day)
18:34raek00:45 is way more convenient than 02:45 for me... :-)
18:34amalloyit's starting to seem like i should give lazybot a $meetup command that says how long till the dang thing starts
18:34bendlasamalloy: hm, could you help me make a version that wouldn't need it?
18:34miltondsilvaI was so excited when I heard there was going to be a live feed that I didn't even confirm the date ;)
18:34amalloythe no-arg version should read ([] `(dir ~*ns* ns-publics)) if you want to do it that way
18:34RaynesWhere would I create an issue for tools.cli?
18:35amalloysince that's basically equivalent
18:35bendlasgo ahead, try it that way
18:35RaynesOnly like 3 new contrib projects are even listed on Jira.
18:35Raynestools.cli doesn't seem to have a way to collect extra, unused arguments, which seems like a massive black hole of a missing feature.
18:36patchworkHey #clojure, I have a question on stackoverflow for you guys:
18:36patchworkhttp://stackoverflow.com/questions/6739962/clojure-how-do-i-refer-to-functions-from-a-loaded-file
18:37patchworkThought it would be better to put it there rather than try to type it all out in here, though if that is not kosher let me know
18:38bendlasamalloy: ok, got it
18:38bendlasfirst clause needs to read ~(ns-name *ns*)
18:54Bronsan
18:59bendlasamalloy, everybody else: I've slightly rewritte the dir macro, care to have a look again? http://paste.lisp.org/+2N62/1
19:02amalloydorun..map println? i much prefer a doseq
19:04bendlasI normally do too, but it saved a gensym that way ;)
19:07bendlasanyway, if there is no heaver criticism, I'll propose it for inclusion
19:11amalloyinclusion in what?
19:11bendlasclojure.repl
19:11bendlasinstead or maybe in addition to the current clojure.repl/dir
19:12bendlasoh, in that case I should also sort it, like the current one does
19:20methodswhat does this mean ? "Clojure multimethods go further still to allow the dispatch value to be the result of an arbitrary function of the arguments."
19:21brehautmethods: in the typical OO programs, the dispatch function for all methods is (fn [& args] (class (first args)))
19:21amalloymethods: instead of eg java's inheritance-based polymorphism, you can dispatch based on, say, the first three characters of the string
19:21brehautmethods: with multimethods you can write whatever function of the arguments you wish
19:22amalloydefine a handler for "get" and a handler for "set", and then later some user of your lib can add a handler for "put" and they all work together an play nice
19:22methodsyea but I think the page was implying that it goes a step farther then generic functions ?
19:23methods"CLOS generic functions extend dispatch value to a composite of the type or value of multiple arguments, and are thus multimethods. Clojure multimethods go further still ... " ^^
19:23amalloymethods: aha. that's dispatch on the *value* of some argument
19:24methodsso what your saying is that, "an arbitrary function of the arguments" allows you to do something like test the first 3 letters of a string or something ?
19:24amalloyyes
19:24amalloybendlas: i'm aware that this is not very helpful, but i don't like your function and i'm not sure why
19:24methodsis there an example ? i would to see how it fits in
19:25brehautmethods: (defmulti fac identity) (defmethod fac 1 [_] 1) (defmethod fac :default [n] (* n (fac (dec n))))
19:25amalloyone thing you can fix at least is (if-let [line1 line2] (-?> ...))
19:25RaynesIt's difficult explaining abstract concepts.
19:25brehautadmittedly thats a terrible example
19:26RaynesI'm so happy I don't have to do i... Oh, man, I'm writing a book, aren't I?
19:26methodshttp://clojure.org/runtime_polymorphism
19:26methodswell i guess that page already shows an example
19:26amalloyoh yeah Raynes, how's that book coming?
19:26amalloymethods: i've used `count` as a dispatch function
19:26Raynesamalloy: Slowly.
19:26methodsI assume that normally [] is just a type of array or something so by him doing actual matching on the values in the array then he's doing just that
19:27Raynesamalloy: My publisher is going to hate me if I don't get to work. And hard.
19:27brehautmethods: empty vector
19:27brehaut,(type [])
19:27clojurebotclojure.lang.PersistentVector
19:27methodssorry I'm really new just reading up on it
19:27brehautthats fine
19:28methodsyea but my point though is that in clos generic functions would you be able to do the same thing or would it simply only be able to dispatch based on fact that you passed a vector ?
19:28brehauti dont know enough about CLOS to answer that
19:29methodssomeone tried to explain to me once the whole solution that generic functions provide .. something about visitor pattern ... but I'm still not sure if I fully get it
19:29bendlasamalloy: it's ok, maybe the wider community will flame it with better arguments ;)
19:29brehautvisitor pattern is a clunky implementation of double dispatch to implement a generic fold
19:30brehautthe visitor calls the visitable thing which calls back to the visitor; it allows single dispatch (based on class) used twice to select the correct implementation
19:30amalloyjesus, brehaut, really? that's terrible
19:30brehautyeah really
19:31amalloythat class was a really long time ago for me, apparently
19:31amalloy$google visitor pattern
19:31lazybot[Visitor pattern - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Visitor_pattern
19:31brehautmultiple dispatch functions choose their polymorphic implementation based on the types of al lthe arguments
19:31brehautmultimethods choose their polymorphic implementation on any function of the arguments
19:32brehautif CLOS uses multiple dispatch on type alone then multimethods are more versitle
19:32brehautif CLOS lets you define any ufnction of the arguments to dispatch then it is equivalent
19:32methodsoh wait i see .. i was wondering why there was any code in the defmulti part.. that's where he looks into the values passed in and figures out which method to call..
19:33brehautmethods: isa? is used under the hood to do the tests
19:34amalloymethods: for example, i have a multimethod here (closed-source, sorry) that takes a map as input. to dispatch, it pulls out one of the keys from the map, does some juggling to convert it into a namespace, and then returns as its dispatch value a keyword with that namespace
19:35brehautoh duh. necesssary evil uses multis to process XML
19:36brehautmethods: https://github.com/brehaut/necessary-evil/blob/master/src/necessary_evil/value.clj#L83-101
19:37brehautapparently xmlrpc is more repelant than i realised
19:39amalloybrehaut: xml is like the poster child for defmulti
19:39brehautamalloy: it really is
19:39amalloysomewhere in cake there's a defmulti i wrote for generating pom.xml, but curiously i can't find it anymore
19:40amalloyi wonder if they threw it out
19:40brehautraynes has refactored again hasnt he
19:40Raynesamalloy: Really?
19:41brehautRaynes: that was me ruining your good name, not amalloy
19:41amalloyRaynes: well, i don't remember where i put it. but a recursive grep turns up only three defmultis, none of which are mine
19:41Raynesamalloy: It's in depot.pom now.
19:41amalloyah. depot. i forgot about that nonsense
19:42RaynesWatch your mouth. Justin will tase you.
19:42amalloymethods: https://github.com/flatland/depot/blob/master/src/depot/pom.clj is another example
19:45methodsis there anything good to read to understand why multi's are better than oo approaches ? (not trying to flame here) .. like you can obviously have the debate about just writing a big switch statement or creating your own defmulti
19:45methodsin another language.. but i remember someone arguing with me that it's still not the same ?
19:46brehautmethods: theres no reason OO canth ave multiple dispatch over arbitrary functions
19:46methodsyea but people in #lisp might try to kill you if you say that
19:46brehautmethods: the main reason to choose between single dispatch and multiple dispatch is performance
19:47brehautmethods: those people are idiots then
19:47methodsyea because it's like c++'s name mangling
19:47methodsit's just directly linked right ?
19:47brehauta virtual method in C++ codes is a pointer indirection through the classes vtable
19:48methodsyea
19:49brehautmethods: however, the realm of runtime optimsation and call site caching is deep voodoo for someone like me, so potentially a multiple dispatch scheme might end up no slower than single disptch
19:50methodsyea i mean in ruby circles people like the duck typing approaching and they don't care really for using obj.type? .. so clojure allowing you to write your own dispatcher seems like it would be more flexible in that approach
19:50methodss/approaching/approach
19:50lazybot<methods> yea i mean in ruby circles people like the duck typing approach and they don't care really for using obj.type? .. so clojure allowing you to write your own dispatcher seems like it would be more flexible in that approach
19:51brehautim not sure how duck typing has anything to do with multiple dispatch
19:51methodswell like you said normally it's based on the "type" of the argument right ? but here you can basically write your own dispatcher to test if the object looks like something instead of actually being something
19:51brehautre:just using a big switch statement: if the dispatching logic doesnt need to be externally extensible (in particular run time extensible) then a switch statement may well be smarter
19:52methodshm what do you mean by run time extensible ?
19:53brehautcode loaded after the multi is defined can extend the multimethod to handle morecases
19:53brehauta switch statement (cond family for example) cannot
19:53brehautits simple late binding
19:53brehautthe java equivalent is classes implementing an interface are loaded
19:54amalloymethods: see eg clojure.core/print-dup, which is a multimethod in core for readably-printing objects. you can add your own implementation any time, which wouldn't work with switch/case/cond
19:54brehautamalloy: thanks :)
19:55amalloythat one only dispatches on type, so it could be a simple protocol, but it demonstrates runtime-extensibility
19:56brehautmethods: there a couple of axis here: #{do you need late binding, dont need late binding), #{single dispatch, multiple dispatch}, #{dispatch on type, dispatch on value} and one case not available in clojure: dispatch on return type.
19:59brehautmethods: multimethods are late bound, multiple dispatch on value. switch statements are early bound dispatch on value. protocols (and interfaces) are late bound single dispatch on type.
20:00brehautmethods: each choice has a tradeoff, but generally the later and less restricted your dispatch mechamism the more powerful it is
20:04amalloy(defmulti super-powerful [& args] (JOptionPane/showInputDialog nil (apply str "What should I do with " args))
20:04brehauthaha awesome :)
20:08mudgeanyone know what let* means?
20:09amalloymudge: in a clojure context? it's just a more limited version of let, which let (a macro) uses internally
20:09mudgeyes, in clojure, ah, is let* a function that let uses?
20:10amalloyit's not a function, it's a compiler built-in
20:12mudgehmm, i didn't see it on clojures list of primitives
20:15methodsbrehaut: well unless your dispatch method has a register hook or something..
20:16brehautmethods: i have no idea what you mean
20:16methodsamalloy: yea that print-dup reminds me of how they do it in haskell ?
20:17methodsbrehaut: hm on return type ?? wouldn't that just be passing the return value to another defmulti ?
20:17brehautmethods: read in haskell is an example of a function that switches on return type
20:17brehautread :: String -> a
20:18brehautif you do (for example) 1 + (read "1") the result is 2
20:18brehautif you do say 'if read "True" then 1 else 2' then it returns 1
20:18brehautbecause read chooses an implementation based on what the inference engine determines is needed
20:19methodsI'm confused on how 'read' is doing any switching ?
20:19amalloymethods: because it knows what context the result will be used in (it needs an int), it can use the int-making version of read
20:19brehautmethods: in the first instance its being used as the second argument to +; the first argument to + is an Integer, so reads return type needs to be an integer, thus read uses that implementation to parse the string.
20:19brehautmethods: in the second it needs a Bool
20:19methodsoh awesome
20:20methodshm reminds me of perl's ability to automatically call scalar() on an array in the right context ?
20:21brehautread's return type is determined at compile time not run time
20:21technomancydoes it blow anyone else away that there's an alternate JVM out there that's 50kloc and still able to run Clojure?
20:21methodsyea i think a good example would of been 1+(read "1") == 2 vs "1"+(read "1") == "11"
20:21technomancyI mean, one that nobody's ever heard of
20:21brehauttechnomancy: wow. link?
20:21technomancyhttp://oss.readytalk.com/avian/index.html
20:21brehautmethods: thats invalid haskell
20:22methodstechnomancy: 50kloc ?
20:22technomancyit's missing a certain JMX class that breaks with one feature of Leiningen, but I was planning on nixing that feature anyway
20:22brehauttechnomancy: thanks
20:22methodsloc = lines of code ?
20:22technomancymethods: 50,000 lines of code
20:22technomancygive or take
20:22methodshm it's going after the embedded market ?
20:22technomancyI guess
20:23brehautlazybot: $heval (read "1")::Integer
20:23methodswhat's wrong with hotspot ? doesn't it have massive jit optimizations...
20:23technomancyit can perform native-code AOT that cuts launch time in half, though overall it's still a fair bit slower.
20:23technomancyhotspot is like a bazillion kLOC
20:23technomancyand hotspot can't AOT to native code
20:24methodsyea i really wish it supported warm up profiles for the jit runtime
20:24brehautstill potentially useful for desktop apps
20:24technomancyavian can take clojure 1.2 boot time down to 0.3s; I'd imagine it could do even better with 1.3 since they were planning on loading less at boot for android
20:25technomancyanyway, I'm just surprised because it basically came out of nowhere
20:25brehauttechnomancy: what is your 1.2 boot time? (for a relative comparisons)
20:25methodsis there any plans to support dispatch on return type ?
20:25technomancybrehaut: on the machine he was using it was 0.6s with client hotspot iirc
20:26brehautoh sure
20:26brehautmethods: the JVM does not provide a facility to do that
20:26brehautmethods: and its only infrequently useful compared to other dispatch models
20:27methodsyea it just allows you to not need to type the extra code at times
20:27brehautperhaps if dnolen's core.logic and associated type engine plays out well it might get added?
20:27methodswhy would the jvm not support it ? like haskell it could be compile time ?
20:27bendlaswow, avian is free software
20:27brehautbecause the JVM doesnt support a lot of things that are useful for non-java languages? haskell suppots TCO at compile time, but the JVM doesnt
20:27bendlashow nice, thanks for the tip, technomancy
20:27methodswhat about llvm's java front end ?
20:28methods^ I mean in comparrison to avian
20:28brehautmethods: additional inference engines are hard to get working nicely in the presence of subtyping
20:28methodswhat do you mean by tco ?
20:28brehauttail call optimisation
20:29methodsyea that's what i figured but wasn't sure
20:29methodsbut why would tco be related to return type inference ?
20:29brehautits not; its just an example of something that haskell has that would be nice but because the jvm doesnt have it, we dont have it
20:29methodsyea i mean it's the same problem that language that compile directly to c have when they want to support tco right ?
20:29brehaut(simulating it muddies interop)
20:30brehautthats a can of worms
20:30brehautGCC supports TCO for instance
20:30methodsah it has special stuff for it ?
20:30brehautit just plain does it with the right flags
20:30technomancyit's funny that avian claims to be "a lightweight alternative to Java"
20:30technomancyrather than an alternative to hotspot
20:32methodsthere was this dialect of c i saw once that was made for all these reasons and made for compilers to output to
20:32brehautGHC for a long time targeted C-- as its output language
20:33brehautJVM bytecodes are much higher level than C however
20:33brehautthey have classes baked right in for instance
20:33methodsas far as i know ghc still does the llvm backend or whatever isn't as fast yet
20:34brehautGHC has a number of backends, it uses its own native code one by default though i believe
20:34mneedhamhey - trying to understand how to dynamically create a symbol - I then wanted to write an assertion that it worked and I thought this one would be ok -> (is (= (symbol ":foo") :foo)) - but it isn't - must be missing something?!
20:34methodsyea i mean but still your runtime could support some more advanced features on top of the bytecode right ? or is hte main goal to not have anything like that for speed ?
20:34brehautmneedham: :foo is a keyword
20:35brehaut,(type (symbol "foo"))
20:35clojurebotclojure.lang.Symbol
20:35mneedhamoh so I want to create a keyword instead?
20:35brehaut,(= (keyword "foo") :foo)
20:35clojurebottrue
20:35brehautcorrect
20:35mneedhamah!
20:35mneedhamso anything beginning with a : is a keywrod
20:35mneedhamis that right?
20:35brehautcorrect
20:35brehaut::foo is a namespaced keyword
20:35brehaut,::foo
20:35clojurebot:sandbox/foo
20:36brehaut,(keyword "mymythicalns" "foo")
20:36clojurebot:mymythicalns/foo
20:36mneedhamah
20:36mneedhamdidn't know you could do that
20:37bendlaswhat's the correct way to propose a feature with a done implementation, for inclusion in clojure?
20:37bendlasticket + pull request?
20:37brehautmneedham: if you are defining heirarchies or similar you definately should namespace your keywords
20:37bendlasticket with attached patch?
20:38brehautbendlas: sign the contributers agreement, post your intentions on the mailing list and then an issue on dev.clojure.org might be created
20:38brehautbendlas: clojure core is conservative on what it accepts and contrib is in a reshuffling phase, and not accepting many (any?)new libs at present
20:39bendlasi know, but it's just an improved version of clojure.repl/dir
20:39bendlasthanks
20:40brehautbendlas: start with http://clojure.org/contributing if you javem't seen it
20:41bendlasI have, just not signed yet, due to inconvenience of faxing
20:41brehautbendlas: international mail agrees
20:41technomancyclojurebot: fax machine is http://achewood.com/index.php?date=11222006
20:41clojurebotIn Ordnung
20:42brehauttechnomancy: win
20:42bendlasanalogous mail? oh boy ...
20:43technomancybrehaut: my super power is to be able to recall relevant web comics for any given situation.
20:43brehautarrows!
20:43technomancyit's up there with Mr. Furious and the Shoveller
20:43brehauthehe :)
20:43bendlas:D @ comic
20:45brehautwhat the hell is wrong with twitter today
20:46tomojthey're running clojure now? :D
20:47tomoj(nah, not for the frontend, and the stuff that is clojure is workin great I bet..)
20:47brehautheh
20:47tomojwonder if they even have any
20:48stuartsierraI think they use Scala a bit.
20:48brehautthey have backtype?
20:49brehauti read an infoq thing or similar that claimed theyve got quite a bit of scala now
20:49tomojbut I wonder how long it would take for backtype code or its progeny to start affecting twitter.com
20:49brehauti recon it will start effecting their bottom line
20:50brehauti found it to be way better analytics than google analytics for my site
20:54brehautthe failwhale was better when it didnt occur inside requests for json
20:57tomojwhat is it, ascii art, or they give you html back, or..?
20:58brehauti can only see the html if i look in the webkit inspector; the page is empty
20:59methodsyea i would think this is basically defmulti for ruby ? https://gist.github.com/d78805b13870b6570a9c
21:01brehautnot quite
21:01brehauttheres only one dispatch function for a multi (put that in your initializer), and then the add_dispatch method takes a value for match not a fn
21:02methodswell my matcher can do anything it wants to test the passed in values and then if it returns true then i call the given body of code... actually that would call every single method that matches .. and each method has it's own
21:02methodstester.. instead of just 1 tester that produces the args to test against
21:02brehautthats more general than a multimethod
21:02brehautand slower again
21:02methodswow that was messy way to say that.. let me try again.. instead of 1 test function that produces the arguments used for dispatching
21:03brehautdispatch is now O(n)
21:03methodshm and it's not O(n) before ?
21:03brehautwhereas multimethods could be much faster O(log n) ?
21:03methodswell yea i mean O(n) because you have n matchers
21:03brehautexactly. you have to test each matcher function until one matches
21:03methodsi can make it work more like clojure's approach
21:03brehautof course
21:03methodsyea but what if you wanted that ?
21:04methods$ ./test.rb
21:04methodsI heard quack
21:04methods:]
21:04brehautmost people would call that a 'rules engine' or something
21:04brehautand you run into clause ordering problems
21:05methodshm
21:05methodswell yea in this case you just run them all
21:05brehauteg, if i added class BlueDuck < Duck; def quack; "blue quack"; end; end;
21:05methodswhat happens if you define a multi method that has the same arguments of something already defined ? does it over ride it ?
21:05brehauti think i screwed that up
21:06brehauti believe so
21:06methodswell adding a class would'nt matter i think what you mean is you added another tester function you run in the problem of which one do you hit first ? and since it's a hash it's not even ordered.. then again ruby 1.9 has ordered
21:06methodshash's
21:06brehauttheres still some ordering on multis i think, but its less significant than having full logic for each test
21:06brehautyeah thats what i meant
21:06methodsyea but you still run into ordering problems in clojure too right ?
21:07brehautits less of an issue when you are testing values
21:07brehautwith comparison
21:08methodshm but why ? i mean it's just based on the order y ou define your matchers
21:10methodswell that example is what i meant earlier when i said instead of using a switch statement
21:10brehautbecuse there is exactly one transformation between arguments and dispatch value. each dispatch value can only have one function associated with it
21:10brehautand its an isa? test
21:10methodscause that lets you add matches later
21:10brehauta switch statement is not late bound
21:18iceydo any of you use amazon's simpledb with clojure?
21:24brehauticey: http://www.clojure-toolbox.com/ lists two libraries for simpledb, rummage and sdb so i presume there are some people using it
21:27iceybrehaut: i'm using a fork of the sdb library from there (https://github.com/bapehbe/sdb) but it's not behaving the way the examples & tests do, so I figured I'd see if there were people using it so I could ask them if I was missing something obvious. Thank you though :)
21:27iceyI'll try out rummage and see if that works a little better
21:30iceybrehaut: by the way, "A brief overview of the Clojure web stack" was amazing
21:30brehautthanks :)
21:51methodshow's that ? https://gist.github.com/21e3aed658edd7b0f785
21:58brehautmethods: still greenspunned
21:59methodsyes I know :] I can't magically add it .. oh wait let me hack up the vm really fast :]
22:00amalloymethods: i wrote a whole vm while you were doing that. decided to call it nop
22:00methodslol
22:00brehautamalloy: is it metacircular?
22:00methodswhat ?
22:01methodslol fill me in here...
22:01amalloyhttp://www.esolangs.org/wiki/Nil
22:02Scriptormethods: http://en.wikipedia.org/wiki/NOP
22:02amalloymy implementation is basically the same but i changed the name to NOP
22:03methodsno matter what defmulti has to run at runtime right ? there is no way to do it at load time cause the arguments can be of any type ?
22:03methodsat any time..
22:03methodsI'm just doing this to see the trade offs or benefits
22:03methodsI'm wondering now how this shiny little class can help my existing code get out of some kind of trap
22:04methodsor spaghetti'd class's as Rich HIckey put it
22:05brehautmethods: once again, if you need late bound decisions over multiple values, then it will help
22:08cemerickI think the ML is teetering on the brink at this point.
22:08cemerick:-(
22:09brehautcemerick: icey was asking about rummage earlier; thats your simpledb lib right?
22:09cemerickyup
22:09dnolen_cemerick: ? seems the same as usual to me :)
22:09cemerickdnolen_: it's actually taken a serious turn downwards in the past 2-3 weeks IMO.
22:10cemerickThere needs to be a designated community manager or…something. I need to go read some Clay Shirky, etc.
22:10cemerickicey: come find me tomorrow, I'm toast for tonight
22:11dnolen_cemerick: really? current crop of threads seem like the usual fare. The only serious downturn was Steve Yegge thread.
22:13dnolen_cemerick: I've long since stopped reading any Ken Wesson post that isn't actually answering someone's question.
22:17Scriptorcemerick: what do you consider to be the discussion going off the rails, just when it goes off topic?
22:18Scriptorwhat about non-clojure talk in #clojure when there's no question being asked?
22:26amalloyhah, fun times. i solved http://4clojure.com/problem/104 with no parens or curly braces
22:31ischyrusWhen I start Leiningen I get this message: "IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character"
22:32ischyruswhat would cause that?
22:37methodshm so clojure is lazy like haskell ?
22:40methodshm the transactional memory reminds me of atomic variables that you can use in device drivers
22:46dnolen_methods: Clojure is not lazy, but it does make heavy use of lazy sequences.
22:46methodsok i guess I'll figure that out later
22:47dnolen_methods: atomic variables are probably more like atoms in Clojure.
22:47methodshm ?
22:49dnolen_methods: can you coordinate changes between two atomic variables ?
22:49methodsnot sure
22:49dekuderpI have a vague problem, and I can't really figure out how to solve it in lisp
22:50dnolen_methods: it doesn't sound like it from the pages of Linux Devices Drivers that google barfed up. sounds more like Clojure atoms.
22:50dekuderpI want to create a function that handles events, but I don't really know how to
22:52amalloy(fn [event] (println event)) is pretty much all you need?
22:52methodsdnolen_: yea idk i know it reduces down to like a machine instruction or something that is atomic ..
22:53dekuderp(fn [events] (call-function (:function-handler (first events) (first-events)) is more of what I want to do
22:53dnolen_methods: yes, an particular instruction is guaranteed to be atomic on that reference. STM is quite a bit fancier - more like DB transaction you can coordinate changes between many references.
22:54dekuderpso the function-handler would be a reference to the function(s) which should be called given the changes that the event represents
22:54methodsyea i mean underneath though it has to use locking anyway right ?
22:55dekuderpbasically I want to make it so that someone else can plop in a new event-type, encode the functions to call in the event-type, and never have to modify the event handling function
22:55dekuderpfor*
22:58methodsbrehaut: obviously you could still use defmulti beneficially without needing to bind it lately ? i mean what if you had a physics lib and defined a bunch of collision types like [:sphere,:plane] I could picture that all being
22:58methodsdone in the same area without needing to late bind it from other places ? or is there something better for that then ? and where does the isa? test ever happen ? based on my implementation i never called anything that was testing
22:58methodstypes .. i simply tested that special = desired value ... but that's not the same as the type of an object ..
23:00methodsdekuderp: something like a basic event system ? event.register("some event name"){ /* code to get invoked on the event */ } .. later .. event.publish("some event name") ?
23:01amalloydekuderp: sounds like you want to talk to methods about using multimethods
23:01methodsdepends on if he wants multiple handlers to listen for the same event
23:02dekuderpyes, I would like multiple methods listening for the same event
23:02dekuderpmultimethods you say?
23:02methodsdoes clojure offer any kind of classes ?
23:03methodsif not from the little I have read you'd want to create a state that holds your events and handlers and then some functions to publish/subscribe
23:03dnolen_methods: multimethods separate hierarchies from dispatch, you can define your own hierarchies w/o involving types. Clojure doesn't do = to match multimethods, it uses isa?
23:04methodsat least that's all i could think of right now and I never wrote 1 line of clojure
23:04dnolen_(derive ::car ::automobile)
23:05dnolen_methods: ^ I've defined a relationship w/o actually creating an actual type.
23:05methodsI don't get where isa? is used though.. (defmulti encounter (fn [x y] [(:Species x) (:Species y)])) that basically looks like it's yanking :Species out of a hash (def b1 {:Species :Bunny :other :stuff}) ..
23:05dnolen_method: you also have deftype/record, but they offer a tiny subset of what you might be used to coming from traditional OO langs.
23:06methodsso clojure supports building blocks then i guess kind of like scheme ?
23:06methods(not that I even know what scheme offers)
23:07dnolen_methods: sort of except that Clojure ships with a lot of meaningful interfaces, you reuse as much as you create.
23:08methodsso where in this implementation would there be an isa? test ? https://gist.github.com/21e3aed658edd7b0f785
23:08dnolen_if _pattern == pattern
23:08methodshm wait a second.. so then what does isa? actually do ?
23:09tufflaxDoes anyone know how I can speed this up? dnolen_, amalloy told me you might know :P http://pastebin.com/bVHRKaKz
23:09dekuderpwait what does "::" represent in clojure so I can google it
23:10jsnikerisHi all. Fairly basic question here. How can I avoid the repitition found in the last few lines of the following gist? e/at is a macro found in Enlive where a series of selector/transformation pairs are written like so: https://gist.github.com/1091232
23:10dnolen_methods: there a lot of hardwire behavior in multifn. Collections needs to be traversed checking isa? on each element. multifn have lot of optimization logic to make this stuff fast.
23:11tufflaxdekuderp A keyword that begins with two colons is resolved in the current namespace (The Reader, clojure.org)
23:11methodsisa? to me sounds like a.class == Something though ? but in this case it looks like it's just testing 2 scalars to be equal ?
23:11amalloyjsnikeris: because at is a macro, the only way to avoid repetition in it is to write another macro that expands into an invokation of (at) that's more to your liking
23:12dnolen_tufflax: sorry not feeling like optimizing code at the moment, but I can tell you that you need type hints for those asets to perform well.
23:12jsnikerisamalloy: ah OK
23:12tufflaxok, dnolen_ :)
23:13dnolen_tufflax: my advice to stop a moment a figure out some minimum operation on arrays, discover what is required to make them fast outside your problem.
23:14amalloydnolen_: one of these days i'll need to write fast arithmetic operations for myself, and then i can stop telling people to ask you
23:14dnolen_tufflax: your code should trounce the Python once you've sorted that out.
23:16dnolen_methods: not isa? looks at the hierarchy, but the Java class hierarchy and a global tag hierarchy (or a custom one if you've provided it)
23:17methodswow I'm confused now
23:17methodsI mean :Bunny to me just looks like a non mutable string or something
23:18dnolen_methods: you can establish relationships between fully namespaced keywords. (derive ::bunny ::animal)
23:18dnolen_(isa? ::bunny ::animal) => true
23:18methodswhat about the case where you want to define a handler regardless of the order of the arguments ? like you want to define the same handler for [:Bunny,:Lion] and for [:Lion,:Bunny] but obviously you want to be able to reference
23:18methodsthe correct one in your handler ...
23:20dnolen_methods: return a set from your dispatch fn, your fn will get the arguments in the right order.
23:20methodsI guess at that point they'll probably just tell you to always order it the same .. or sort it first and define your callbacks in the sorted way
23:20dnolen_methods: you could of course stop speculating and start writing some Clojure ;)
23:21methodsoh , this is bigger though , I'm trying to understand usage of them and how it could help my existing code
23:21methodsi really want to understand the benefits of this approach over classical oo styles and apply it
23:22methodswhen you said , "return a set from your dispatch fn" what did you mean ? It's already returning [(:Species x) (:Species y)] is there a way to sort that quickly or something ?
23:28dnolen_methods: https://gist.github.com/1091247
23:28methods(into #{} [x y])
23:28methodswhat is that ?
23:28dnolen_methods creating a set
23:29methodsso a set has no order basically ?
23:29dnolen_methods: no.
23:29Scriptormethods: right, it's the mathematical definition of a set, an unordered collection of unique elements
23:30Scriptor,(cons 2 #{1 2 3})
23:30clojurebot(2 1 2 3)
23:30Scriptorscratch the unique part
23:31Scriptorwait
23:31Scriptor,(conj 2 #{1 2 3})
23:31clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IPersistentCollection
23:31Scriptor,(conj #{1 2 3} 2)
23:31clojurebot#{1 2 3}
23:31Scriptorunscratch the unique part
23:32dnolen_methods: https://gist.github.com/1091247
23:32dnolen_^ hierarchy w/o types
23:33methodsyea just weird that ::car is never defined or anything
23:34methodsi guess it really doesn't have to be defined ?
23:35methodsI'm just not sure what (derive) would do then besides allowing 1 thing to look like another ?
23:35methodsit wouldn't actually like extend any type of functionality would it ?
23:36methodshm so you could use vectors or sets and define methods for both ? I assume then you need to order your defmethod's from most specific to least..
23:37dnolen_methods: no.
23:37dnolen_you can define them in any order.
23:37scottjmethods: why do you always add a space before your "?" ?
23:37methodsidk I'm nuts..
23:38methodsI guess I like it to stick out
23:38scottjmethods: ok you're pretty consistent about it
23:39methodslol it's funny though cause I type it something like? and then go back and add a space... I guess my brain believes the ? belongs to the sentence not the word.. or I just want it to stand out more or something.. idk..
23:39dnolen_yowza: http://arxiv.org/abs/1107.3539
23:39methodss/something/sometimes
23:39lazybot<methods> lol it's funny though cause I type it sometimes like? and then go back and add a space... I guess my brain believes the ? belongs to the sentence not the word.. or I just want it to stand out more or sometimes.. idk..
23:39methodswhat's up with that ^ ?
23:40scottjyou used s/...
23:40methodsWOW!
23:40Scriptorlazybot detects that and actually does the substitution
23:40methodsyea that rocks !
23:40methodsI'm going to add that to my bot right away .. actually that would be a good plugin in your client perhaps ..
23:40scottjwould be nicer if it highlighted the change
23:41methodsyea you could do that with unicode i think
23:41scottjor just bolding/coloring format strings I think irc supports
23:42methods \u0002
23:43methodsthat's for bold
23:43methodsshould be really easy to add that to the bot http://oreilly.com/pub/h/1953
23:44methodsdoes it also support /g and other options ?
23:45methodswhat about backrefs ? lol .. hopefully it doesn't allow me to inject variables names or call a method in the replacement portion..
23:51Scriptorgoing through the lazybot source, it's...interesting
23:51methodsoh it's public ?
23:51Scriptormethods: yep, https://github.com/flatland/lazybot/tree/master/src/lazybot
23:51Scriptorhttps://github.com/flatland/lazybot is the main repo
23:53brehautScriptor: comparing lazybot and clojure bot is particular interesting
23:54brehauts/e b/eb/
23:54lazybot<brehaut> Scriptor: comparing lazybot and clojurebot is particular interesting
23:54methodsdoes clojure support native regex testing like you might see in perl ?
23:55brehaut(re-seq #"[a-c]+" "aabcedfeaaba")
23:55brehaut,(re-seq #"[a-c]+" "aabcedfeaaba")
23:55clojurebot("aabc" "aaba")
23:55methodscool
23:55brehautfor instance
23:55brehautbut res are not fns (for performance reasons)
23:55methodsI'm trying to remember how to match any character and then right after that match anything except that character... i don't think backrefs are available in the search string right away
23:55methodsfns ?
23:56brehautifn specifically; anything callable like a function
23:56brehaut(map (juxt class ifn?) [inc [] (symbol "foo") :foo "str" #"re" {} #{} ()])
23:57brehaut,(map (juxt class ifn?) [inc [] (symbol "foo") :foo "str" #"re" {} #{} ()])
23:57clojurebot([clojure.core$inc true] [clojure.lang.PersistentVector true] [clojure.lang.Symbol true] [clojure.lang.Keyword true] [java.lang.String false] [java.util.regex.Pattern false] [clojure.lang.PersistentArrayMap true] [clojure.lang.PersistentHashSet true] [clojure.lang.PersistentList$EmptyList false])
23:59amalloy#"(.)((?!\1).)" probably works, methods
23:59amalloy&(re-seq #"(.)((?!\1).)" "aabb")
23:59lazybot⇒ (["ab" "a" "b"])