#clojure logs

2009-12-12

00:02technomancyback when I was all "HAY GUYSE HOW DO U PARSE A STRING?"
00:03hiredmanhyperspec
00:03hiredmanhyperspec?
00:04hiredmanperformance?
00:04clojurebothttp://clojure.org/java_interop#toc46
00:07hiredmanclojure?
00:07clojurebotclojure is cheating
00:08tolstoyHey, that's what my manager, and his manager, and the architect said.
00:12hiredmanclojurebot: twbray is <reply>you have to watch twbray, if you take your eye off him for a second he is likely to blog post
00:12clojurebotc'est bon!
00:12twbrayhiredman: huh?
00:13hiredmantwbray: just making sure clojurebot knows who you are
00:14twbrayclojurebot: Pleased to meetcha
00:14clojurebotPardon?
00:34alexyksomnium: pingy-wingy
00:50skybound_is there anything like prxml that accepts an outputstream/writer? xml/emit seems cumbersome to use
00:55alexykhow do you get a seq from a Java iterator?
00:58_atoalexyk: call iterator-seq on it
00:58alexykok
01:00hiredmanskybound_: emit prints to *out*, and you can bind *out* to whatever
01:02alexykhow do you sort a seq of tuples like (["a" 1] ["b" 2]) in descending order of the numbers?
01:02hiredman,(doc sort-by)
01:02clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."
01:04alexykhiredman: right, I forgot what java Comparator looks like :)
01:04hiredmanforget the Comparator bit
01:04hiredman,(sort-by val '([a 2] [b 3]))
01:04clojurebotjava.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.util.Map$Entry
01:04hiredmangrr
01:05hiredman,(sort-by second '([a 2] [b 3]))
01:05clojurebot([a 2] [b 3])
01:05skybound_hiredman: right :-) thanks
01:06alexykhiredman: almost there!
01:07hiredman!
01:07npmanybody know of any clojure packages or tricks that would help me find a ranked set of indexes within a sequence where a subsequence of values "best fits" within a larger sequence of values. (e.g. someone selects a set of features from a audio/video resource that i extract http://nielsmayer.com/prototype-11-17-2009.jpg .... and then i want to find that same selection in other sequences from other recordings that might not be exactly the same
01:07npm)
01:08alexykhiredman: so sort-by cannot do descending?
01:08Carkh,(sort-by second > '([a 2] [b 3]))
01:08clojurebot([b 3] [a 2])
01:08alexyk,(sort #(> (%1 1) (%2 1)) '(["a" 1] ["a" 2])) ; this works too
01:09Carkhyou need to read the doc with more attention !
01:09clojurebot(["a" 2] ["a" 1])
01:09npm,(+ 1 1)
01:09clojurebot2
01:09npmhm
01:09npmcool
01:09alexykCarkh: how does second > combine together?
01:09Carkh,(doc sort-by)
01:09clojurebot"([keyfn coll] [keyfn comp coll]); Returns a sorted sequence of the items in coll, where the sort order is determined by comparing (keyfn item). If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."
01:09alexykah right
01:09Carkhsee the first line of the doc
01:09alexyksorry I was distracted by java comparator from sort
01:09npmracks brain for which lisp "," syntax is from. CL?
01:09Carkh=)
01:09hiredmanI guess I did tell him to ignore the comparator bit
01:10Carkhnpm : clojurebot lisp, prety nice but you can't defn =(
01:10alexykCarkh: yes, hiredman is to blame for everything good and bad :)
01:10Carkhalexyk : will do !
01:10npmhm, so if it's clojure,how can it prevent me from calling execute in java?
01:11alexyk:)
01:11hiredmanclojurebot: whose job is it to recieve all blame?
01:11clojurebotthat's KirinDave's job
01:11hiredmanclojurebot: whose job is it to prevent npm from executing java?
01:11npmclojurebot how can you prevent me from creating infinite threads and DOSing you?
01:11clojurebot
01:12hiredmanclojurebot: we demand answers!
01:12clojurebotPardon?
01:12hiredmanclojurebot: you heard me!
01:12clojurebothiredman: I'm just giving you a second chance
01:12hiredmanclojurebot: a wise guy, huh?
01:12clojurebota is t
01:13npmclojurebot do you pass the turing test?
01:14hiredmanclojurebot: what about the turing test?
01:14clojurebotwhat is wrong with you
01:14hiredmanclojurebot: tell us about the turing test?
01:14clojurebotthe answer is 42
01:15_atohehe, just got real 12m0.027s / user 182m39.276s / sys 26m25.290s on twbray's widefinder 2 test, with shared clojure hashmaps inside atoms with atomiclongs as values. :-) that beats the java entry and I think I've still got a little room to improve
01:17_ato_mst had some great suggestions, which for some reason make the garbage collector pauses longer but it ends up being faster in the end anyway
01:17hiredmantrashy suggestions
01:17_msthahah yep
01:18cp2I failed the Touring test.
01:18cp2er
01:18cp2oops
01:18cp2:|
01:26polypusclojurebot: what are your passions?
01:26clojurebotwhat is wrong with you
01:42alexykoh my god, running pagerank on twitter shows that justinbieber is #1 by mentions. I needed to look it up. Clojure brings me knowledge!
01:42alexykhe & 1000 girls talking about him.
01:43alexykthank you, Clojure, I needed to program for decades to get to study Ashton Kutcher in detail with your help.
01:46alexykand Britney is only #50.
01:53wavisisa? is backwards...
01:54waviscan't use it with condp
02:23qedalexyk: haha, how are you doing that?
02:23qeda library or something homemade?
02:23alexykqed: clojure + jung2 :)
02:24alexykalthough clojure is a bit slow for pagerank, I'll use OpenMP and good ol' Fortran next
02:24alexykfor that part
02:26alexykI mean even Java is slow for PageRank. Bow before C++, Java!
03:38atifping
05:45angermanc++?
06:13somnium~c++
06:13clojurebotHuh?
06:14somniumclojurebot: c++ |is| just what is a protected abstract virtual base pure virtual private destructor, and when was the last time you needed one?
06:15somnium~c++
06:15somniumhmm
06:15somnium,(+ 2 3)
06:16clojurebotNo entiendo
06:16clojurebot5
06:18somniumclojurebot: c++ is <reply>just what is a protected abstract virtual base pure virtual private destructor, and when was the last time you needed one?
06:19somniumclojurebot: ping?
06:20clojurebotPONG!
09:50interferonare there any built-ins that let you check parameter types?
10:05the-kennyinterferon: Sorry, I don't understand what you trying to do. Can you explain it?
10:05interferoni keep running into problems where i mean to pass an array of maps to a function and, through my own mistakes, i end up passing just the map directly in.
10:05interferonthen i get cryptic NPE's
10:06interferonso for debugging purposes, i want osmething like CL's check-type
10:06the-kennyinterferon: You can do type-hints on function arguments.
10:06interferoni can write it, but curious if it's built-in
10:06interferontype-hints don't check
10:06rhickey,(cast String 42)
10:06clojurebotjava.lang.ClassCastException
10:06rhickeylike that?
10:07the-kennyYou can also use (type ..)
10:08rhickey,((fn [a b] {:pre [(integer? a) (integer? b)]} (+ a b)) 1 2)
10:08clojurebot3
10:08rhickey,((fn [a b] {:pre [(integer? a) (integer? b)]} (+ a b)) "1" 2)
10:08clojurebotjava.lang.Exception: Assert failed: (integer? a)
10:08rhickeyor that?
10:08interferonwow
10:08interferon:pre and :post
10:08interferon?
10:11interferonis that a special case? if you pass a map after the function parameters they're interpreted as contract information?
10:13rhickeyhttp://github.com/richhickey/clojure/commit/0ac482878a1dd520cbee2faa0f5f6ab1082ffa76
10:13rhickeyonly doc is there right now
10:13the-kenny:pre and :post looks really cool
10:13the-kennyNice work :)
10:14interferonthat's great!
10:14interferonthanks
10:16interferonis there any way to get type hints to become assertions?
10:16interferonso if i have a parameter #^String str and i pass it an int, the function throws an exception
10:16interferon?
10:22rhickeyinterferon: you could write a macro to do that, but right now type hints are not runtime assertions
10:22interferonwould you be interested in a patch that checks some special variable *treat-type-hints-as-assertions* when functions are defined?
10:23rhickeyinterferon: no
10:23interferonokay
10:23rhickeyI don't want people to think of type hints as other than that - hints to speed up host interop. Turning them into a type system is a whole different story
10:27interferonfair enough
10:49lambdatronicchouser: you around?
10:51lambdatronicah well, perhaps some other time.
11:01angermanwow, this should have atken less then 10 minutes, and now I'm trying to figure out why clojure calls nth on an Integer.
11:10interferonangerman: throw lots of exceptions to see what's going on
11:11interferon(throw (Exception. (str (type blah) blah ...)))
11:11angermanthat's what I've been doing
11:12angermanbut user$eval__xxxx$fn__xxxx.invoke
11:12angermanthat should be one of my anonymously defined functions
11:13hoeckangerman: that Exception happens often when you try to destructure a number, like: (let [[a b c] 10] a)
11:14angermanhoeck: thanks for the hint. I may have an idea now where to look else
11:15interferondoes clj-stacktrace help?
11:16angermanit's currently runnig and didn't crash yet.
11:16angermanI think it was (let [[a b] some-seq] ...) instead of (let [a & b] some-seq])
11:17angermanhoeck: thanks for pointing out that destructuriing might cause the issue
11:21hoeckangerman: glad I could help, you also may try to (require 'the.ns :reload) the offending namespace, that puts correct source lines into the stacktrace
11:22angermanhoeck: it's a mess. I'm using the slime repl
11:23hoeckangerman: :)
11:59stacktracerwhat's the function that inverts a predicate?
11:59stacktracerI want a non-nil? predicate ... surely I can do something like: (invert-predicate nil?)
12:00tomoj(complement nil?)
12:00LauJensenAnything in contrib for quick'n'dirty directory recursion ?
12:01stacktracertomoj: thanks!
12:01tomojLauJensen: as in, give me all the files in this directory tree in depth-first order? :)
12:02LauJensentomoj: yes sir
12:02tomojit's in core
12:02tomojfile-seq
12:02LauJensenBasically 'find .' returning a vector or such
12:02tomojfile-seq on a File gives you a lazy-seq of Files
12:03tomojstarting with the File you pass and then going in depth-first order
12:04LauJensenSo I have to supply a file and not just a root dir ?
12:04tomojroot dir is fine, they're still Files in java
12:05LauJensenah yes I see
12:05LauJensenThanks
12:05tomojlike (file-seq (java.io.File. "/home/tomoj")) gives me a lazy seq starting with my home dir and then going through every single file inside my home dir
12:05LauJensenyes sir
12:07laughingboyCan anyone here answer some newbie leiningen setup questions?
12:14cp2,(file-seq (File. "."))
12:14clojurebotjava.lang.IllegalArgumentException: Unable to resolve classname: File
12:14cp2,(file-seq (java.io.File. "."))
12:14clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission . read)
12:14cp2:(
12:19qedhmmm, i think today ill spend some time on the packing problem
12:29npm ,(org.apache.commons.io.FileUtilstoFile (URL "file" "" "/etc/passwd"))
12:29npmwell
12:29tolstoyHah. I wonder how clojure bot implements its sandbox?
12:30the-kennytolstoy: Look at the source
12:30tolstoyThere's source?
12:30the-kennytolstoy: http://github.com/hiredman/clojurebot
12:30npm,(+ 1 1 )
12:30clojurebot2
12:30the-kennyhttp://github.com/hiredman/clojurebot/blob/master/hiredman/sandbox.clj
12:31npm,(org.apache.commons.io.FileUtilstoFile "/etc/passwd")
12:31clojurebotjava.lang.ClassNotFoundException: org.apache.commons.io.FileUtilstoFile
12:31npmoh bette
12:31npmr
12:32npm,(org.apache.commons.io.FileUtils.toFile "/etc/passwd")
12:32clojurebotjava.lang.ClassNotFoundException: org.apache.commons.io.FileUtils.toFile
12:32npmwell that's good :-)
12:32tolstoy,(slurp "/etc/passwd")
12:32clojurebotjava.security.AccessControlException: access denied (java.io.FilePermission /etc/passwd read)
12:32npmheh
12:33tolstoyI know nothing at all about that security manager stuff. Cool. Seems worth looking at in some spare moment.
12:33npmi do :-) i'm glad it's working
12:33the-kennyclojure showed me some parts of the java api which I've never seen before
12:33the-kennylike java.net.Authenticator and the security stuff
12:37npmplus access to all sorts of cool useful packages like com.trilead.ssh2.*
12:38npmTODO implement http://lists.xwiki.org/pipermail/users/2009-August/016934.html in clojure rather than groovy
12:49qedanyone have any documentation on reading the java documentation for non-java folks?
12:49tolstoyhah hah.
12:50tolstoyGenerally, look at the "interface" classes, like Map, and in there you'll see "implementing classes" like "HashMap" or "TreeMap" or "LinkedHashMap" and so on.
12:51tolstoyBut, basically, you only use the interface functions anyway.
12:51tolstoyI think that's what I do, aside from looking at actual examples.
13:24Anniepooanybody in the SF bay area, bay area clojure's doing a special thing today
13:25Anniepoowe realized lots of folks were in that 'i need to fiddle and ask questions' state, so
13:25Anniepootoday we're meeting in Panera Bread on Millbrae Av. in Millbrae, hanging out with laptops, coding,
13:26Anniepoosharing knowledge
13:27Anniepoowe're also on Second Life at http://slurl.com/secondlife/Belphegor/4/38/82
13:27cp2you sure you guys dont wanna run over to dc real quick? :D
13:27Anniepooget an SL account, we're there too!
13:30Anniepoowww.secondlife.com - download the software (they have linux) and get free account
13:41the-kennyAnniepoo: Uhm.. why do you advertise second life to us?
13:42Anniepooonly because we're having a clojure meetup there and in the SF bay area
13:43Anniepooand cp2 suggested we 'run over to dc real quick'
13:43AnniepooSL seemed a more practical solution for him
13:45ssiderishello people
13:45tomojyou're having a clojure meetup in SL?
13:46Anniepooyes
13:46tomojawesome
13:46cp2heh =P
13:46ssiderisis this the right place for someone (me) who's learning clojure right now to ask newbie questions?
13:46Anniepoohttp://slurl.com/secondlife/Belphegor/10/43/82
13:46cp2yessir
13:48ssiderisok i'm trying to right something for doing pattern matching for s-expressions (i'm also new to functional programming)
13:48ssideris(defn mToken [x] (fn [b] (= x b)))
13:48ssideristhis would produce matchers matching an exact value
13:49ssiderisi also have this: (defn mAny [] (fn [x] (true)))
13:49tomojdon't you want more than just a boolean answer?
13:49ssiderisi'm aiming low for the time being
13:50ssideristrying to get it to say whether it matches or not
13:50tomojah ok
13:50ssiderisand i can say "match this OR this" using: (defn mOr [f1 f2] (fn [x] (or (f1 x) (f2 x))))
13:50ssiderisand (i'm hoping that) this is for concatenating matchers: (defn m+ [f1 f2] (fn [x y] (and (f1 x) (f2 y))))
13:51ssideris(at this point i'm starting to realize that maybe i should be using pastebin or somthing)
13:51tomojfor concatenation I was imagining something that takes however many arguments
13:52ssiderisgood point, will try and refactor
13:52ssiderisanyway, so I construct this matcher: (def matcher (m+ (mToken "haha") mAny))
13:52ssiderisand I would expect it to match this: (matcher4 "haha" 2)
13:52ssiderisbut i get this: #<CompilerException java.lang.IllegalArgumentException: Wrong number of args passed to: user$mAny (NO_SOURCE_FILE:852)>
13:53tomojyou defined mAny as a zero-arg function
13:53tomojso (mAny) gives you the matcher
13:53ssiderisah!
13:54tomojyou could instead do (defn mAny [x] true) if you just want to use mAny directly
13:54ssiderisok, so I was passing the function rather than calling it
13:54ssideristhis still gets me frequently
13:54ssiderisespecially when trying to do something smart
13:55tomojhmm, seems there's another problem, though
13:56tomojoh, you have (defn mAny [] (fn [x] (true)))
13:56tomojbut true is not a function
13:56ssiderisi think i do need the matcher-producing version of mAny
13:57tomoj(defn mAny [] (fn [x] true)) should work
13:59ssiderisit works! thanks
14:00qedanyone have any advice on improving the performance of: http://devinwalters.com/posts/21
14:00qedIt takes about 30seconds right now
14:02tomojyou don't care about the actual values in the chain, do you?
14:04qedtomoj: i dont believe so
14:05tomojso you can just use an integer as the accumulator instead of a vector, I'd think?
14:05tomojnot sure how much faster that'd make it go
14:05tomojthe fact that step is a function probably doesn't help either, maybe making it inline would help
14:05qedtomoj: do you have any advice for code profiling?
14:05tomojnope :(
14:05tomojI think there are java tools that work for clojure
14:06qedive been interested in learning how to use profiling tools
14:08tomojyourkit is not free :(
14:10tomojwell you can download it but it only works for 15 days
14:10qedI found something... :X
14:11tomojyour code is taking much longer than 30 seconds on my computer :'(
14:11qedyeah this is on 4 cores, 8gb of ram
14:11qed2.66ghz
14:11qedobviously i made some mistakes :)
14:13tomojtook it 493s here
14:13tomojheh
14:13qedlol omg
14:30tomojusing an integer instead cut it down to 260s
14:30tomojI think you probably want to try and avoid function calls on integers, use loop and primitives etc
14:40qedtomoj: good advice
14:40qedtomoj: thank you
14:41tomojnot sure how to do all the arithmetic with primitives though
14:42tomojodd? is bad, and using / is too I think
14:42tomojbit-and inlines but bit-shift-right doesn't
14:45tomojthat apply at the end looks bad to me as well
14:59fliebelIs there a way to make this less verbose? (clojure.contrib.seq-utils/shuffle [:a :b :c :d])
15:00cp2(ns foo.bar (:use [clojure.contrib seq-utils :only [shuffle]]))
15:01cp2(shuffle ....)
15:01cp2alternatively you can use :as as well
15:01cp2(ns foo.bar (:use [clojure.contrib seq-utils :as sutils :only [shuffle]]))
15:01cp2(squtils/shuffle ...)
15:03tomojthat's require, no?
15:18fliebelcp2: thanks
16:34qedAnyone here familiar with compojure?
16:34Carkhyes
17:01the-kennyI want to replace the error-handling with exception in clojure-couchdb with return-values.. but what should I return for an error?
17:01danlarkinthe-kenny: good idea
17:02the-kennySomething like {:error true :cause "text"}?
17:02danlarkinnil?
17:02the-kennyYeah, but it isn't possible to get the cause of the error with that
17:03the-kennyI could also do something like a ref where I can store the errors
17:03the-kenny...but that's not very beautiful in my opinion
17:04danlarkinyeah no that's not optimal
17:05Carkhwhy do you want return codes ?
17:05_atothe-kenny: My preference is nil for "not found" and exception for real errors (like connection problems or malformed requests or whatever)
17:05the-kennyI don't like the exceptions... and some others here too
17:05the-kenny_ato: hm..
17:05Carkhato : what if you found a nil ?
17:06the-kenny_ato: But then you would have to define "not found" ;)
17:07_atoCarkh: maybe do the same thing as Clojure, have an optional argument you can set for not found which defaults to nil?
17:07Carkhchouser made a library with common lisp style conditions
17:07Carkhthough that's is the same as exceptions, only restartable
17:08the-kenny_ato: But couchdb returns some useful informations for an "empty" view, like total document count and such things.
17:09_atohmm. I think Clutch always returns a map.. with like {:rowcount 1234, :rows [...]}
17:09Carkhthe-kenny : so hat are the drawbacks of exceptions compared to the drawbacks of error calls ?
17:09the-kennyYes, that's the return data of couchdb
17:10Carkh*error codes
17:10the-kennyCarkh: Exceptions aren't very "functional".
17:11Carkhwell if you have a pure function, and it raises an exception, you may expect it to always do so
17:11Carkhwhat's not functional in that ?
17:12Carkhi woudn't want to use a library that returns error codes, that means i need to check these at each nested function, or raise an exception myself
17:12Carkhor use monads =/
17:13the-kennyExceptions are way more verbose than error-codes. You can just ignore errors, but you can't ignore exceptions
17:13_atoI tend to be doing a number of different things:
17:13_ato1. getting a single document
17:13_ato2. getting a list of documents
17:13Carkhjust ignore errors ? yuk !
17:13_ato3. doing updates
17:14_atowhen getting a single document I don't usually care about the row count, so nil is fine
17:14_atowhen getting a list of documents, I can return a list (could be empty list). This could have the row count on it as metadata
17:15_atowhen updating I probably want exceptions as not-found doesn't make sense there. For conflicts I probably want two different update functions, one which automatically retries with a pure function (think swap! and atoms) and another that lets me decide what to do with the conflict (eg ask the user or whatever)
17:15Carkhanyways if you want to ignore errors nothing prevents you from makeing a function or macro ignore-errors
17:16the-kennyCarkh: Nothing prevents me from modifying my fork of clojure-couchdb either ;)
17:17Carkh(defn ignore-errors [func & params] (try (apply func params) (catch Exception e nil)))
17:17Carkhheh sure, you're king with your code, i'm just saying =)
17:18the-kennyhm.. I've never thought about metadata for clojure-couchdb
17:19the-kennythe erlang-way would be something like {error, data} and doing pattern-matching on it.
17:19ssiderisguys, say I have a bunch of functions as a list and a list. I want to apply each function to the corresponding element of the list (based on position). Any ideas?
17:20the-kennyssideris: Something like (map #(%1 %2) function-list data-list)?
17:20_ato,(map inc [1 2 3])
17:20clojurebot(2 3 4)
17:20_atooh
17:20_atobunch of functions
17:21the-kenny,(map #(%1 %2) [inc dec inc dec] [1 2 1 2])?
17:21clojurebot(2 1 2 1)
17:21ssideristhe-kenny: yeah, i think that would do
17:21ssideristhanks
17:21the-kennyYou're welcome
17:21ssiderisultimately i'd like to see if they all returned true
17:21ssiderisbut i think constructing the list of results is the first step
17:22the-kennyssideris: (every? true? list)
17:22ssiderisso elegant!
17:22ssideris:-)
17:23the-kennyLisp is very elegant :)
17:23the-kennys/Lisp is/Lisps are/
17:24gbtwell they're very elegant when you know what you're doing, which I don't, but thats why I hang out here :)
17:24ssiderisi'm new to lisp in general, I had tried learning Common Lisp in the past but Clojure really motivates me because I already know the java standard lib
17:28triyo,(into-array ["/xxx" "/yyy"])
17:28clojurebot#<String[] [Ljava.lang.String;@3242c8>
17:28triyohhm, I get java.lang.NoSuchMethodError: org.springframework.util.Assert.noNullElements([Ljava/lang/Object;Ljava/lang/String;)
17:29triyoI thought is said String array of String elements
17:30triyoam I misusing into-array? All I do is pass the (into-array ["/xxx" "/yyy"]) onto the java class through interop
17:31triyothe method of the class expects a String array
17:31nickpadwondering if someone can help me out with some java interop stuff - trying to call a java constructor method Foo(int labels[])
17:32the-kennytriyo: Maybe you want to add the type to the array?
17:32triyohehe, nickpad: I'm asking a similar question :)
17:32the-kennyOh wait
17:33triyo,(into-array ["/xxx" "/yyy"])
17:33clojurebot#<String[] [Ljava.lang.String;@b8229c>
17:33nickpadi've tried (new Foo (int-array [1 2 3]) but that gives me an illegal argument exception
17:33tomojtriyo: hmm
17:33tomojgoogle that exception
17:33the-kennynickpad: You forgot the int
17:33the-kennyoh stop
17:34the-kennyI read the constructor wrong..
17:36triyotomoj: hmm googled, that sounds dodgy.
17:36tomojdo you have multiple versions?
17:36tomojI don't understand the error, I know that "[Ljava/lang/Object;" means an array of Objects, but what's "[Ljava/lang/Object;Ljava/lang/String;" mean?
17:36triyoI used leiningen to download the depenedencies
17:37triyoI'l have a look at the lib/ dir quick
17:38triyoIt means an Object array of Strings
17:38triyonew spring ver has rather a String array of Strings of course
17:39triyoyup I think I see a lib culprit
19:03ssiderishello, I've written this very basic set of functions for matching s-expressions: http://pastebin.ca/1712672
19:03ssiderisand i was wondering whether there is anyway to write something like: (def matcher (m=+ 1 matcher))
19:04ssiderisof course that woudl not work as it is since when def-ing matcher, the symbol matcher is not bound yet
19:04the-kennyssideris: Maybe if you do a "(declare launcher)" above this def?
19:05ssiderishm, no i still get the same error
19:06the-kennyum sorry, I meant (declare matcher)
19:06ssiderisyeah, i got that :-)
19:06ssiderisbut it didn't work
19:08ssiderisalso i think that maybe i dont really want to refer to matcher
19:09ssiderisbut to the function that m=+ produces
19:09ssideriswhich is anonymous anyway!
19:12tomojssideris: I'm confused
19:12_atomaybe: (def matcher (m=+ 1 (fn [& args] (apply matcher args))))
19:13ssideristomoj: about the purpose of the code, or my last question?
19:13tomojthe purpose
19:13tomoj_ato's rendering clears it up a bit
19:13tomojyour (def matcher ..) above confused me, a circular definition
19:14ssideristhe idea is to try and produce a recursive matcher
19:14ssiderisso if (m=+ 1 2) returns true when passed (1 2)
19:14ssideris(def matcher (m+= 1 matcher))
19:15ssideriswould match (1 1) and (1 1 1 1) etc
19:15_atohrmm
19:16_atoI thought it would match (1 (1 (1 (1 ...
19:16_atobut maybe I'm misunderstanding
19:17ssideriserm, possibly, I'm basically borrowing ideas from parser combinators
19:17tomojso, I guess you want a fixed point of (partial m+= 1) ?
19:18ssideristomoj: give a second to read up on partial
19:21mudphoneHiya folks, anyone know where I can find swank-clojure.jar files for download?
19:22ssiderismaybe what i'm asking for is slightly misguided: the main purpose of being able to define matchers recursively would be to able to say "match this multiple times"
19:23ssiderisbut maybe it's better to leave that out and create a few other functions tha implement "match at least once", "optional match multiple times", "match exactly X times" etc
19:23tomojZ combinator works
19:23tomojbut this is probably not the best approach :D
19:23_atomudphone: http://clojars.org/repo/swank-clojure/swank-clojure/1.1.0-SNAPSHOT/
19:23tomojer, Y combinator, but applicative order of course
19:24mudphone_ato: gracias!
19:24mudphoneshould have remembered to check clojars
19:25ssiderisyeah my understanding is that Y combinator is a mythical creature that allows you to do recursion on anonymous functions
19:25ssiderisbut that's all :-(
19:25ssiderissorry, functional newbie as well as clojure newbie
19:25_atoI should add a download link the clojars jar pages so that it's more obvious how to just get the jars without using Leiningen/Maven/Ivy etc
19:26tomojhmm
19:26tomojactually it doesn't seem to work
19:26ssiderisoh ok
19:27ssideriswhat do you think about the approach i described above?
19:27mudphone_ato: swank-clojure is step one for me... then it's on to lein + swank clojure project
19:28mudphonehope that's the right order
19:29tomojssideris: sounds reasonable
19:29tomojbut I'm now going to go figure out how to make the Y combinator work for this :)
19:30ssideriswell let me know if you do!
19:31tomojI think the issue is that this matcher takes arbitrarily many arguments
19:32tomojthat's one thing that puzzles me about your code so far
19:32tomojwhy (m8 1 1 1 1) instead of (m8 '(1 1 1 1)) ?
19:33ssiderisdunno, less parenthesis
19:33ssiderisno good reason really
19:33ssiderisdo you think it would result to cleaner code if I pass one argument?
19:33tomojI think it would make my Y combinator trick easier :)
19:33tomojbut, didn't you say the goal is pattern matching on sexps?
19:34tomojso the argument to a matcher would presumably be a sexp?
19:34ssiderisindeed...
19:34ssiderisok let me change it
19:35ssideriserm just a sec
19:35tomojI don't really know anything about pattern matching, so don't listen to me
19:35ssiderisme neither, this my educational project
19:36ssiderisif I change m=+ to accept a single param, then don't i lose the ability to say:
19:36ssideris(m=+ 1 2 (m_) 4 5)
19:36ssiderism_ being the "any" matcher
19:36tomojwell I wouldn't think m=+ should accept a single param
19:36tomojrather the return value of m=+
19:37tomojso that ((m=+ 1 2 (m_) 4 5) [1 2 3 4 5]) is true for example
19:37tomojbut again, I dunno what I'm talking about. I think making that change actually also removes the need for the Y combinator trick :(
19:38ssiderisok say I write m=+ differently so that it accepts a list
19:39ssiderisI would then have to define amatcher as: (m=+ '(1 2 (m_) 4 5))
19:39ssiderisbut the ' would prevent the evaluation of (m_)
19:39ssiderisso that expression would only produce a half-baked matcher
19:39tomojwell, again, I think m=+ is fine taking however many arguments
19:40tomojthat makes sense to me
19:40ssiderisok, sorry I thought you said otherwise
19:40tomojbut I would think that the return value of m=+ should be a function of one argument
19:41ssiderisah ok, so that would make a difference in the invocation of the matcher, not the definition
19:41tomojright
19:41ssiderisso for (def m7 (m=+ 1 2 (m-regex #"(ha)+") 4 5))
19:41ssiderisyou do: (m7 '(1 2 "iopj" 4 5))
19:41ssiderisok makes sense
19:42tomojI dunno if that's actually better or not
19:42tomojisn't that how parser combinator libraries usually work?
19:42ssideristhe things i've read are for parsing strings
19:42tomojI mean, the parsers accept lists of tokens rather than arbitrarily many arguments
19:42tomojoh, hm
19:43tomojhave you seen fnparse yet?
19:43ssiderisnope
19:43tomojmaybe you might get some ideas from it http://github.com/joshua-choi/fnparse
19:43tomojI still haven't been able to wrap my head around it
19:43ssideristhanks!
19:44ssideristhe paper url is broken
19:44ssiderisi mean the academic paper he's linking to
19:44tomojextra parenthesis
19:45tomojgot href'd wrong
19:45tomojhttp://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.49.8088
19:45ssiderisoh it *is* about parser combinators
19:46ssideriscool
19:47tomojthe code you pasted is the initial steps toward a parser combinator library, right?
19:47tomojI don't even know the difference between this and pattern matching
19:47tomojwith pattern matching do you end up with a map of bindings?
19:48ssiderisyes, i suppose it is, although i was intending to leave it to the level of s-expr, didn't want to use it for strings
19:49ssiderisi think in pattern matching (as per haskell) you provide some values to fill the gaps
19:50ssiderisso the pattern is filled by the data provided
19:50tomojI think I remember seeing something about pattern matching in clojure somewhere
19:53_atossideris: http://gist.github.com/255178 :-P
19:54tomojatoms? :(
19:56_atotomoj: if you can do it without atoms/vars/refs and without changing the structure of the m=+ function, I'll be very impressed
19:57_atoyou need a level of indirection somewhere so you can bind the value of "this" after you close over it
19:58tomojI was imagining m8 as curried
19:58tomojbut if that is the case, its return value has to be a function
19:58tomojwhich is truthy :/
19:59tomojwhich would bring me to fnparse's monads
20:02tomojwe can do (apply m=+ (repeat 1)) but that's cheating I guess?
20:02tomojpretty awesome that we can apply a function to an infinite sequence...
20:02tomojI'm surprised that works
20:03_atoah, yeah that's a nicer way of expressing it. I should have thought of that
20:05tomojI hadn't realized [& args] would accept a lazy seq
20:08tomoj,(take 10 (apply (fn [a b & args] (concat [a b] args)) (concat [1 2] (repeat 1))))
20:08clojurebot(1 2 1 1 1 1 1 1 1 1)
20:08tomojso we have functions which not only can take an arbitrary number of arguments, but which can in fact take an infinite number of arguments.. cool!
20:16ssideriswow
20:16ssiderisso that solves it doesn't it?
20:18tomojI don't really like that solution :/
20:19tomojwell, maybe if you wrap it in m* or something
20:21tomojm+ perhaps
20:21tomojit doesn't work like I'd expect
20:22tomojif we do (defn m+ [x] (apply m=+ (repeat x)))
20:22tomoj((m+ 1) 1 1 1 1) works, but (m=+ 3 (m+ 1) 4) doesn't
20:22tomojit matches 3 1 4 but not 3 1 1 4
20:23tomojactually, I think this is just because m=+ can't be composed
20:24tomojI would expect (m=+ 3 (m=+ 1 2 3) 4) to match 3 1 2 3 4, is it supposed to?
20:24ssiderisyes it is
20:24Intertricitydoes clojure have anythign like python slices?
20:24ssiderisdoes it not?
20:24Intertricity*anything
20:24tomojno, it doesn't
20:24Intertricitylike "blah12342314"[:3]
20:24tomojoops, talking to ssideris, not you, Intertricity
20:24Intertricitytomoj, ah ok :)
20:24tomojIntertricity: but, no, there is no special syntax for that
20:25tomoj,(take 3 "blah")
20:25clojurebot(\b \l \a)
20:25Intertricityoooh that's just as good
20:25Intertricity,(str "hello")
20:25clojurebot"hello"
20:25tomoj,(take 3 (drop 2 "blaarghhglll"))
20:25clojurebot(\a \a \r)
20:25Intertricity:o
20:26tomojalso there's subs for strings
20:26Intertricityok that's the coolest bot I've seen so far xD
20:26tomoj,(subs "blaarghhll" 3 6)
20:26clojurebot"arg"
20:26Intertricity,(subs "blaaarghdfafad" 0 3)
20:26clojurebot"bla"
20:26Intertricitythat would work perfectly
20:27Intertricitywhat about turning string characters into a list I can iterate through?
20:27ssideristomoj: i've changed the code slightly: http://pastebin.ca/1712745
20:27tomojIntertricity: just iterate through them
20:27Intertricitytomoj, ahh ok, thanks :D
20:27_ato,(map identity "blargh")
20:27clojurebot(\b \l \a \r \g \h)
20:27_ato,(apply str (map identity "blargh"))
20:27jasapp,(seq "asdf")
20:27tomojstrings are seqable, so pretty much anything that expects a sequence will accept a string
20:27clojurebot"blargh"
20:27clojurebot(\a \s \d \f)
20:28ssiderisjust to have the matcher from m=+ accept a single param
20:28tomojI think that might fix the problem I just saw
20:28_ato,(apply str (take-while #(.isLetter %) "hello7bar"))
20:28clojurebotjava.lang.RuntimeException: java.lang.IllegalArgumentException: No matching field found: isLetter for class java.lang.Character
20:29Intertricitytomoj, do you know if ikvm's .net support is any good?
20:29_ato,(apply str (take-while#(Character/isLetter %) "hello7bar"))
20:29clojurebotjava.lang.Exception: Unable to resolve symbol: take-while# in this context
20:29_ato,(apply str (take-while #(Character/isLetter %) "hello7bar"))
20:29clojurebot"hello"
20:29IntertricityI have a project I want to use clojure to learn with, but it requires a .net library :\
20:29tomojIntertricity: dunno what ikvm is, and dunno anything about .net, sorry
20:29tomojI think there is a version of clojure running on the CLR, though?
20:30aluinki'm trying to compile a simple app in a subfolder app/hello.clj i'm doing (compile 'app.hello) from the Repl, but continually get classpath errors. anyone got a minute or two to give me a hand?
20:30tomojlots of clojure libraries probably don't work with it, though, but you can write your own stuff
20:30_atohttp://wiki.github.com/richhickey/clojure-clr
20:31Intertricitytomoj, http://www.ikvm.net/
20:31aluinki'm doing what i'm told to do on this page, http://clojure.org/compilation
20:31hiredmancompile?
20:31clojurebotthe unit of compilation in clojure is the namespace. namespaces are compiled (not files). to compile a namspace the namespace needs to be on the classpath and so does ./classes/ (and the directory needs to exist) because clojure writes the class files to that directory. http://clojure.org/compilation
20:32aluinki've exported CLASSPATH=./classes:./
20:32_atoaluink: also make sure you have (ns app.hello) at the top of app/hello.clj
20:32aluinkand yes, classes does exist
20:33hiredmanlisppaste8: url?
20:33lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
20:33hiredmanpastebin somesomething (errors, code, shell commands, etc)
20:34tomojssideris: hmm, I'm seeing new problems
20:34lisppaste8aluink pasted "hello" at http://paste.lisp.org/display/92007
20:35ssideristomoj: i'm all ears (or eyes?)
20:35aluink_ato: see the paste
20:35tomojssideris: try this ((m=+ 3 (m=+ 1 2 3) 4) '(3 1 2 3 4))
20:36tomojoh, wait, ((m=+ 3 (m=+ 1 2 3) 4) '(3 (1 2 3) 4)) works
20:36tomojwhich one is supposed to work?
20:36ssiderisagainst what?
20:36ssiderissorry...
20:36ssiderisyou have the parameter right there
20:37_atoaluink: java -cp clojure.jar:.:classes -Dclojure.compile.path=classes clojure.lang.Compile app.hello
20:37Intertricityhas anyone here played with ClojureCLR?
20:37hiredman:|
20:38hiredmanssideris: what is the exception, how/when do you see the exception and how are you starting clojure?
20:38_atoaluink: otherwise please paste the command you're using and the error
20:38ssideristomoj: well, the first should return false rather than throwing an exception
20:39ssiderishiredman: you mean aluink?
20:39hiredmanssideris: I must
20:39hiredman<-- full of nyquil
20:39tomojssideris: ah, yes
20:40ssideristomoj: it's probably because m=+ assumes the correct amount of tokens
20:40tomojwell..
20:40tomojactually
20:40tomojtry this
20:40tomoj((m=+ 1 2) '(1))
20:40tomoj:D
20:40tomojit assumes it's being given something seqable, anyway
20:40aluink_ato: ok, that worked, but this is what i was doing...
20:40lisppaste8aluink pasted "process" at http://paste.lisp.org/display/92008
20:41ssideristomoj: so the use of map is what creates the problems
20:41tomojyep, it cuts off at the sorter seq
20:41hiredmanaluink: -cp and CLASSPATH are mutually exclusive
20:41aluink_ato: i wonder if it was picking up my export and/or was it that -D that did the trick
20:41hiredmanif you use -cp then CLASSPATH is ignored
20:42tomojso similarly ((m=+ 1 2) '(1 2 3)) is true
20:42aluinkhiredman: ahhh!!!
20:42hiredmanyeah
20:42ssideristomoj: so I should return false if it's not seqable and if the sequences are of different lenghts
20:42aluinki didn't know that, where is that documented?
20:42aluinkman java1
20:42aluink!
20:42tomojssideris: that sounds like it would fix it, yeah
20:43_ato"Specifying -classpath or -cp overrides any setting of
20:43_ato the CLASSPATH environment variable." -- man java
20:43tomojthough you'll be going through the sequence twice and holding the head :/
20:43aluinkto do what i was doing, i should have done -cp clojure.jar:$CLASSPATH
20:44aluinkthat's kinda've annoying, oh well...thanks for pointing that out!
20:45hiredmanclojurebot: -cp and CLASSPATH |are| mutually exclusive
20:45clojurebotYou don't have to tell me twice.
20:45hiredmannow it's documented there
20:48aluinkhow is that info retrieved?
20:48aluinkbetter yet, where can i find docs on working with clojurebot?
20:49ssiderisMEIN FUEHRER, IT WORKS!
20:50hiredmanclojurebot: -cp and CLASSPATH?
20:50clojurebotclasspath is (System/getProperty "java.class.path")
20:50hiredmanhmmm
20:50_atohehe
20:50hiredmanclojurebot: -cp and CLASSPATH
20:50clojurebot-cp and CLASSPATH are mutually exclusive
20:50ssideristomoj: http://pastebin.ca/1712761
20:50aluinkyou kinda have to know to ask that question though right?
20:50hiredmanclojurebot: -cp?
20:50clojurebotExcuse me?
20:50_atoclojurebot: -cp
20:50clojurebotPardon?
20:51_atoheh
20:51hiredmanclojurebot: exclusive?
20:51clojurebotGabh mo leithscéal?
20:53tomojssideris: you'll want to replace seq? with sequential? I think
20:54tomojvectors aren't seqs so ((m=+ 3 4) [3 4]) doesn't work with seq?
20:54ssiderisoh ok
20:54ssideriswhy is that?
20:55tomojlists are their own seqs
20:55hiredmanclojurebot: -cp and classpath?
20:55clojurebot-cp and CLASSPATH are mutually exclusive
20:55tomoj,(let [lst '(1 2 3)] (identical? lst (seq lst)))
20:55clojurebottrue
20:55tomoj,(let [v [1 2 3]] (identical? v (seq v)))
20:55clojurebotfalse
20:55tomojvectors aren't
20:56tomojnor hashmaps, strings, etc
20:56hiredmanwin 11
20:57_ato,(sequential? "foo")
20:57clojurebotfalse
20:57tomojhmm
20:57tomojyeah I just noticed that too
20:57tomojI remember asking this question before, but don't remember the answer -- how do we test for seqability?
20:59chouserthere is a 'seqable?' on contrib, but it's rarely the right thing to use.
21:00tomojis "will this thing work with the seq library" not the right question to ask?
21:01chouserrigh
21:01chouserright
21:01tomojoh, yes, I see you are right in this case
21:01tomojif we did a test for seqability, we couldn't use strings as literals in the patterns
21:01chouserbecause of my complex and persuasive argument.
21:01chouser:-)
21:02chouser*most* of the time if the code is going to choose between two valid actions, you want something more specific than seqability
21:02tomojas it is we can't use lists, and with sequential? can't use vectors
21:03chouserperhaps 'coll?'
21:03tomojwhat all implements Sequential? lists, vectors, ...
21:03tomojhuh, NOT seqs
21:03hiredmannot strings
21:04tomojwell, I dunno what the right test is, then
21:04ssideristhis is so confusing... we need a comparison table
21:04tomoj,(sequential? (seq []))
21:04clojurebotfalse
21:04tomojbut
21:05tomoj,(sequential? (iterate inc 1))
21:05clojurebottrue
21:05tomoj:(
21:05tomojI cast you out, sequential?
21:05_ato,(seq? (seq []))
21:05clojurebotfalse
21:05tomojwat
21:05_ato;-)
21:05_ato,(seq [])
21:05clojurebotnil
21:05tomojooh
21:06tomojok, I welcome you back in, sequential?
21:06tomojso seqs are sequential, that's good :)
21:06qedmaybe this is a dumb question, but....how are colls different from seqs?
21:06BrandonWhello, i've got a quick question about functional programming, if that's okay :)
21:07ssiderisseqs are lazy lists, right?
21:07tomoj,(coll? (seq [1]))
21:07clojurebottrue
21:07tomojwait, what? I thought that would be false
21:07qedlol
21:07tomojPersistentVector$ChunkedSeqs are colls I guess
21:08tomojok, but {} is a coll and {} is not a seq
21:08tomoj(and similarly [] is a coll but not a seq)
21:08qed#{} seems like it wouldnt be a coll
21:08_atopublic interface IPersistentCollection extends Seqable
21:08qedbut i guess ordering really has nothing to do with it?
21:08BrandonWif you want to make a library along the lines of a pdf editor, how would you write a functional library for editing PDFs, if each operation would return an entirely new pdf as per functional programming idioms. Wouldn't that be a lot of memory overhead? I barely know anything about functional programming, I'm just trying to wrap my head around the concepts :)
21:08BrandonWbrb
21:09_atocolls needs to implement count, cons, empty, equiv and be seqable
21:09tomojpresumably you wouldn't write out the entire pdf to disk every time a change is made
21:09tomojif you have some in memory representation of a pdf in terms of persistent data structures, the new pdfs aren't really "entirely" new
21:09qed_ato: they need to implement all of those?
21:09tomojthey can share structure
21:09_atoall seqs are colls
21:10_atoand all colls are seqable
21:10qedbut not all colls are seqs
21:10_atoright
21:10qedok
21:11tomojwhere's the clojure ring benchmark?
21:12chouser~classes
21:12clojurebotGabh mo leithscéal?
21:12tomojI found one in swannodette/clojure-benchmarks but I'm looking for rhickey's
21:14chouserThis may help understand relationships between collection types: http://tinyurl.com/clojure-classes
21:14chouserexcept ... it's a bit out of date and potentially a bit overwhelming.
21:14tomojI think a table would be nice
21:14tomojbut I want to generate it programmatically
21:15tomojs/svg/html/ and it's easy :)
21:15chouserright -- the code is there -- go for it.
21:19qedah, clojure documentation... such fun
21:19tomojqed: are you the one working on that doc wiki project?
21:20qedyeah, well, attempting to, i suck at clojure still, and compojure isn't easy for me, but it's slowly coming along
21:20ssiderisso strings are not sequential?
21:20qedim trying to get a basic structure for the site down
21:21ssideris,(sequential? "hello")
21:21clojurebotfalse
21:21tomojqed: well, good luck, I'm excited :)
21:21tomojssideris: I think this is a good thing for your matchers
21:21qedtomoj: hey man, ill need some help if you're up to it! :)
21:22tomojif strings were sequential, ((m=+ \a \b) "ab") would work, but ((m=+ 1 "foo" 2) '(1 "foo" 2)) wouldn't
21:22tomojqed: is it in git somewhere yet?
21:22qedyou can clone the repo and just start making markdown files with the name of the forms, follow the template and badda bing badda boom
21:22qedya one sec
21:22qedhttp://github.com/defn/cljex
21:23tomojawesome, you bought that domain name as well?
21:23qedi was thinking it might be a better idea to get the docstrings automatically and put them into the files so we dont need to update that part later
21:23qedyeah getclojure.org/com
21:25ssiderishere's a table: http://www.stathis.co.uk/private/seqs.svg
21:26ssiderishave i missed anything?
21:26ssiderisfirefox just shows me the source of the svg!
21:27ssiderissilly firefox
21:27the-kennyOmniWeb does it too.
21:27_atoyour webserver is serving it as text/plain
21:27BrandonWtomoj: that sounds what I was thinking. I had read something about if you program functionally, everything can be passed by reference because the referenced objects will never be changed, and if you do need to change it, there is a cheap way to clone it with a minor modification
21:28BrandonWso each successive change of the pdf would not create an entirely new pdf in memory, but rather take the original pdf and append whatever changes are needed, right?
21:28tomojsomething like that, yeah
21:28ssiderishttp://www.stathis.co.uk/private/seqs.png
21:28tomojif you change it, you get a new object, but it has references inside it to parts of the old object
21:28tomojand since none of these objects can ever change, this is not a problem
21:29_atohttp://meshy.org/~ato/tmp/seqs.svg
21:29tomojwhy doesn't apache know how to serve svg by default? :/
21:29_atossideris: you missed {}
21:30tomojthere are other things I'd like to see on a table as well
21:30tomojcounted? for instance
21:31hiredman,(coll? (seq [1 2]))
21:31clojurebottrue
21:31hiredmanyour table is missling a dot
21:31BrandonWokay thanks for the information :)
21:32BrandonWi'm trying to decide between clojure vs scala in the next language i want to learn
21:32tomojthat sounds like an interesting project, BrandonW
21:32tomojthe pdf stuff I mean
21:32_ato,(counted? '(1 2))
21:32clojurebottrue
21:32ssideristomoj: thanks
21:32BrandonWoh it was mostly a hypothetical question at this point
21:32_ato,(counted? (cons 1 (cons 2 ()))
21:32clojurebotEOF while reading
21:32tomojthe choice between clojure vs scala is trivial, so uninteresting :P
21:32_ato,(counted? (cons 1 (cons 2 ())))
21:32clojurebotfalse
21:32BrandonWjava has pretty good pdf tools already that i'm sure could be used from clojure
21:32_atodifference between lists and cons cells
21:32tomojyeah, but I bet they suck
21:32hiredmanclojurebot: scala {((x: Any, y: Any) => (f: Function2[Any, Any, Any]) => f(x, y))(1, 2)((x: Any, y: Any) => x)}
21:32clojurebotAny = 1
21:33tomojwhat sounds interesting to me is coming up with a persistent representation of pdf documents
21:33BrandonWit was more a question on the inner workings of functional language not slowing you down when you have a large-ish object whose state would be changing a lot (in an oop paradigm, anyways)
21:33BrandonWfrom what i've heard/used of it, it works pretty well
21:33tomojyeah
21:33BrandonWbut of course, it isn't idiomatic clojure, so it could be improved :)
21:33tomojthere is some slowdown, but it's not bad
21:33ssideristomoj: ok, counted?... what else?
21:34ssideris_ato: what does {} do?
21:35tomojdammit, why did I think it was a good idea to ditch the emacs-starter-kit. now swank-clojure-project doesn't even work, and lein-swank is apparently broken atm
21:35hiredman#scala.log:2009:Dec:03:16:41:22 dibblego : dcsobral, FWIW, I've given up on expecting a usable Scala core library, to save disappointment
21:35_atossideris: {} is an empty map
21:35_atoI guess there's also reversible?
21:36_atoand associative?
21:37_atooh and ifn? of course
21:37_ato,(ifn? [])
21:37clojurebottrue
21:37ssiderisi thought all maps started with #
21:37_ato,(ifn? ())
21:37clojurebotfalse
21:37ssideris#{}
21:37_atothat's a set, not a map
21:37ssiderisoh eys
21:37_ato,{:foo 1, :bar 2}
21:37clojurebot{:foo 1, :bar 2}
21:37ssideris*yes
21:37_ato,#{:foo :bar}
21:37clojurebot#{:foo :bar}
21:38_atooh and there's also: sorted?
21:38_ato,(sorted? #{})
21:38clojurebotfalse
21:38_ato,(sorted? (sorted-set))
21:38clojurebottrue
21:38tomojdamn
21:39tomojI was just about to say that the only other one that seemed relevant was sorted? (just grepped the ns-publics in clojure.core for "?" :D)
21:39tomojI mean we have chunked-seq? and vector? and some others, but they don't seem that valuable
21:39ssiderisi'm starting to think that doing this in svg is not such a good idea
21:40tomojI am trying to start a project to do it in html, but can't get a repl up for some reason
21:41ssiderisit would be nice to have another column with a brief explanation of what each test means?
21:43tomojoh, seems we need swank-clojure.jar in lib/ now for swank-clojure project
21:43tomoj:/
21:45j3ff86what does -> do?
21:47j3ff86nevermind
21:49ssideriswhich collection implements Sorted?
21:50j3ff86different from sort?
21:51tomojwell, there are sorted sets and sorted maps
21:51tomojperhaps others
21:52_ato,(sorted? (sorted-set))
21:52clojurebottrue
21:52_ato,(sorted? (sorted-map))
21:52clojurebottrue
21:52_ato,(sorted? (array-map))
21:52clojurebotfalse
21:52_ato,(sorted? (hash-map))
21:52clojurebotfalse
21:52_ato,(type {})
21:52clojurebotclojure.lang.PersistentArrayMap
21:53ssideristomoj: where you going to automate the html table?
21:53ssiderisi mean generating it
21:54tomojyup
21:56ssiderisanyway, here's the updated hand-made version: http://www.stathis.co.uk/private/seqs.png
21:57ssiderishttp://www.stathis.co.uk/private/seqs.svg
21:59tomojthank you for making me learn how to use conkerors "view internally as mime type" feature :)
22:10ssiderishahahaha
22:11ssideristomoj: what would you use for generating html?
22:13tomojwell, I haven't done much of it, but I think I like enlive
22:13quizmehi
22:13tomojthough that might not really count as "generating html"
22:13tomojinstead you have your html out in html files (where it belongs :P) and you apply transformations to it to add in the dynamic stuff
22:13quizmeis it better to write in a functional (stateless) way or object-oriented way in clojure ?
22:14tomojcertainly the former...?
22:15ssideristomoj: the clojure API documentation is not very clear on the data structure test functions
22:15quizmewhy is that ?
22:16tomojwell, it's not easy to write in an object-oriented way in clojure
22:16ssideristomoj: "this tests if the collection implements interface X" doesn't mean much to most people
22:16ssiderisespecially beginners
22:16tomojindeed
22:17tomojcounted? is good
22:17ssiderisare you aware of any texts that explain things a bit more clearly?
22:17tomojnope :/
22:17tomojthe source?
22:17tomojhaving a list of the methods in the mentioned interfaces to go along with the table would be nice
22:18tomojthough from a clojure perspective those should be de-emphasized I guess
22:19_atoquick and dirty version: http://meshy.org/~ato/tmp/colls.html
22:21quizmetomoj: are you writing a tutorial ?
22:21tomojnope
22:22tomojwas going to make a chart like _ato's
22:22tomojyour htmlize is sexy, _ato
22:23ssideris_ato: nice
22:23tomojso lists (and seqs) are the only things that are their own seqs?
22:25tomojthe reduce in the agent-ring function at http://github.com/swannodette/clojure-benchmarks/blob/master/thread-ring/thread-ring.clj seems absolutely brilliant to me
22:25_ato,(seq? (range 10))
22:25clojurebottrue
22:25tomojthough it took me a while to understand it
22:26tomojoh, Conses are there own seqs too
22:26tomojoh, Conses ARE seqs
22:26tomojwell of course they are. now I've confused myself :(
22:27tomojit's a tautology that seqs are the only things that are their own seqs
22:31tomojdoes anyone else thing that reduce is brilliant?
22:32qedlike.. (reduce)?
22:32qedit's just a foldr right?
22:33tomojah, english
22:33qedyou know...foldr...reduce has been around for awhile in various forms
22:33tomojit's a foldl, though, right?
22:33qederr yeah sorry
22:33qedi always mix them up
22:34tomojbut what I meant was, does anyone else think that that reduce is brilliant
22:34qedohhh, that *that* reduce
22:34tomojas in, that reduce over there: http://github.com/swannodette/clojure-benchmarks/blob/master/thread-ring/thread-ring.clj
22:34qedi dont understand agents yet :\
22:34qedbookmarks
22:35ssiderisi think i'm going to bed
22:35ssideristhanks for all your help guys
22:35ssiderisi still have loads to learn
22:35ssiderisbye-bye!
22:35_atoheh, cute
22:36tomojI would've never thought to use reduce there
23:07duncanmla la la
23:44quizmewhat's clojure's way of doing object-oriented stuff?
23:44tomojdoes not doing object-oriented stuff count as a way of doing object-oriented stuff?
23:44tomojmaybe the new stuff in the new branch is what you're looking for, I dunno
23:45quizmeclos stuff
23:45tomojwe have multimethods
23:45tomojfor dynamic dispatch
23:46tomojand the new branch has some new stuff in that area as well