#clojure logs

2009-11-06

01:30Drakeson`just thought you might want to know, slime (from git://git.boinkor.net/slime.git) breaks in Oct 31. The last commit on Oct 30 seems to be fine.
02:38qedWe should forget about small efficiencies, say about 97% of the time; premature optimization is the root of all evil.
02:38qed~ Donald Ervin Knuth
02:38clojurebotI don't understand.
02:47aatifhPing
02:48aatifhHow do i bind multiple values for test in the if-let macro?
02:50hiredmanyou don't
02:50hiredmanclojurebot: ping?
02:50clojurebotPONG!
02:50hiredmanhmm
02:52aatifhsure? The doc says (if-let bindings then else & oldform)
02:53hiredman*shrug*
02:53hiredman,(if-let [a nil b nil] :then :else)
02:53clojurebotjava.lang.IllegalArgumentException: if-let requires exactly 2 forms in binding vector
02:55aatifhclojurebot, right
03:55ordnungs`knock knock?
04:29stephenj(+ 1 1)
04:29clojurebot2
04:30tomojwhy is she doing that???
04:30tomoj(map + [1 2] [3 4])
04:30tomoj(+ 3 4)
04:30clojurebot*suffusion of yellow*
04:31tomojhrmm
04:31tomoj(+ 1 3.1)
04:32tomoj(+ 1 3)
04:32clojurebot4
04:32tomoj(+ 1 4)
04:32clojurebot*suffusion of yellow*
04:32tomoj,(+ 1 +)
04:32clojurebotjava.lang.ClassCastException: clojure.core$_PLUS___4443 cannot be cast to java.lang.Number
04:32tomoj,(+ 1 4)
04:32clojurebot5
04:32tomojach ja
04:33morphlingtomoj: are you expecting (4 6)?
04:33morphlingtry (map #'+ [1 2] [3 4])
04:33tomojuh
04:33hiredmanmorphling: +
04:33tomoj,(map + [1 2] [3 4])
04:33clojurebot(4 6)
04:33tomojjust trying to figure out what clojurebot was doing
04:34tomoj(* 1 2)
04:34opqdonutmorphling: thinking common lisp?-)
04:34clojurebot2
04:34tomojseems it does elementary math upto 4 like the i-ching calculator
04:34hiredmanthat is preposterous
04:35hiredmanonly towel toting hickhickers use i-ching calculators
04:37tomoj(if (> out 4) "*suffusion of yellow*" out)
04:38tomoj:P
04:39tomojI would like to understand clojurebot's guts someday
04:39tomojwriting a bot in clojure sounds fun
04:39hiredmanweird is I swear I removed that three or four times, but somehow while git merging it gets added back in
04:40hiredmantomoj: it would help if I wrote docstrings I suppose
04:41tomojyou can't escape the interconnectedness of things, I suppose
04:42ordnungswidriggaa, clojure can be unreadable (comp #(some #{%} [1 2 3]) :params :some)
04:43tomojhmm
04:45hiredman(some #(-> % :some :params list set) [1 2 3])
04:45hiredman:D
04:46hiredman#(-> % :some :params list set (some [1 2 3]))
04:46ordnungswidriglist set ?
04:46hiredmanset takes a seq/collection
04:46hiredman:/
04:46ordnungswidrigwhy is this needed here?
04:47tomojis (some #{foo} [bar baz]) the idiomatic way to see if a vector contains some value?
04:47hiredmanin your example you put something in a set
04:47hiredman#{%}
04:47hiredman(-> % list set) is equivilent
04:47ordnungswidrigtomoj: yes, that's the idiom I used
04:48hiredman,#{:a}
04:48clojurebot#{:a}
04:48ordnungswidrigmacroexpand?
04:48hiredman,(-> :a set)
04:48clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword
04:48ordnungswidrigbrb
04:48hiredman,(-> :a list set)
04:48clojurebot#{:a}
04:49ordnungswidrigre
04:49hiredman,(-> :a ((partial conj #{})))
04:49clojurebot#{:a}
04:50hiredmananyway, I don't believe there is a function like list for sets
04:50tomojI have sometimes felt there should be a sort of inverse to apply
04:51ordnungswidrigtomoj: which would do what?
04:51tomojso that (foo set 1 2) would give #{1 2} where foo is this thing
04:51hiredmanah!
04:51hiredman#(-> % :some :params sorted-set (some [1 2 3]))
04:52hiredman,(-> :a sorted-set)
04:52clojurebot#{:a}
04:52tomojwell that is peculiar
04:52hiredmanexcellent
04:52ordnungswidrighiredman: now please make it a higher order function in [1 2 3] :-)
04:52ordnungswidrighiredman: ((foo [1 2 3]) 1) -> true
04:53tomojhmm
04:53tomoj,((set [1 2 3]) 1)
04:53clojurebot1
04:53tomoj,((set [1 2 3]) 4)
04:53clojurebotnil
04:54hiredman(fn [x] #(-> x :some :params sorted-set (some %)))
05:11Chousuke,(hash-set 1 2 3)
05:11clojurebot#{1 2 3}
05:11Chousuke:P
05:19tomojChousuke: aha
05:19tomojthat makes it seem much less peculiar
06:19Chousuketomoj: there's also sorted-set
06:20tomojright, sorted-set is what made it peculiar to me
06:20tomojbecause it's different from set
06:20tomojbut hash-set fills in the gap and makes it make sense
06:26Chousukedebugging this reader thing I wrote is getting on my nerves. I'm hitting some bug re-recompiling Clojure with it that doesn't even give consistent exceptions ;/
06:27ChousukeI suspect there's something wrong with syntax-quote because it seems to complain when macroexpanding definline.
06:28Chousukemost of the time it complains about ArraySeq not castable to IFn but then sometimes I get a "wrong number of arguments passed to 'vector?'"...
06:29Chousukethe worst of it is that when I try to execute those definlines using a repl, everything seems to work fine
06:31Chousukeprobably the error is somewhere else and it just triggers on definline :/
06:55stephenj~comparator
06:55clojurebotTitim gan éirí ort.
06:56stephenjThat's not very nice clojurebot
06:56stephenjcomparator
06:56stephenj'comparator
06:58_ato,comparator
06:58clojurebot#<core$comparator__5152 clojure.core$comparator__5152@10c6482>
06:58_ato,(doc comparator)
06:58clojurebot"([pred]); Returns an implementation of java.util.Comparator based upon pred."
06:59_ato~def comparator
07:01stephenjThanks _ato
07:17gerry`(deftype person [] [Runnable]
07:17gerry`(.run [] (println "ok")))
07:17gerry`java.lang.IllegalArgumentException: Wrong number of args passed to: core$distinct-QMARK- (NO_SOURCE_FILE:8)
07:17gerry`
07:18gerry`hello
07:18gerry`how to define deftype without fields?
07:19gerry`and what's "distinc-QMARK..." stuff?
07:19gerry`though reify can work in this case
07:22gerry`anyone here?
07:22stephenjyes, but new so I know less...
07:23gerry`hmm
07:29liwpgerry`: I know nothing about deftype, but distinct-QMARK is a call to (distict? ...) somewhere
07:29liwp,(doc distict?)
07:29clojurebotIt's greek to me.
07:29liwp,(doc distinct?)
07:29clojurebot"([x] [x y] [x y & more]); Returns true if no two of the arguments are ="
07:32stephenj~def deftype
07:34gerry`(displayInterface 'java.lang.Runnable)
07:34gerry`java/lang/Runnable extends java/lang/Object {
07:34gerry` run()V
07:34gerry`}
07:36gerry`(displayInterface 'clojure.lang.IObj)
07:36gerry`clojure/lang/IObj extends java/lang/Object {
07:36gerry` withMeta(Lclojure/lang/IPersistentMap;)Lclojure/lang/IObj;
07:36gerry`}
07:43gerry`liwp: i need look into clojure sources, but i my poor java knowledge seems can't help me :)
07:44_atogerry`: looks like a bug, deftype is only a few days old
07:49AWizzArdrhickey: is in the PAR branch a pfilter?
07:49gerry` hmm
07:49rhickeyAWizzArd: no
07:54AWizzArdMaybe a pfilter could be a nice addition to core :)
07:56rhickeyAWizzArd: patch welcome! but an order-preserving pfilter for vectors is tricky
07:56gerry`i'm testing reify/deftype with asm, reify works great
07:56rhickeygerry`: asm?
07:56gerry`clojure.asm.*
07:57gerry`rhickey: is deftype without fields bug?
07:57rhickeygerry`: yes
07:57gerry`ok
07:57rhickeynot your bug, mine
07:58gerry`;-)
08:12solussdif I memoize a function that takes a ref as an argument and checks the contents of a ref in an 'if', will that check be preserved, or will it always return the same output for a given ref after it is called once for that ref?
08:14cgrandsolussd: will always return the same result for a given ref whatever its actual value is
08:14solussdthat is what i thought it should do, but it doesn't appear to be working that way.. hm
08:15cgrand,(let [i (memoize deref) a (atom 1)] (i a) (reset! a 2) (i a))
08:15clojurebot1
08:16rhickeygerry`: fixed - was bug in case
08:16gerry`great
08:20rhickeygerry`: one sec - breakage
08:21_atohehe, now it *only* takes no fields :)
08:23rhickeyok now fixed
08:24rhickeysomeone's writing case/refify/deftype/defclass tests to contribute, right?
08:34gerry`ok,now it works, rhickey: thx for good job
08:35chouserI don't think we have a 'new' branch for contrib.
08:35rhickeychouser: current contrib works with new, I test before each checkin
08:36rhickeyobviously it doesn't have any new-specific code
08:36rhickeybut tests for reify et al can go right into core
08:37rhickeyare you thinking about converting proxy to reify, defstruct to deftype, etc?
08:37chouseroh! no, I simply forgot that clojure's tests were no longer in contrib. sorry
08:38chouserneed more tea, apparently.
08:39chouseris proxy on the chopping-block? defstruct? Even if their not, using those tests as a starting point may not be a bad idea.
08:39gerry`proxy works with inherit class ,how can reify do that?
08:39rhickeychouser: I'm trying to stay away from chopping block, but that's a good idea
08:39rhickeygerry`: reify can't
08:43gerry`so reify can't replace proxy,right?
08:43rhickeygerry`: not everywhere
08:43chouseronly for well-designed APIs
08:44chouserClojure is opinionated. :-)
08:44rhickeychouser: fighting the good fight - thanks :)
08:44gerry`ok
08:45gerry`interfaces + data = clojure ,not include classes
08:47gerry`is my understanding right?
08:48rhickey+ protocols, will be more important than interfaces
08:48rhickeybut in the same space
08:48gerry`thx
08:54rhickeyI had been thinking about (implement AProtocol AType fn-map), but now think it might be more convenient to implement multiple protocols in a single place (___? AType AProtocol fn-map BProtocol fn-map ...)
08:55gerry`but due to java interop,and reify is faster than proxy, reify support superclass may be one of choices,.java interop shouldnot be punished by bad API :)
08:57chousergerry`: and even a good Java API can't provide implementations to inject via macros or whatever becomes the Clojure way -- inheriting implementation may be the only choice.
08:58chousergerry`: so, I believe an uber-proxy is planned, though I don't understand the layers under deftype/defclass/reify enough yet to know where it fits in there
08:58lisppaste8rhickey pasted "name this" at http://paste.lisp.org/display/89891
09:00rhickeychouser: it basically means a painful and huge hack to the reify/deftype underpinning to support superclass, super ctors, ctor bodies, super method access, protected access etc
09:00chouserrhickey: yeah, that's sorta what I was afraid of. A shame to mess up perfectly good code that's already there.
09:01rhickeydoing it in the current Java compiler is something I don't want to spend my time on
09:01chouserah
09:01rhickeywith cinc, and knowing the requirement in advance, we can probably structure things so reify and proxy share code
09:05rhickeymixins as ordinary maps of names to fns is going to be fun
09:07chouserprovide, support, satisfy, fulfill
09:07chouserwill this be the primary interface to implement a protocol(s) for a specific type?
09:08rhickeyI think so, since it can do one as easily as n
09:09rhickeythe notion of satisfy might be derivable (still pondering protocols on protocols and bridges), so this should be more concrete
09:18gerry`impl? achieve? deploy? assemble? compound?
09:19rhickeymaybe extend?, as there could be many independent (extend X ...) for and X
09:19rhickeyfor any
09:20rhickeyof course that's a very different meaning from Java's X extends Y
09:20rhickeyor maybe not
09:21chouseralmost a pun
09:22chouserat first you extend A by providing Foo (extend Foo A)
09:23chouserthen you extend B by providing Foo and also extend Foo itself (extend Foo B)
09:24rhickeychouser: In Java, extends is more about "adds stuff to" then extending an interface to reach new types
09:25rhickeybut none of this English is very precise
09:25rhickeyI think of it as extending the type to support more protocols
09:26cgrandsupplement?
09:26rhickeycgrand: that's the idea
09:27rhickeyI'm not concerned about the JAva overlap here
09:27chouserin a grid of all types (y axis) and all protocols (x axis), each map in a 'extend' form fills in one cell.
09:27rhickeyyes
09:28rhickey:)
09:29rhickeyif only it were that simple - you should see my current omnigraffles - when interfaces and inheritance, and potential protocols-on-protocols come into play it gets tricky
09:31rhickeyI asked my wife to email me one of these diagrams the other day and she gave it the subject line: Spaghetti
09:32froog:)
09:32rhickeyso maybe we should call it 'toss'
09:32chouserheh
10:52fradiavaloHow do I slice strings in clojure? For eg in python I can do "abcde"[:-2] to get abc
10:54tomoj,(doc subs)
10:54clojurebot"([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
10:54tomojno negative indices I guess, though
10:55fradiavaloAh, that is really what I am after, to get everything but last 2 characters
10:55tomojwell
10:55tomoj,(let [s "abcde"] (subs s 0 (- (.length s) 2)))
10:55clojurebot"abc"
10:55tomojguess you can write a little wrapper around that if you want
10:56eevar2fradiavalo: you could also use any of the functions which work on seqs
10:56eevar2or the java String api
10:56tomojis there something which drops n from the end of a seq?
10:56fradiavaloI think seq functions might help here, let me see
10:57tomojwell, (butlast (butlast aseq)) I guess...
10:57tomojbut turning a string into a seq and then back into a string seems strange to me just to chop off two characters
10:58tomojsubs just uses .substring
11:00fradiavaloyeah, I can't seem to find an elegent way to do this
11:01tomojon my computer subs is like ten times faster than doing butlast twice
11:01tomojwhat, you don't want to ask the string for its length?
11:02tomojas far as I know java strings have no support for python-style negative indices, so asking the string for its length is the only way
11:02fradiavaloI could write a function along the lines you suggested, but I was hoping I could do without it
11:02tomojwell, you can :)
11:02fradiavaloIn general it would be nice to have this work for all sequences
11:02tomojeven if it did work for all sequences, doing it the sequence way is lots slower than doing it the string way
11:04fradiavalotomoj: true, could one write a multimethod here to choose different implementations?
11:05tomojguess you could, but I don't really understand why you would want to
11:06fradiavaloJust to have a general function which works across all seqs or seq like objects
11:06tomoj#(butlast (butlast %)) works
11:06tomojbut is (subs foo 0 (- (.length foo) 2)) too ugly, or..?
11:08hiredmanclojurebot: ping?
11:08clojurebotPONG!
11:09rhickey(deftype Foo [a b c])
11:09rhickey,(deftype Foo [a b c])
11:09clojurebotjava.lang.Exception: Unable to resolve symbol: deftype in this context
11:09fradiavalotomoj: your soln is good, I am just being finicky
11:28cemerickrhickey: Everything's been gone swimmingly since yesterday morning. There was a bit of nip and tuck here and there because of the dashed-names, but everything we have is now using the HEAD of the new branch.
11:29rhickeycemerick: great! I had a question for you - had you/are you using the accessor fn capability of defstruct?
11:30cemerickrhickey: yes, we still have one struct still, which is tied up with our crazy struct/genclass macros. That won't last though, at which point we'll be struct free.
11:30cemerickand, to answer your question, yes, struct accessors are used there
11:31rhickeybut were you using accessors and have you provided similar things for your deftypes?
11:32cemerickoh, I see what you're getting at. We were using accessor fns as the targets of gen-class getter method impls -- with field access, that's clearly unnecessary.
11:33rhickeyok, because leaving any wrapper around (:field x) will seriously diminish the benefits of the keyword call site caching I put in. If you are using (.field x) directly it's moot
11:34cemerickright. We have those set of interfaces that define simple .fieldname getters for various slots. Certainly no need for separate accessor fns there.
11:38cemerickThe only similar thing that exists now are some accessor fns that dynamically unpack slots. e.g. so you can use the same bounds fn to get the value out of any Bounded (our interface that defines a .bounds getter method), a map (or deftype/defclass now) with a :bounds slot, and have it automatically deref the result if necessary. I'd like to get rid of that mechanism, but it's going to take a while to unwind that -- and it's only used for ~5 slots.
11:45chouserslightly better layout for iphones now at http://clojure-log.n01se.net/
11:45cemerick"I don't need no stinkin' youtube on my phone, I need #clojure log files!" :-D
11:45chouserso true!
11:46hiredmanthere're not #clojure logs, there're #clojure: The Definitive Reference
11:46chousereach day is still way too long now. I need some kinda of intra-day navigation.
11:46hiredmanthey're
11:46hiredmangood loard
11:46chouserhiredman: so true!!
11:47chouseralthough it's been months since I gave up reading the overnights :-/
11:48hiredmanI glance over the scroll back looking for rhickey
11:49chouseryeah, that's one option for the intra-page. direct links to rhickey posts.
11:49hiredmanhaha
11:49rhickeya summary of questions asked would be nice
11:49hiredmanyeah
11:50hiredmanDialogues with the Benevolent Dictator
11:52KjellskiHi there...
11:54KjellskiIs there any way to alias a java import? Like (ns de.kjellski (:import (javax.sip) :as foo)) ?
12:00fradiavalo tomoj: where did you import butlast from? str_utils2.clj?
12:01tomojfradiavalo: it's in core
12:01tomoj,(doc butlast)
12:01clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
12:02chouserKjellski: alas, no. The best you can do is use import and then refer to just the classname part instead of requiring the whole package.
12:02fradiavalotomoj: Oh yeah, I saw another one in str_util2.clj
12:03fradiavalo"Returns s without the last n characters. Returns an empty string
12:03fradiavalo if n is greater than the length of s."
12:03fradiavalo(butlast "ABC")
12:03fradiavalooops wrong window, sorry
12:03tomojoh, cool
12:04tomojsource is pretty much the same thing
12:05tomojexcept they use count and check to make sure you don't try to take too much
12:05tomojtake too much off I mean
12:05fradiavaloIt also works with last n characters
12:05tomojI mean same thing as (subs s 0 (- (.length ......
12:06fradiavaloAlso I wonder why all the underscored filenames are converted to hyphens for import?
12:06tomojcus hyphens are more lispy
12:06hiredmaneh?
12:06chouserbecause underscores are ugly and hard to type
12:06hiredmanfor import?
12:06patrkriswhere do I ask about VimClojure-related stuff?
12:07chouserpatrkris: right here, though it works best when kotarak is around
12:07hiredmanthis is as good a place as any
12:07chouser~seen kotarak
12:07clojurebotno, I have not seen kotarak
12:07Kjellskichouser : Thanks.
12:07patrkrischouser: ok, thanks
12:07hiredmanI wasn't aware that import also did the name munging
12:08chouserhiredman: I assume he means use|require
12:08hiredmanfradiavalo: well?
12:09fradiavalohiredman: so why not have hyphenated filenames?
12:09hiredmanfradiavalo: hyphens are not legal in java classnames/package names
12:09Kjellskichouser : uhm, nope... I need to import a few things for an sip stack... and just wondered what to do instead of typing all imports... thought I could "alias" javax.sip as sip or so...
12:09fradiavalohiredman: Ah okay. Thanks, that makes sense.
12:10hiredmanreally?
12:10chouserKjellski: sorry, by "he" I meant fradiavalo -- I should have specified.
12:10hiredmanI mean of course it does!
12:10Kjellskichouser : okay... ^^ nevermind...
12:11fradiavalochouser: yeah, you are right. Sorry for the name mangling
12:11fradiavaloI am still getting my head around (import use require)
12:17hiredmanhttp://lambda-the-ultimate.org/node/3673
12:19chousermacros
12:19chouserwell, probably not, but it's my go-to answer
12:20hiredmanexcept neither haskell nor erlang have those, yes?
12:21chouserright. which is why it's the next order of magnitude
12:21hiredman:P
12:21chouseractually, template haskell is all there for macros. But the static typing requirement increase the complexity of writing them quite a bit it seems.
12:28chouserI have a list of expressions, each with a logical name. I'd like a seq of the names of the true ones.
12:29cemerickman, it's taking me a while to get my web dev sea legs back :-/
12:29chouser,(map first (filter second {:foo true, :bar false}))
12:29clojurebot(:foo)
12:29chouserhm. I guess that's not too bad.
12:30hiredmanclojurebot: web dev is the worst dev
12:30clojurebotIn Ordnung
12:32cemerickI'm half-tempted to throw my hands up and bust out JSPs, just because that'll come flowing back in a cinch from 8 yrs ago. :-P
12:33KjellskiHow can I do someting like --> new SipFactory.getInstance.setPathName("nist.gov");
12:34chouserKjellski: that doesn't need to be getInstance() ?
12:35Kjellskichouser : Couldn´t I combine the two in one row? Actually it´s getInstance() and in the next step setPathName ...
12:36hiredman->
12:36Kjellskichouser : misunderstood you, sorry... yes it´s a method call...
12:36hiredmandoto
12:36hiredman..
12:36Kjellski,(doc ->)
12:36clojurebot"([x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
12:36hiredmanetc etc
12:36chouser(-> SipFactory. .getInstance (.setPathName "nist.gof"))
12:36Kjellskichouser : Thanks!
12:38hiredmanyou might need some parans around SipFactory.
12:38chouserhiredman: are you doubting ME!?!?!!!?
12:39chouserer, I mean, hiredman's right.
12:39chouser:-)
12:39Kjellski*grin* ^^
12:39djorkclojurebot: web dev?
12:39clojurebotweb dev is the worst dev
12:39djorkI see
12:39Kjellskiclojurebot: hiredman
12:39clojurebothiredman is lazy
12:40Kjellskiheh...
12:40Kjellskiclojurebot: kjellski
12:40clojurebotHuh?
12:40KjellskiNoooooooooo... how dare you ...
12:41Kjellskihiredman : actually I´m reading a lot of the clojurebot sources to dive deeper... thanks for the sources...
12:49djorkKjellski: good move. That and clojure.contrib.
12:49djorkclojurebot: clojurebot
12:49clojurebotclojurebot is amazing
12:49hiredmanKjellski: keep in mind that code is a form of expression, and reading a lot of code by one person is rather one sided
12:51djorkclojurebot: windows
12:51clojurebotI don't understand.
12:51djorkme either
12:52Kjellskihiredman : of course, but I think starting with something not as abstract as clojure.contrib is easier for me...
12:52st__would anybody be able to provide help re. Emacs & swank-clojure-project ?
12:52st__AquaMacs, to be exact
12:53Kjellskist__ : I suggest you to just ask and look who´s responding...
12:53st__If I try to run the elisp function to set my classpath, I get a prompt that I can't get out of ? directory completion doesn't work, and <RET> doesn't work, either
12:54st__(apologies if this is a mere Emacs question; I've never seen this before)
12:54djorkC-g doesn't get out of it?
12:54Kjellskist__ : and now I can tell you, that I have no clue... sorry...
12:55st__C-g sort of gets me out of it, but the minibuffer still has it
12:55st__and I can't use the function, which means I can't really use Emacs :-(
12:56st__any other hint to set the classpath would be appreciated, too
12:57technomancyst__: what's the "elisp function to set the classpath"?
12:57technomancyyou should be able to just use setq.
13:10KjellskiShould I use doto also for member methods that return things?
13:10chousernot if you want to be able to use the returned values.
13:11KjellskiAnd what if I want to use them?
13:12KjellskiI want to call a memberfn of a javaobject that has attrs...
13:13KjellskiWould this be okay? (.. sipFactory (.createSipStack "args")) looks like doubled expression of that is a memfn...
13:13chouseror just (.method obj "args")
13:15Kjellskichouser : Oh my... thanks again... I need a say thanks to one of you button...
13:17chouserKjellski: don't bother. I can assume you're thankful. :-)
13:18Kjellskichouser : thanks. *grin*
13:38KjellskiAnyone a quick link to a complex proxy example?
13:49AWizzArdHow can I find out if an object O is a (deftype Foo [x y])?
13:49chouser(= (type O) ::Foo) ?
13:50AWizzArdok
13:51AWizzArdWill that soonish work with intance? or isa??
14:04ambientyeah, i'd need a good tutorial for complex proxies also
14:04ambienti just can't quite grok them
14:06chouserhow complex? there's one in contrib lazy-xml
14:08ambienti still feel like im shooting ducks with a blindfold on
14:08ambienthow do i define a callback function types in a proxy?
14:10ambientim trying to convert this into clojure: http://code.google.com/p/jrtaudio/source/browse/trunk/examples/src/OscillatorBank.java
14:10ambientto learn how to use jrtaudio
14:14Kjellskiambient : I don´t see where you need a proxy there...
14:14ambientaudio.openStreamOut(new OscillatorBank()); where OscillatorBank containst a callback function to generate the audio output
14:16ambientit's calling a java class, and i dont know how to do that other than proxies
14:16ambientjava class, that i'm supposed to construct
14:17ambientim open to suggestions :)
14:17KjellskiWhat interface is the callback in? Or is there none?
14:17ambientits a JNI wrapper for a C++ class
14:18ambienthttp://www.music.mcgill.ca/~gary/rtaudio/
14:18KjellskiHmmm... I thought that with proxys you could just _implement_ things from interfaces... but I´m pretty sure I´m wrong...
14:19ambientwell i have no clue what to do with this, that's why I'm asking. I've tried to browse the documentation and the web but still unsuccesfully
14:19ambientthe only way currently for me to do this is to write something and see if it works, write something new, etc...
14:19KjellskiWhat about defining your own interface with excatly h
14:20Kjellskithat method signature and implement that in a proxy to be set in the function call?
14:20ambientyou mean write some java?
14:21Kjellskiambient : japs, but that would suck like trial and error right?
14:21ambientwell i could probably do it with java, but i'd rather not write any java because the goal in this project for me is to do it with 100% clojure
14:22jasappI'm probably missing something here, but what's wrong with gen-class and compile?
14:22ambientjasapp i've still yet to look into that deeper, because i thought this could be done with proxies
14:22jasappahh
14:23jasappit's not bad at all
14:23jasappprovided compiling stuff ahead of time doesn't pose a problem
14:24ambienthmm, if it can be done from emacs, i suppose it doesn't ;)
14:24jasappheh, is there anything that can't be done from emacs?
14:24ambientwould a simple C-c C-k work?
14:25jasappI've never figured out where emacs actually puts the class files
14:25ambientanyhow, back to reading stuff about gen-class, thanks guys
14:25Kjellskiambient: , in the JRtAudio.java file it looks like that openStreamOut is just getting an Object type as the parameter... maybe it would be enough to just throw an Object with callable interface in there... and that could be done with writing a proxy for the callable interface...
14:26ambientKjellski ok, thanks
14:26Kjellskiambient : http://code.google.com/p/jrtaudio/source/browse/trunk/src/JRtAudio.java
14:57qed'lo
14:58qedI need some help building a proper prime sieve -- I need to find the sum of all the primes below 2 million for project euler #10 -- I've seen some examples of prime sieves but I simply am not advanced enough to be able to take their code and claim I know what's going on
14:58qedIf it's not 100% lazy or efficient I don't really care
14:58qedI just need something that will work
14:58ambienthttp://paste.lisp.org/display/69952
15:01qedamb is that for me?
15:01ambientyes
15:02Kjellskiambient : could I take that too? ^^
15:03qedambient: why the initial (let [n (int n)]?
15:03ambientenforcing types
15:03qedah
15:03ambienti don't know, i didn't write it, rhickey did
15:03ambientreflection is the performance killer
15:04tomojseems weird that you'd do the reverse list trick
15:04tomojreverse is linear time for a list, isn't it?
15:04ambientunless you have a doubly linked list ;)
15:04chouserthat's not just avoiding reflection, it's using a primitive local
15:05Kjellskichouser : whatever you say: amen.
15:05Kjellskichouser : In other words, what does that mean?
15:06notallamai just did a prime generator in haskell a little while ago. i did it in clojure first, but i don't know where i put it. http://pastebin.com/me4e71f3
15:07KjellskiWhat about the Java probableNextPrime from Java-Math or so...?
15:09tomojI wonder if generating the primes efficiently requires you to store them all in memory at once
15:09ambientnope
15:09ambientyou can keep just about 10 in memory when generating more iirc
15:09tomojI think I used a next-prime thing which went off and checked each successive number for primality, so that you didn't have to store them all
15:09tomojbut that was slow
15:10chouser~primes
15:10clojurebotGabh mo leithscéal?
15:10chouser~sieve
15:10clojurebotsee the genuine sieve of eratosthenes
15:11chouser~genuine sieve
15:11clojurebotsee the genuine sieve of eratosthenes
15:11chouser~genuine sieve of eratosthenes
15:11clojurebotsee the genuine sieve of eratosthenes
15:11chousersheesh
15:11chouser~the genuine sieve of eratosthenes
15:11clojurebotthe genuine sieve of eratosthenes is http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf
15:13qedooooooo this is neat
15:13qedchouser: im sure you've probably solved this one
15:14qedhow did you do problem 11 in proj. euler -- the one where you have a 20x20 grid and you need to find the greatest product of 4 adjacent numbers up/down/left/right
15:14qedhow did you represent the grid in clojure?
15:14chouserno, the genuine sieve was too much for me. :-)
15:14qedchouser: haha i doubt that :)
15:14notallamathat haskell code i posted is either the same as that article, or very close.
15:15ambientqed you could represent it just as a 1-d array
15:15ambientqed up=-20, left=-1, right=1, down=20
15:15chousermy solution for 11 uses a vector of vectors
15:16notallamathat grid problem sounds like a job for comonads. i'm still not entirely sure what a comonad is, but i'm starting to recognize where you can use them.
15:17tomojI had a vector of vectors too
15:17tomojand then a direction is a function on a pair
15:17tomojand get-in grabs a value from the grid
15:17qedclojure doesnt like numbers as 0n, does it?
15:17qedlike 08
15:18hiredman,08
15:18clojurebotInvalid number: 08
15:18chouseroctal
15:18hiredman^-
15:18chouser,10
15:18clojurebot10
15:18qedahhh
15:18chouserer
15:18notallama,07
15:18clojurebot7
15:18chouser,010
15:18clojurebot8
15:18Kjellskihuh?
15:18Kjellski,090
15:18clojurebotInvalid number: 090
15:19ambient0 is a prefix for octals
15:19ambient0-7
15:19Kjellski,0010
15:19clojurebot8
15:19Kjellskigot it... thanks...
15:19ambient,0xFF
15:19clojurebot255
15:19qedso is there a way to use the grid they provided
15:19qedwithout running some regex or something on it
15:20ambient,0xCAFEBABE
15:20clojurebot3405691582
15:20notallama,(bigint "08")
15:20clojurebot8
15:20qedah-ha
15:20chouser,(class (bigint "08"))
15:20clojurebotjava.math.BigInteger
15:21notallama,(Integer/parseInt "08")
15:21clojurebot8
15:21chouser,(class (Integer. "08"))
15:21clojurebotjava.lang.Integer
15:21ambient,(int "08")
15:21clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Character
15:21ambient:(
15:21Kjellski,(int 08)
15:21clojurebotInvalid number: 08
15:21Kjellski,(int 07)
15:21clojurebot7
15:21Kjellski,(int 017)
15:21clojurebot15
15:21qedso i have this grid -- my first intuition is to use map #(int %) my-grid-which-contains 08
15:22qedbut that's not working
15:22qederr not int, bigint
15:22tomojhmm
15:22tomojI wonder how I got my grid
15:22tomojI found my old solution and I stripped off the extra 0 somehow
15:22notallamaqed: Integer/parseInt will work too, and give you an int.
15:23qednotallama: how would you map it across a list or a vector though?
15:23chouser,(map #(Integer. %) (re-seq #"\d+" "08 02 22 97 38"))
15:23clojurebot(8 2 22 97 38)
15:23tomojnice
15:23qedwhoa -- that's cool
15:23qedthanks chouser
15:24ambient,(frequencies "feoifoenfoeijvoiejf")
15:24clojurebotjava.lang.Exception: Unable to resolve symbol: frequencies in this context
15:24ambient:(
15:25duncanmdum de dum
15:26ambient,(clojure.contrib.seq-utils/frequencies "dum de dum")
15:26clojurebot{\e 1, \space 2, \m 2, \u 2, \d 3}
15:29Chousukethis is not fun anymore :(
15:30notallamawhat isn't?
15:30ChousukeI'm writing a reader, and as far as I can tell, my reader produces identical output to Clojure's, and still compilation fails
15:30Chousukeit also fails with a completely mind-boggling error
15:30jasappmaybe I should write a reader
15:31notallamayou're writing a reader too?
15:31jasappit seems like the popular thing to do
15:32qedthat movie "The Reader" only had me thinking about lisp the whole time
15:32ambientheh :)
15:32ChousukeIt for some completely ???"#?€? reason tells me that something is passing wrong arguments to a certain function but all debug prints show completely sane inputs...
15:33Chousukein the inputs look identical to what LispReader produces.
15:33Chousuke-in
15:33notallamadid you try (= (read-str blah) (your-read blah)), just to make sure?
15:33chouserChousuke: you're comparing metadata too?
15:33Chousukehmm, I haven't tried that actually.
15:34chouser= won't
15:34chouserof course
15:34ambienti remember the time when i had an extra space in my XML build file which completely broke my whole project
15:35Chousukehmmh.
15:35jasappI had similar trouble with some xml I'm working on
15:35jasappI ended up having to call trim on almost all my strings
15:35jasappbut printed, it was annoyingly the same
15:35Chousukeit'll be difficult to compare the two readers :/
15:36jasappwhat are you writing your reader in?
15:36ChousukeClojure
15:36Chousukeof course :P
15:36tomojso will your reader someday read itself? O_o
15:36jasappnot going the java route?
15:36Chousukethat's what I'm trying to make it do.
15:37tomojthat kind of thing blows my mind
15:37Chousuketomoj: I can use Clojure to compile the reader and then recompile it once, but a second recompilation using the newly produced reader blows up.
15:37ambientwonder how easy it would be after cinc to port clojure for eg. running on top of LLVM
15:38Chousukealso it compiles contrib just fine, and all tests pass save for one which for some reason blows up the stack
15:39qedyou want to conj onto vectors right?
15:40qedoops nevermind
15:42notallamaambient: you'd have to get defclass and such doing sensible things on llvm, so i'm thinking it'd still be pretty tough.
15:43ambientyes, the java interop would have to go and just keep the lispy parts
15:44notallamait doesn't sound to great to me. you'd get to call c code instead i guess, but i dunno how well that would work.
15:45chouserIt'll be interesting to see how it all plays out. Clojure does expect the host to provide at least a minimal OOP system I think, so porting to C++ (without templates and with a GC lib) might be easier than C or LLVM.
15:45ambientinteresting
15:46notallamatemplates are my favourite part of c++. minus the syntax.
15:46chouserhm, though once clojure.lang classes are all actually deftypes and protocols, I wonder how much OOP the host would actually need to have.
15:47jbendigCalling C++ libraries at runtime would be painful wouldn't it? Clojure with C seems easier to me.
15:47jbendigIt's painful with CL anyways.
15:47chouserI call C++ libraries from Clojure all the time.
15:47jbendigUsing JNI?
15:47chouserthe usage isn't too painful, though the initial setup was a bit.
15:48chouseryeah, JNI as generated by swig
15:48ambienti thought about that, but at first look it seems extremely painful
15:49jbendigI haven't tried that yet. Sounds like a good idea. I don't have much use for Java libraries but I do for C++ .
15:49ambientbut that's just because I'm on windows :p
15:50ChousukeWhat I don't get is that the clojure-reader Clojure works just fine when compiled with a java-reader and then with itself but not when compiled only with itself ;(
15:56Raynestechnomancy: Whenever you get a chance, I left a message on the swank-clojure mailing list, asking a question about using alternate clojure and clojure-contrib jar files. It appears someone else has posted a query as well.
15:59chousereven without trying to thread responses, it seems quite tricky to programmatically pick out new topics from an IRC log.
16:01StartsWithKchouser: how about then we tell the bot what it was? like !tag -30min reader error
16:01chousermaybe we can train everybody to start with "new topic:"
16:02ambientwhy is there a need to do that?
16:03ambientif you don't mind me asking
16:03chouserambient: I'm trying to figure out a descent way to provide intra-page navigation for the #clojure logs
16:04chousera list of links at the top of the page to specific topics would be brilliant, if it were possible.
16:04ambientlexical affinity has been found an useful way to categorize random text
16:05tomojbut we don't have training data
16:05chouserI just listed every poast that ends in a ? but the results are essentially useless.
16:05rhickeyhuh
16:06lisppaste8Chouser pasted "questions" at http://paste.lisp.org/display/89911
16:06chouseror at the very least too noisy.
16:06ambientwhat about categorizing everything where "hello" or "hi" occurs with "problem" in the same line ;)
16:07ambientor words like "so," with at least two "I"'s
16:08chouserambient: heh.
16:09shooverchouser: or... a view that only shows lines starting with "rhickey:", mouse over or click to see the rest
16:09chouserhm, lines at least 30 chars ending in ? is quite a bit better
16:09chousershoover: my sandbox here has all rhickey posts in red. :-)
16:10rhickeyincluding how,what,where, why , will ?
16:10jbendigI've noticed some interesting questions were in reference to Clojure's idioms. Might be able to filter some questions by searching for the word "idiom."
16:10shooverchouser: erc shows *my* posts in red :)
16:11rhickeyin any case it is a lot less to go through than the entire log if used as anchors
16:11ambientjbendig i feel so _conflicted_ using "bla bla bla.", which is linquistically correct, instead of "bla bla bla". which is logically correct
16:12shooverany kind of anchors with j/k style navigation would be great
16:12chousershoover: j/k ?
16:12shooverchouser: single key next/prev
16:13chouserso I've got 54 relatively interesting lines for today -- you want a list of links at the top of the page? down the side?
16:13jbendigambient: I completely agree.
16:13chousershoover: it sounds like you're talking about using them differently, but I don't understand yet.
16:14shooverchouser: links are fine, but for blazing through a few days logs I would prefer to use the keyboard
16:15ambienti think vimperator has keybindings for that
16:15chousershoover: right -- you want a key that skips to the next "interesting" line?
16:15shooverchouser: Yes. My use is "Oh, I haven't been on for 2 weeks, what's been going on?"
16:16chouserhm ... I like not repeating the text.
16:16Licenser_the key that skips to the next interesting line is the oftne ctrl+end
16:17chouserrhickey: is that what you're thinking too? I'm not sure what "used as anchors" means.
16:17rhickeychouser: yes
16:17rhickeynav
16:18chouserso a key to skip forward/backward to interesting lines.
16:18chousermaybe up/down clickables on those lines for the keyboard-impared
16:18hiredmanChousuke: have you looked at the metadata?
16:20Chousukeit's pretty difficult to debug because I only seem to get the exceptions when compiling with ant :/
16:20hiredman:/
16:20hiredmantime for print statements
16:20ChousukeI have them all over :P
16:21hiredmanat one point I had every single fn in my reader printing when it was called, and then inside several of the more complicated fns I had more prns
16:21hiredmanI had a new var *trace-reader* that you could bind to true to get this big long trace
16:22hiredmanwhich I took out in the final version, because of a few issues
16:22Chousukeall my individual tests show no problems with metadata, at least :(
16:23tomojcould you have ant hang and start a swank server somehow?
16:23ChousukeI also tried using LispReader's syntaxquote but it didn't help :)
16:30chouserhold me back!
16:31chouserI have (map post-to-html posts) but now I need a bit of state [next interesting post number] passed along.
16:31hiredman:(
16:31chouserI guess I can use reductions. :-/
16:31hiredmanuse r educe
16:32hiredmanor that
16:33chouserbut the conversion for both is so clumsy because the intermediate state leaks into the output seq/collection too.
16:35chouserha! I already have (map post-to-html (cons nil posts) posts) so I can look one post behind as I go along.
16:36raek(random clojure nicks: http://ohthehugemanatee.net/word-o-matic/1211/ )
16:36The-KennyI just got "Repl" :)
16:37chouserclojurebot: Who's job is it to generate random nicks?
16:37clojurebotis is
16:38hiredmanhmmm
16:38hiredmanclojurebot: whose job is it to generate random nicks?
16:38clojurebotis is
16:39ambientheh "Monkey"
16:39hiredmanclojurebot: whose job is it to generate random nicks?
16:39clojurebotthat's fgtech's job
16:41hiredmanclojurebot: whose job is it to remove factoids that break things?
16:41clojurebotthat's frodwith's job
16:41hiredmanI really have to do something about the fuzzer, it takes forever
16:42jasappfuzzer?
16:42ambalekclojurebot: who's your daddy?
16:42clojurebotGabh mo leithscéal?
16:42jasappheh
16:42adityoi got Holt
16:43hiredmanif there isn't an exact match for a lookup clojurebot splits the input into words, and generates a list of a lot of possible combinations of those words, and tries them
16:43adityoclojurebot: who's fuzzer
16:43clojurebotHuh?
16:44hiredmanhttp://github.com/hiredman/clojurebot/blob/master/hiredman/clojurebot/factoids.clj#L117
16:45tomojthat's so it can answer things even if we don't ask just right?
16:45adityobehold Ambitbckey :)
16:46qedclojurebot: What is it?
16:46hiredmanmore or less
16:46clojurebotWhat is meta
16:46qedoh so it's a markov?
16:46qedclojurebot: Who am I?
16:46clojurebotPardon?
16:46hiredmanthe whose job factiod just says "whose job is <reply> that's #someone's job"
16:47hiredmanclojurebot: whose job is it to keep the metric system down?
16:47clojurebotthat's TheBusby's job
16:47chouser,(reductions (fn [a b] (if b (inc a) a)) 0 (map odd? (take 10 (repeatedly #(rand-int 2)))))
16:47clojurebotjava.lang.Exception: Unable to resolve symbol: reductions in this context
16:47jasappahh
16:47chouser,(use '[clojure.contrib.seq-utils :only (reductions)])
16:47clojurebotnil
16:47Chousukeraek: heh, I tried the dinosaurs and got "Chilisaurus" :)
16:47chouser,(reductions (fn [a b] (if b (inc a) a)) 0 (map odd? (take 10 (repeatedly #(rand-int 2)))))
16:47clojurebot(0 0 0 1 1 2 3 3 3 3 4)
16:47qedclojurebot: whose your daddy? is <reply> #someone's my dadd
16:47clojurebotIk begrijp
16:48chouser~daddy?
16:48clojurebotPardon?
16:48raek"Clojurka"...
16:48qed~dad?
16:48clojurebotGabh mo leithscéal?
16:48qedlol that's like 3 languages right there
16:49raekwhat's with all the gaelic?
16:49raek...and dutch?
16:50hiredman~english
16:50clojurebotEnglish is the official language of the universe
16:50jasappis clojurebot running in a repl somewhere?
16:50Chousukeit responds in a random language when it doesn't understand.
16:50jasappclojurebot: where are you?
16:50clojurebotwhere is your source code
16:51Chousuke~source
16:51clojurebotsource is http://github.com/hiredman/clojurebot/tree/master
16:51Chousukeclojurebot: forget where
16:51clojurebotI forgot where
16:53The-Kennyclojurebot: xmpp
16:53clojurebotPardon?
16:54chouserdestructuring should use (:k m) instead of (get m :k)
16:55hiredmanclojurebot is on xmpp as clojurebot@thelastcitadel.com
16:55tomojwhy?
16:55hiredmanwhy not?
16:56tomojchouser: why?
16:56hiredman:P
16:56hiredmanthe new superfast :foo lookup works in the furst case, I believe
16:56Chousukechouser: what if k is not a keyword? :(
16:56chouseryeah
16:56ChousukeI suppose it could be specialised for the :keys case.
16:57chouserChousuke: and for actual keys
16:57chouser(let [{the-a :a, :keys [b c]}])
16:57tomojkeywords as functions are faster now?
16:58tomojor, only for deftype/whatever stuff that I don't understand yet?
16:58chousertomoj: the latter
16:58tomojah
16:58rhickey(:k m) is only fast when :k is a literal keyword, when a var/local holding a keyword it is normal lookup
16:59chouserbut that should fit nicely with let bindings
16:59hiredmanmakes sense
16:59rhickeye.g. (let [k :k] (k m)) is ordinary lookup
16:59rhickeybut yes, macros can see they have literal keywords
17:18marcgpretty quiet here
17:20Chousukemarcg: you just missed the discussion :)
17:20Chousukebut don't worry, there will be another, eventually :P
17:20mauritslamersQuestion: I am trying to build a pattern finding algorithm and until now I have tried do to that using a recursive loop
17:21mauritslamersthe speed isn't too good though
17:21marcgalright, when I know more about clojure I'll start a discussion :-D
17:21ambientmauritslamers strings?
17:22mauritslamersnot necessarily
17:22mauritslamersjust any type of data
17:22mauritslamersI need a loop to be able to pass on some data to the next loop to prevent false doubles
17:22mauritslamersbut I wondered whether there was a more efficient way to do that
17:23ambientpasting your code/problem might help
17:23mauritslamersI was already in the process of doing that :)
17:23notallamawhat sort of patterns are you trying to find? like a regex, but for general seqs, or what?
17:25lisppaste8mauritslamers pasted "pattern finding" at http://paste.lisp.org/display/89917
17:26mauritslamersnotallama: I am trying to find any pattern of any length
17:28ambienthmm the way i'd do it is just use integers, not any type
17:29mauritslamersnotallama: So I know it is quite cpu intensive anyway, but I was wondering whether using recur in this way would introduce overheads in either memory or cpu
17:30mauritslamersambient: would it be very inefficient to use strings for these symbols? that is, even when they would be numbers?
17:31mauritslamersI use a vector of characters now because that is the type of input I received
17:31ambienti usually use integers for algorithms that can be easily mapped as such. like strings can be easily mapped to ascii integer values
17:31ambientit doesnt have to be characters, you can map any type of thing to integer that just supports that abstraction
17:32mauritslamerswould it improve speed much?
17:32mauritslamersor would it enable a complete new kind of pattern finding?
17:33ambientas i dont completely understand what you're trying to do it's hard to say
17:36notallamamauritslamers: do you have an example of how you use it?
17:38mauritslamersambient: what the idea is now, is that I partition the entire input in sequences of 2
17:38mauritslamersso, in case of the first input that is commented out
17:38mauritslamersthe first element in that sequence is (1 2)
17:39mauritslamersso I filter the entire sequence for all places where that sequence occurs
17:39mauritslamersnext I go to the next item (2 3) and do the same
17:39mauritslamersthe same also for (3 1)
17:40mauritslamersthe next element is (1 2), but because I already did search for that sequence, I skip that one
17:40mauritslamersthat repeats for the entire input
17:41mauritslamersnext I partition in three and do the same for the entire sequence
17:41mauritslamersand so on until the length of the sequence has been reached
17:41ambientso you want to find unique sequences of length n?
17:41mauritslamersyep, exacly
17:42mauritslamerswhat is also important is that if a subsequence of a longer pattern also occurs as a pattern, the algorithm should also return that pattern as a unique sequence
17:43ambient,(map #(set (partition % 1 "efeokjfekj")) (range 2 4))
17:43clojurebot(#{(\f \e) (\k \j) (\e \f) (\e \k) (\e \o) (\j \f) (\o \k)} #{(\e \o \k) (\e \f \e) (\e \k \j) (\k \j \f) (\j \f \e) (\f \e \k) (\o \k \j) (\f \e \o)})
17:44ambientthat find all unique sequences between in range 2 to 3
17:44mauritslamersmmm, trying to understand what happens
17:47ambientyou wouldn't happen to be programming a compression algorithm?
17:47mauritslamersno, I don't :)
17:47ambientoh, ok heh
17:48mauritslamerswhy do you ask?
17:48mauritslamers:)
17:48ambientfinding repeating patterns is just the thing to do to in compression
17:48ambientso instead of ffffffff you can write 8f
17:48mauritslamerstrue, but this case the patterns are being used to do other stuff :)
17:54mauritslamersambient: thanks a LOT!
17:54mauritslamersthat speeds up the algorithm at least 100 times
17:54ambientnp :)
18:01mauritslamersambient: small additional question: what should I do when I want to have a pointer to the original place inside the input data?
18:02mauritslamersbecause when I use the indexed-partition instead it returns far too much results (of course :) )
18:02ambientyou'd have to find a way to add an index into the "partition" function
18:03mauritslamersthat is what indexed-partition does, but wouldn't that influence the set function?
18:03ambient,(indexed (partition 2 "foobar"))
18:03clojurebotjava.lang.Exception: Unable to resolve symbol: indexed in this context
18:03ambient,(clojure.contrib.seq-utils/indexed (partition 2 "foobar"))
18:03clojurebot([0 (\f \o)] [1 (\o \b)] [2 (\a \r)])
18:04ambienthmm
18:04ambientbut if you want to have pointers to places where the sequence is located, you can't have unique items
18:05ambientbecause then they're all different because of the location indicator
18:05mauritslamersthat is what I just found out indeed
18:06ambientso you would do (indexed (partition 2 1 "foobar")) to find the locations and for example (frequencies (partition 2 1 "foobar")) to count the occurrances
18:07mauritslamerscould I force set into only looking at a specific element of the value it gets?
18:07ambientfunctions usually do only one thing
18:07mauritslamersthe same as saying: "ignore that index")
18:08mauritslamersmmm
18:08ambienti'd probably just save intermediate values and then do different things unto them
18:08mauritslamersit wouldn't be too difficult to search for those patterns later on
18:09mauritslamersthe use of set already increases the speed of the algorithm hughely, so just searching for the already known pattern shouldn't be a problem to do afterwards
18:09ambientit's still N/2
18:10mauritslamerstrue, but in my original algorithm it was N!
18:10ambienthehe
18:10mauritslamersand luckily the amount of data is not enormous :)
18:11mauritslamersso that will be more than fast enough
18:11mauritslamersambient: thanks a million :D
18:11ambientnah, it's the power of functional programming
18:12ambientthings like these are pretty simple
18:13ambientuseful stuff: http://richhickey.github.com/clojure-contrib/seq-utils-api.html
18:26mauritslamersambient: I thought I started to get the basic idea of functional programming, but I now see that I need to keep thinking inside out :)
18:26mauritslamersbut that url is absolutely making it into my favourites!
18:30ambientif you want to learn more about functional programming, here's a good book
18:30ambienthttp://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html#%_toc_start
18:31ambientit has a lot of stuff in it, i'd suggest just reading some chapters that introduce the functional style
18:35javuchi1and the best tutorial about clojure?
18:36ambienti bought the book, it's pretty good
18:36hiredman~blip.tv
18:36clojurebotblip.tv is http://clojure.blip.tv/
18:37ambientthen there is mark volkmann's clojure pages, which for being free, are pretty awesome http://java.ociweb.com/mark/clojure/
18:37qedhow does apply work compared to reduce
18:37qedambient: i love his audio
18:37qedambient: i registered getclojure.org/com
18:37qedjust for giggles
18:38qedi need to put something up on them -- havent decided what yet
18:38ambientapply applied, reduce reduces
18:38ambienti really can't explain it better D:
18:38qedyou mean apply allies
18:38qedapplies
18:38ambient,(apply + [1 2 3])
18:38clojurebot6
18:38danlarkinqed: dangerous, considering you don't own the copyright to all the words in your domain name :)
18:38ambient,(reduce + [1 2 3])
18:38clojurebot6
18:39ambient,(clojure.contrib.seq-utils/reductions + [1 2 3])
18:39clojurebot(1 3 6)
18:39javuchi1,'nice
18:39clojurebotnice
18:39javuchi1hehe
18:39qeddanlarkin: oh god -- i know that's in jest, but really -- rich is gonna sue me?
18:39ambientprobably, and you're going to prison
18:39ambientfor life
18:39danlarkinI can't speak on his behalf... but he could! :)
18:40qedyeah -- let's hope clojure doesn't make anyone any money
18:40qedotherwise im screwed
18:40hiredmanI think it would be a trademark, not a copymark
18:40javuchi1,(if nil true false)
18:40clojurebotfalse
18:40danlarkinhiredman: oh you're right
18:40hiredmaner
18:40hiredmancopyright
18:40hiredmandanlarkin: are you sure?
18:40javuchi1,(= nil false)
18:40clojurebotfalse
18:40javuchi1do you see?
18:40javuchi1nonsense
18:41ambient,(== nil false)
18:41clojurebotfalse
18:41danlarkinhiredman: yeah you trademark brands
18:41danlarkinand you copyright IP
18:41hiredmannil and false are different, but they are both treated as false by if
18:41javuchi1hiredman: really strange behavior
18:41qed(def lie true) (if lie false)
18:41javuchi1can't undertand why
18:42hiredmanjavuchi1: because a. you should not need false, you should just use nil b. java interop needs false
18:42hiredmanso clojure has nil and false
18:42qedi think b is probably the more important of your explanation
18:42qedthe more important part*
18:44javuchi1hiredman: so it is a jvm issue?
18:44hiredmanit's not an issue
18:45javuchi1i understand it is
18:45hiredmanit's not
18:45danlarkin,(false? nil)
18:45clojurebotfalse
18:45danlarkinoh no!
18:45danlarkin:)
18:45javuchi1at least false should be equal to nil to be consistent
18:45hiredmanwhy?
18:45Chousukejavuchi1: false can't be equal to nil because false is not nil
18:45Chousukejavuchi1: however, both are *logically* false.
18:46javuchi1it has no sense
18:46javuchi1,(= nil false)
18:46clojurebotfalse
18:46qedit has plenty of sense, it's just weird
18:46javuchi1should return true
18:46hiredmanI just explained the sense
18:46hiredmanjavuchi1: why?
18:46Chousukejavuchi1: no, because nil is not false :)
18:46javuchi1because nil should be a sinonim of false ;)
18:46Chousukeand pretending it is would cause problems.
18:46qed"Yes it is!" "No it isn't!"
18:46hiredmanjavuchi1: but it isn't
18:47qed'round and 'round we go.
18:47Chousukejavuchi1: nil is java null, false is java false.
18:47hiredmannil is nothing, false is a boolean value
18:47javuchi1that's weird, hehe
18:47qedagreed
18:47hiredmanqed: hey, I ask why
18:47Chousukeyou bet clojure wouldn't have false if it could be avoided but it can't. :P
18:47qedwhy is it weird?
18:47hiredman"it should be this way!" "why?" "because I want it that way!"
18:48qedheh -- i mean i can see where he's coming from
18:48qedit's a weird little case
18:48hiredman*shurg*
18:48Chousukethough sometimes being able to differentiate between nil and false is useful
18:48qedagreed
18:48ambientChousuke so the test? functions would returns something-something or nil?
18:48javuchi1i don't see when
18:48Chousukenil means "nothing", which could be taken to mean neither true or false.
18:49hiredmanmostly when doing java interop
18:49Chousukethat is, that the value is not known.
18:49hiredmanbut I cannot remember ever having a situation where I cared about false vs. nil
18:49hiredmanit's a non-issue
18:49Chousukejavuchi1: Clojure has false because the JVM has it, but because treating nil as a boolean false is useful, that's also done.
18:50Chousukejavuchi1: but Clojure still won't pretend that they're the same thing .)
18:50javuchi1then, Chousuke, from your point of view, (if nil true false) should return true, as nil is not a boolean, it is just nothing
18:50Chousukejavuchi1: I said it's false in a boolean context.
18:50hiredmanjavuchi1: you are talking about logical value
18:50Chousukewhich nothingness often is.
18:50hiredmanboolean is a type
18:51hiredmannull is not a type
18:51javuchi1hiredman: nil is fully featured type which only one value, nil
18:51qed,(if false nil true)
18:51clojurebottrue
18:51javuchi1at least it is that way in CL
18:51hiredmanjavuchi1: by your logic anything that is not nil should = true
18:51hiredman,(if :a :b :c)
18:51clojurebot:b
18:52Chousukeheh :D
18:52Chousuke,(boolean nil)
18:52clojurebotfalse
18:52hiredmancommon lisp can go do unpleasent things to itsself
18:52Chousukethere.
18:52javuchi1hiredman: yes if you accept the logic of nothing being false
18:52Chousukejavuchi1: nil is false in CL too. and nil is nothing :P
18:52Chousukeit's also the empty list which is silly.
18:52Chousukethough sometimes useful
18:54hiredmanjavuchi1: which you do
18:54hiredmanwhich is why I said "by your logic"
18:54Chousukejavuchi1: no-one is claiming that nil equals false, but if interpreted a a truth value, it's non-true. similarly any non-nil value that is not the boolean value false has a "true" truth value.
18:54javuchi1i admit that it is the best aproach
18:55hiredmanthat what is?
18:55hiredmananything not nil = true
18:55hiredman?
18:55javuchi1Chousuke: that's not logic
18:55Chousukejavuchi1: logic only has two values.
18:56hiredmanChousuke: ahem
18:56hiredmanChousuke: boolean logic
18:56Chousukeyeah. that.
18:56javuchi1Chousuke: what i claim is that if something nil is considered false, false should mean nil too
18:56javuchi1that's my point
18:57hiredmannil is only considered to be false in the logical context
18:57javuchi1the behaivior of "if" is weird to me
18:57hiredmannot the context of equality
18:57Chousukejavuchi1: but that can't be, because nil and false are separate values. :/
18:57Chousukethey both just have a "false" boolean interpretation
18:57hiredmanif it is not raining then the sentence "it is raining" is false and so is the sentence "5 + 2 = -3"
18:57javuchi1Chousuke: a strange "typecast"
18:58hiredmanbut it does not make the sentences equivilant except in the context of boolean logic
18:58Chousuke,(identical? (Boolean. false) (Boolean. false))
18:58clojurebotfalse
18:58Chousuketwo more false values :P
18:58javuchi1hiredman: if you don't know if it is raining, it is not correct to say that it is false that it is raining
18:59Chousukethey happen to be equal to false because they're the same type though.
18:59javuchi1get it?
18:59hiredmanjavuchi1: that has nothing to do with anything
18:59hiredmanI stipulated that it is not raining
18:59Chousukejavuchi1: Does the behaviour of if really make no sense to you or are you just claiming that to be pedantic?
19:00Chousukeit's perfectly sensible to treat nothing as false.
19:00tomojit would annoy be greatly if it weren't the way it is
19:01hiredmanjust because two things can be treated the same in the logical context does not mean they are the same
19:01javuchi1Chousuke: yes, but my claim is that if you treat nil as false, you should treat false as nil, too
19:01Chousukejavuchi1: why does that follow?
19:01javuchi1simple logic
19:01hiredmanin the context of boolean logic, where clojure treates nil as false, false is also treated as nil
19:02ChousukeA->B does not imply B->A
19:02javuchi1if nil is false, false is nil, that simple
19:02hiredmannil is not false
19:02Chousukejavuchi1: but nil is not false. that's the point.
19:02hiredmannil is treated the same as false in the context of boolean logic
19:02hiredmanthere is no implicint = false inside if
19:02javuchi1nil is not false when you are interested in, but not when you are interested... really strange
19:02Chousukein mathematical terms, f(nil) = f(false), but nil is not false
19:03tomojwhat does it even mean to "treat false as nil"?
19:03tomoj(nil? false) should be true?
19:03hiredmanjavuchi1: I'm interested in it
19:03hiredmaner
19:03hiredmannot
19:03hiredmanlike I said. it has never been an issue
19:03Chousukeand the f function here is simply {false -> false, nil -> false, otherwise -> true}
19:04tomojjavuchi1: do you have an example snippet that should behave differently in your opinion?
19:05tomojI can't imagine what change you could possibly want to make
19:06javuchi1tomoj: to behave consistently
19:06Chousukebut... it is consistent
19:06Chousukewhat part of it is not consistent?
19:06javuchi1if you want nil to be considered false in some contexts, then consider false to be nil too
19:06Chousukewhy?
19:06ambientim currently eating crackers but the crackers aren't eating me
19:06javuchi1very simple
19:07javuchi1imagine the situations in which it is usefull to consider 0 to be nil and false
19:07javuchi1like in C
19:07hiredmanjavuchi1: in the context where nil is considered to be false, false is treated exactly like nil
19:07Chousukenil is only considered false in a boolean context, and in the boolean context, false is considered nil.
19:08Chousukebut only in that context are they equal, and nowhere else.
19:08javuchi1are you sure, Chousuke?
19:08Chousukeyes.
19:08javuchi1,(= false nil)
19:08clojurebotfalse
19:08Chousukethat's not a boolean context.
19:08Chousukethat's value context.
19:09hiredmanare these two values the same? false
19:09Chousuke,(= (boolean false) (boolean nil)); force to boolean context
19:09clojurebottrue
19:09javuchi1the boolean context of "if" is, then incorrect or inconsistent
19:09hiredmanhow?
19:09javuchi1because it treats nil as false
19:10hiredmanand false as nil
19:10Chousukehow is that inconsistent?
19:10javuchi1and false != nil
19:10hiredmanwhich is what you wanted
19:10Chousukejavuchi1: sign(x) treats many x's the same as well. how is that inconsistent?
19:10hiredmanjavuchi1: in the boolean context they are treated exactly the same way
19:10Chousukesign(5) = sign(23819238)
19:10Chousukevery inconsistent :)
19:11javuchi1if you want to be consistent, you should either a) consider nil as true b) consider false and nil as sinomous
19:11hiredmanthey are sinomous in the boolean context
19:11Chousukesynonymous :P
19:11hiredmanshow me where they aren't?
19:11javuchi1yeah, that
19:11javuchi1;)
19:12Chousukejavuchi1: what I still fail to understand is why you think that only one value may be treated as non-truth
19:12hiredman,(if false :a :b)
19:12clojurebot:b
19:12hiredman,(if nil :a :b)
19:12clojurebot:b
19:12hiredmansynonymous
19:12javuchi1,(or false nil)
19:12clojurebotnil
19:12tomoj,(if 3 :a :b)
19:12clojurebot:a
19:12tomoj,(if 4 :a :b)
19:12clojurebot:a
19:12ambientbtw, what is the plural of lisp? lispes? lisps?
19:12tomojoh noes
19:12tomoj3 and 4 should be sinonimus
19:12Chousukeambient: lisps
19:12hiredmantomoj: that is what I was saying before about everything should = true
19:13tomojindeed
19:13tomojwhy is true privileged, though?
19:13ambientdo lisps have true and false? are they even needed? i would think not
19:13tomojeverything should = 42
19:13tomojexcept for false
19:13tomoj(which is equal to nil)
19:13hiredmanambient: they don't
19:13tomojfalse is here because of java I think
19:13Chousukeyeah
19:13tomoj(and true as well)
19:14Chousukeif the JVM had only null, Clojure wouldn't have false either.
19:14javuchi1tomoj: no, because you define as true everything which is not nil
19:14tomojno I don't
19:14ambientyeah, so false is just a value, not a truth definition integral to the language
19:14tomoj...that would be wrong
19:14hiredmanbut there is nothing inconsistent with clojure's handling of nil and false
19:14The-KennyI approve tomoj in the 42 thing :)
19:14javuchi1tomoj: my point is that, sometimes nil is false but sometimes not, which is nonsense
19:14Chousukebut since the JVM has both, so does clojure. and it treats them both as false values.
19:14notallamanil and false also have to be distinct for java interop. false for false, nil for null
19:14tomojjavuchi1: you are not making sense
19:14javuchi1is 4 sometimes true and sometimes not?
19:14Chousukejavuchi1: nil always has a false truth value.
19:15tomojjust because nil is treated as false by 'if' doesn't mean it sometimes IS false
19:15javuchi1no, 4 is always true
19:15Chousukehiredman: but it's still not the value "false"
19:15javuchi1but, nil is sometimes false and sometimes not
19:15tomoj,(= 4 true)
19:15clojurebotfalse
19:15javuchi1understand?
19:15hiredmanChousuke: eh?
19:15tomoj4 is not true
19:15Chousukehiredman: oops.
19:15hiredmantrue is the value true
19:15Chousukehiredman: wrong target.
19:15Chousuke,(class? true)
19:15clojurebotfalse
19:15javuchi1tomoj: it should be
19:15Chousukewhoop
19:15Chousuke,(class true)
19:16hiredmanChousuke: hah
19:16clojurebotjava.lang.Boolean
19:16tomojjavuchi1: uhh
19:16tomojwhat?
19:16Chousuke,(class false)
19:16clojurebotjava.lang.Boolean
19:16Chousuke,(class nil)
19:16clojurebotnil
19:16ambientwhy does (number? 3) return true instead of something else though?
19:16tomojif 4 is true, then you can't do math
19:16hiredmanambient: why not?
19:16ambientif true and false aren't integral to truth values in clojure
19:16ambientwhy doesn't it return 3 or nil?
19:16Chousukeambient: it calls to java
19:16Chousukewhich returns booleans
19:16hiredmanthere is no reason it couldn't return 3
19:16ambientso it's not consistent after all
19:16hiredmanor nil
19:16hiredmanambient: it is
19:17javuchi1tomoj: then we have found another inconsistence: everything except nil should be true, but clojure claims it is not
19:17hiredmanwhat if it returned 'true
19:17tomoj"everything except nil should be true" - who says?
19:17tomojI don't say that
19:17ambientbut if number? is a clojure function and not a java interop function, and it still returns stuff from the java land...?
19:17Chousukejavuchi1: Clojure simply has a slightly extended definition of booleans.
19:17tomojif everything except nil is true, your language is useless
19:17tomojyou only have two values and you can't do shit
19:17Chousukejavuchi1: basically, nil and false are boolean false, everything else is boolean true. it's perfectly consistent.
19:18hiredmantomoj: javuchi1 is confusing boolean equality and value equality
19:18tomojyes I know :)
19:18javuchi1tomoj: if fact we have only two values all the time, as we are working with binary machines
19:18tomojnot at the language level
19:18tomoj(at least, not in a language like clojure)
19:19hiredmanjavuchi1: what is the value of true?
19:19hiredmanif say this was C and true is 1
19:19javuchi1everything that exists... i would define true as a function better than a value
19:19tomojwat
19:19Chousukejavuchi1: no, true is not a function.
19:20Chousukejavuchi1: true is a value
19:20Chousukejavuchi1: the function is the thing determining what is true and what is false.
19:21javuchi1and what is true for you?
19:22Chousukejust true. one of the two boolean values.
19:22hiredmanclojurebot: you have the con
19:22clojurebothiredman: aye aye skipper
19:22Chousukeit doesn't matter what it is. I call it true and it is true. :)
19:22ChousukeI can just define it so.
19:23Chousukeafter I define it and its properties (boolean logic) I can define arbitrary functions mapping other values to either true or false.
19:23javuchi1in your way of thinking
19:23javuchi1if C, for example, everthing which is not 0 is true
19:23javuchi1and it has a value
19:23javuchi1for example, 4
19:24Chousukeyes. in C, there's an implicit predicate in every if which does {0 -> false, not 0 -> true}
19:24javuchi1that's how i say that i define true as if it where a function
19:25Chousukeclojure has a similar implicit predicate, but it has two branches leading to false
19:25javuchi1true = not NULL or true= not false
19:25javuchi1not is a function
19:25ChousukeI should have said not equal
19:26notallamajavuchi1: do you do any c++? think of overloading operator bool(), if so.
19:26Chousukeso stuff equal to nil or false give false, and stuff not equal to either gives true. :/
19:26Chousuke+s
19:27javuchi1yes, that would be consistent :)
19:27Chousukethat's how it works in Clojure.
19:28tomojdon't lots of languages work this way?
19:28Chousukedoesn't scheme have a separate false from nil too?
19:28javuchi1the problem is that there is avalue fro true and false in clojure
19:28tomojI vaguely remember something like that
19:28tomojruby has nil and false the same as clojure
19:28javuchi1which is the confusion which is all about
19:28tomojpython too? Idon't remember
19:28tomojthere is no confusion here :D
19:29notallamai think in scheme, the two booleans are the only things you can use in a boolean context. not entirely sure, though.
19:29Chousukejavuchi1: yeah, but they're just values. if itself doesn't really care about that. :)
19:29Chousukejavuchi1: they're there to satisfy java.
19:29ambientRSR4 <3
19:29javuchi1tomoj: how you can say that a value is true? is there only ONE value which is true?
19:29javuchi1i don't agree
19:29tomojI say "truthy"
19:30tomojbut I dunno if anyone will understand me when i say that
19:31notallamajavuchi1: think of "if" and such as implicitly calling "boolean" things.
19:31Chousukejavuchi1: the "true" value is just a value representing truth. other things can be "true" too, but then they're really just mapped to the "true" value through some arbitrary function.
19:32javuchi1the, Chousuke, true is a characteristic, not a value
19:32Chousukejavuchi1: it's very much a value in boolean logic :)
19:32Chousukeit's easy to pick any arbitrary value to represent your truth (or non-truth)
19:32ChousukeI could call 4 my truth and 5 non-truth.
19:33ambient,(doc reify)
19:33clojurebotNo entiendo
19:33Chousukewhich would cause funny things as 4*5 would be 5 and 4+5 would be 4
19:33javuchi1you could, but is nonsense
19:33Anniepoo'pipe rotated' is true and 'pipe not rotated' is false (common in rr interlocking)
19:33Chousukejavuchi1: mathematically it's perfectly valid.
19:33ChousukeI'm free to choose.
19:34javuchi1if you brake common sense (in which math is based), yes, it is correct
19:34Chousukemaths is not based on common sense :P
19:34Chousukemaths is based on... maths.
19:34javuchi1but then you are not going to be consistent with the rest of the human race
19:34Chousukeit's self-hosting.
19:34javuchi1maths are human thoughts, they don't even exists...
19:35tomojfinally something we can agree on
19:35Chousuke:)
19:35javuchi1yes, hehe
19:35ChousukeI have to disagree with math not existing though :P
19:35javuchi1;)
19:35technomancyChousuke: ah, a platonist!
19:35tomojyou don't exist
19:35danlarkinalan turing would have something to say about that
19:36Anniepoojavuchi1, deliberately the OSI network stack model doesn't refer to zero and one, it refers to 'mark' and 'space'
19:36ChousukeI just did some exercises for a "Fourier methods" course the other day and that stuff is very real.
19:36tomojjavuchi1: wait, does clojure exist?
19:36javuchi1anyway, i prefer, if you wnat to listen, the C aproach of considering everything except 0 to be true
19:36tomojthat would be terrible
19:36javuchi1tomoj: not at all, it's all virtual ;)
19:36Anniepoothose terms were originally when a goose quill pen was or wasn't marking a strip of paper
19:37tomojunless the cdr of a singleton is 0
19:37notallamareally, when you look close enough at anything, you'll find that there's nothing there. like, look at an atom: it's entirely (or damn well near it) empty space.
19:37tomojwhich would be highly odd
19:37Chousukejavuchi1: won't C actually give you an error if you try to use eg. a struct in an if?
19:38javuchi1notallama: not even that, it is something you believe it is there because you have the illusion that what you see thouht you eyes is true in some way
19:38Chousuke^^^^physics
19:39javuchi1Chousuke: not, but clojure is not, too
19:39technomancytomoj: ah, a chestertonian! =)
19:39Chousukehm
19:39tomojif (seq '()) returned 0, I would kill myself
19:40tomojOR, if (seq '()) returned nil, but nil wasn't falsey, I would me mildly annoyed
19:40Chousuke,^^(with-meta 'a (with-meta {:foo 'bar} {:meta 'physics}))
19:40clojurebot{:meta physics}
19:40tomojhaha
19:41ambientmetaphysics wont pay my bills or mow my lawn
19:41Chousukemetadata about metadata :/
19:41javuchi1why would you kill yourself, tomoj?
19:41javuchi1what is the definition of seq?
19:42tomoj(if (seq '()) :foo :bar)
19:42tomoj,(if (seq '()) :foo :bar)
19:42clojurebot:bar
19:42tomojthis is very useful
19:42javuchi1,(doc seq)
19:42clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
19:42ambient"metaphysics can contain nothing but sophistry and illusion."
19:42tomojwhat, that's not the quote
19:42javuchi1it can return 0, which means that it is empty
19:42Chousukejavuchi1: but then you'd have to equate 0 to nil :/
19:43tomojif it returns 0, then every time you get a seq, you have to check whether it's a seq or 0
19:43tomojand you could add stuff to it
19:43tomojand get 12 or something..
19:43Chousukewhich is one of the most popular causes of programming errors I think :P
19:43tomojlike (+ (rest '(1)) 12)
19:43javuchi1you can throw an exception ;)
19:44tomojit would just be so monstrously ugly that I would be forced to end my life
19:44cupertinochadMay I ask a newbie question?
19:44Chousukesure.
19:45cupertinochadI heard somewhere that (. blah) was no longer the best way to do Java interop. I want to do (. System nanoTime) Is this still the preferred way?
19:45javuchi1or, you can make an special function test, for example called end? which tells you when the end has reached
19:45Chousuke,(System/nanoTime)
19:45clojurebot1257554820716579000
19:46javuchi1it would be even better than nil
19:46javuchi1or nil?
19:46tomojjavuchi1: but why in the world would we want to do that?
19:46tomojjavuchi1: is clojure your first lisp? just curious
19:46javuchi1no, i used CL
19:46Chousukecupertinochad: Foo/bar for static fields/methods, (.field obj args) for non-statics
19:46tomojweird
19:46technomancytomoj: who else but a CL user would want to unify false and nil? =)
19:47tomojsure, but.. into 0?!
19:47javuchi1i'm not a CL guy
19:48javuchi1perhaps a C guy, probably worse
19:48cupertinochadChousuke: Thanks a million
19:48cupertinochadChousuke: Any idea why this way is preferred over "."?
19:48Chousuketechnomancy: I don't think unifying false an nil is a bad thing per se, but if it means (= false nil) -> true instead of just removing "false" from the language I think it's not worth the trouble.
19:49Chousukecupertinochad: it's lispier and looks better.
19:49javuchi1Chousuke: i would agree on simply removing false
19:49javuchi1and make anything else just true
19:49tomojremoving false is not good for java, though
19:49Chousukecupertinochad: my personal justification is that a mere . in the head of a list (in operator position) is a wasted of a prominent code position :)
19:49Chousuke-d
19:50Chousuke(foo bar) pretty much always means "operator foo with args bar" in Clojure
19:50Chousukeoperator . only tells you "java interop". System/nanoTime tells you... the time :P
19:51javuchi1java is weird
19:51tomojI don't particularly like java much either
19:51javuchi1the jvm is a miracle, but not that good, too
19:52clojurebot
19:52tomojbut I like being able to use it from clojure very very much
19:52Chousukethe JVM is not optimal for a lisp I suppose, but it's not as bad as people think
19:52ChousukeI doubt Java even uses half of what the JVM really could do :/
19:52ambientbtw, when can i use these puppies? http://www.assembla.com/wiki/show/clojure/Datatypes
19:52javuchi1i would prefer more like it's own virtual machine like erlang, with facilities to call other languages like java directly
19:53Chousukeambient: I think it's another branch in the repo
19:53Chousukejavuchi1: go ahead and implement a virtual machine that competes with the JVM and perhaps you can make Rich consider migration :D
19:53ambientChousuke is it going to be merged into the main branch sometime in the not so distant future?
19:54javuchi1Chousuke: as far as I know (and I don't know much), the jvm is very object oriented, and very suboptimal for anything else
19:54tomojI think the JVM is great for clojure :)
19:54Chousukeambient: You'll have to ask Rich about that.
19:54javuchi1and it is a monster
19:54chouserambient: post 1.2, I think
19:54ambientchouser ok, thanks
19:55Chousukejavuchi1: There are great people working on improving the situation, though.
19:55javuchi1Chousuke: the jvm is a comodity, but I don't think it would be THAT difficult to make your own vm as everybody says
19:55tomojJVM means clojure runs pretty easily everywhere and there's already a library I can use for pretty much anything
19:55cupertinochadChousuke: Thanks for the explanation; I agree.
19:55ambientjavuchi1 oh man, you just didn't say that... :D
19:55Chousukejavuchi1: it's not difficult to make a VM. it IS difficult to make it rival the JVM.
19:55tomojnot least because to really rival the JVM you'd need to write tons and tons of libraries..
19:55javuchi1Chousuke: you don't need to. look at erlang, it is able to call Java and C very easily
19:56Chousukein fact, any VM you can code in a year's time will get blown out of the water by the JVM. :)
19:56javuchi1tomoj: it is true, also, that most staff from the jvm is useless for a lispy/inmutable based structures like clojure is based on
19:56Chousukeit's just a huge responsibility off of Rich's shoulders :P
19:57chouserjavuchi1: really? like what?
19:57javuchi1i won't use much of the staff from the java library just because it is difficult to integrate in the world of inmutable things of clojure, and it would be very little idiomatic
19:58tomojI certainly don't agree..
19:58tomojjetty, htmlunit, tagsoup, matrix math stuff, jgraph, on and on
19:58ChousukeYou have a point, but the situation isn't as bad as you think :)
19:58tomojall I love being able to use from clojure directly, even if using them is a bit less pretty than pure clojure
19:58tomojit's MUCH less work than rewriting them all
19:59javuchi1there are plenty of vm out there
20:00ambientof JVM's calibre? very few
20:00javuchi1some of them are able to comunicate with other vm like the jvm
20:00javuchi1JVM is not that good
20:00Chousukeit's only perhaps the best :P
20:00javuchi1is simply the amount of libraries avaiable
20:01tomojI don't think that's the whole story
20:01ambientnot to speak of proprietary codebases that some companies have
20:01tomojbut that's really important anyway :)
20:01javuchi1as i said before, there are ways of calling the jvm from the outside
20:02javuchi1erlang is capable of doing so
20:02tomojso go use erlang?
20:02javuchi1it's not lispy ;)
20:02tomojah
20:02javuchi1but i considered
20:02chouserlfe
20:02krumholtjavuchi, what exactly is it you don't like about the JVM and which JVM? You could always go and use a JVM not from sun
20:03ChousukeI think javuchi1 just thinks the JVM is not as good for lisps as the erlang VM
20:03javuchi1lot of things, krumholt
20:03Chousukewhich is probably true. however, that doesn't mean it still isn't excellent :D
20:04chouserjavuchi1: have you considered "lisp flavoured erlang"?
20:04krumholti think it is a very excellent plattform too. maybe it could be better but all the work.. :)
20:04Chousukeit's got an amazing runtime-profiling optimizing JIT-compiler :P
20:04Chousukehow many VMs have that?
20:05ambientCLR is pretty good at least on windows
20:05javuchi1Chousuke: there are many others that do
20:05Chousukejavuchi1: such as?
20:06ambientiirc CLR has TCO
20:07javuchi1the erlang VM is very good, the CLISP one is also good (and they are making a JIT now), the SBCL compiler is not a VM, but can do very good optimizing compiling on the fly, and many many others... it is not that hard to make another one, but i understand the comodity of the jvm... just that... it feels to much like java
20:08Chousukejavuchi1: that "It's not that hard" is utterly false :)
20:08Chousukejavuchi1: it's exceedingly difficult.
20:08javuchi1you can use an existing one
20:08ambientsomething interesting about JVM and TCO I found. "This is also the reason why JVM doesn't offer tail calls at all. The security sandbox uses stack walking to work out whether an operation is permitted in the current context. Proper tail call optimization would destroy the information needed to make those decisions."
20:08Chousukesuch as the JVM :/
20:09javuchi1for example, take SBCL and transform it until you get something very apropiate for a language like clojure
20:09ChousukeI recently read JRose's post about continuations on the JVM. it was pretty interesting.
20:09chouserambient: I believe there is a patch for TCO on the JVM that takes into account such things.
20:09Chousukejavuchi1: but then you wouldn't get the libraries.
20:10javuchi1why not?
20:10Chousukejavuchi1: and I don't think CL would be a good basis for Clojure anyway :/
20:10Chousukeit's... mutable :)
20:10javuchi1it was just an example
20:10javuchi1java is also mutable
20:11krumholtjavuchi1, the jvm is only a plattform unless you plan on becoming a clojure developer i think there is no real reason to worry about it. from my point of view as programmer i don't really care what plattform is used and why would i?
20:11javuchi1and the jvm is pretty much mutable ;)
20:11ChousukeMany things aren't though.
20:11Chousukelike strings and numbers.
20:11javuchi1oh, strings and numbers... even C can do right on that ;)
20:12chouserC strings are mutable
20:12javuchi1i said can do well, not that they were not mutable
20:12ChousukeC "strings" are blobs of memory ;(
20:12Chousukeliterally. if you want to treat something as just memory you cast it into a C string. :P
20:13javuchi1you can program inmutable in C if you want
20:13javuchi1ah, and now that we talk about C
20:13Chousukethough I suppose the real definition requires that it be null-terminated :/
20:13javuchi1C would be an excelent "platform" of "vm" for anything
20:14javuchi1look for example at ECL
20:14tomoj:'(
20:14javuchi1it is doing very well and it uses C as the assembler for everything
20:14ChousukeC is not a platform though. :/
20:14ChousukeC on unix is a platform.
20:14ChousukeC on windows is a platform.
20:14javuchi1I said "platform" not platform
20:14javuchi1understand what means the "
20:15javuchi1http://ecls.sourceforge.net/
20:15robin_bdoes anyone here know about setting the classpath for the interactive REPL started by the textmate clojure bundle?
20:21krumholtrobin_b, i think you could use add-classpath
20:21krumholt,(doc add-classpath)
20:21clojurebot"([url]); Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
20:22robin_bah - ok - so just do it within the repl once started
20:22robin_bthat makes sense
20:22robin_bI was looking for a textmate command or a place to configure the project
20:23chouseradd-classpatch is notoriously treacherous
20:23chouserif it works in a given situation, great, but don't be surprised if it fails in slightly different circumstances.
20:23robin_bhmm
20:29ambientis it in any way predictable?
20:29javuchi1all of this came with (= false nil)
20:29chouserambient: you mean to know when add-classpath with fail?
20:29Chousukeheh :P
20:30ambientchouser yes
20:30javuchi1let me ask something a little delicate
20:30javuchi1do you hate CL gus?
20:30Chousukeno. :)
20:30chouserambient: yes, it's not actually random, but it depends on how classloaders are being used
20:30javuchi1what do you think about them?
20:30ChousukeDepends on the person :P
20:31ChousukeI think there are quite many CLers here too.
20:32javuchi1do you think it is compatible to keep using CL and Clojure?
20:32javuchi1at the same time?
20:32javuchi1i have the feel that CL is getting to old
20:33ChousukeThat's kind of my opinion too.
20:34ChousukeI never really got into CL... It has some really neat things, though.
20:34ChousukeAnd I really with Clojure had similar debugging facilities :P
20:34Chousukewish*
20:34The-KennzI really love CLOS
20:35The-KennzBut it's a bit old, I agree... bad library support etc.
20:35javuchi1I don't, it is weird for me
20:36ChousukeThen again, Clojure does many things better than CL in my opinion. Vectors, maps and sets for instance.
20:36The-KennzIt's good to have a real map in clojure.
20:36ambienti'd think immutability and robust concurrency constructs are more essential :)
20:37The-KennzI remember the ugly lists of (key . value)
20:37Chousukeand lisp1:ness and namespaces and syntax-quote are all cool stuff too, even though they're "minor" features
20:37javuchi1the main problem about CL is that everybody said that CL would be able to do anything in the future, but now we can see that there is a vital thing that it is not able to do, and little expectations of being to in the near future: multitasking
20:38ChousukeWhat's the deal with that anyway?
20:39hiredmanactually, it was durring the standarization process of cl that the phrase "sufficently smart compiler" was coined
20:39ChousukeA sufficiently smart Clojure compiler would fix my reader :(
20:39ChousukeI still have no idea what's wrong with it.
20:40javuchi1with the reader?
20:40javuchi1of clojure?
20:40Chousukeno, one that I'm writing.
20:41Chousukeit compiles just fine and even works with contrib
20:41Chousukebut then explodes with the weirdest error if I try to recompile it with "itself"
20:41javuchi1are you a clojure devveloper?
20:41Chousukewhich makes no sense as in order to compile it I already compiled it once with itself.
20:42Chousukebut compiling a second time fails.
20:42hiredmanChousuke is a Chousuke of the Finnish Chousukes
20:42Chousuke:P
20:42Chousukejavuchi1: I have a CA.
20:42javuchi1perhaps because you compiled it the first time with another version or with an option enabled/disabled?
20:43hiredmanpffft, even I have one of those
20:43Chousukewell, it goes like this:
20:43javuchi1what is a CA?
20:43_atojavuchi1: http://clojure.org/contributing
20:45javuchi1oh i don't like it
20:46ChousukeFirst I compile the java files. Then, I have core.clj and reader.clj; I compile core.clj and reader.clj to class files with a plain java clojure. After that, I add them to classpath and recompile all clj files to classes, and make a jar of those. then I have a clojure.jar which uses my clojure reader but if I then try this process again with "plain java clojure" replaced with this
20:46_atothe only thing I don't like is it has to be posted instead of scanned + emailed
20:46Chousukenew clojure.jar... boom.
20:46scottjIs there a debugger that you can easily run along side slime so when you have a stack trace pop up you can easily see what variables values are?
20:47Chousukescottj: there's http://georgejahad.com/clojure/cljdb.html
20:47ChousukeI should try that. :/
20:47javuchi1i don't agree very much with that politics
20:48hiredmanpolitics?
20:48hiredman(maybe you mean those policies?)
20:48javuchi1that
20:49javuchi1 you hereby assign to me joint ownership, and to the extent that such assignment is or becomes invalid, ineffective or unenforceable, you hereby
20:49javuchi1 grant to me a perpetual, irrevocable, non-exclusive, worldwide, no-charge, royalty-free, unrestricted license to exercise all rights under those
20:49javuchi1 copyrights. This includes, at my option, the right to sublicense these same rights to third parties through multiple levels of sublicensees or other
20:49javuchi1 licensing arrangements;
20:49javuchi1bad bad bad
20:50chouserjavuchi1: my friend, there is no need for you to contribute.
20:50_atohehe
20:50javuchi1you're right
20:50hiredmanwell, sorry to lose you, bye?
20:50javuchi1and now, much less need
20:50Chousukeyou can just be a user
20:50Chousukethat's good too. File bug reports :P
20:51ChousukePersonally I think the CA is trivial.
20:51chouserbut as a *user* I hope you can take comfort in knowing that when licenses need to be changed, that it can happen smoothly because the contributors have all signed on.
20:51_atoIMO Clojure/Sun's is much better than many other CA's eg http://www.canonical.com/contributors
20:51javuchi1when i saw the screencast
20:51javuchi1it was strange the face rihky put when talking it wan open source...
20:51javuchi1now i understand
20:51Chousukehuh?
20:51_atowhat?
20:52ChousukeIt is open source. Free software, even :P
20:52_atojavuchi1: did you miss the bit where it says Rich promises to release the code under an OSI/FSF approved license?
20:52javuchi1only until rich wants
20:53_atounlike Canonical's you also retain ownership of your contribution
20:53Chousukeyou just assign Rich joint copyright for your contributions. Which basically means that Rich *could* close the source but that won't happen; if it does, Clojure either dies or a fork happens :/
20:53chouserChousuke: no, actually, because he promises not to in the same agreement.
20:54Chousukewhat the CA allows is that if there ever is a licence better than the EPL for Clojure, it can be easily changed.
20:55chouserin fact it happened once already
20:56ambientthere are some restrictions on using clojure in work related stuff?
20:56chousernope
20:56Chousukethe EPL is GPL-incompatible, but then again, so are most other licences ;/
20:57_atoyeah, that's the only really bad thing about Clojure's licensing IMO
20:57Chousukeand even then it's GPL's fault.
20:58Chousukebut oh well. plenty of non-GPL java libraries out there :)
20:59jbendigI imagine the EPL makes it easier for many businesses to adopt use of Clojure. Don't many businesses stay away from GPL related code without trying to understand the licensing terms?
20:59javuchi1note that rich didn't promise anything
20:59javuchi1 Any contribution I make
20:59javuchi1available under any license will also be made available under a suitable FSF (Free Software Foundation) or OSI (Open Source Initiative) approved
20:59javuchi1license.
21:00javuchi1what is contribution?
21:00chouserambient: I'm not very sure, but I think the only "work related" restriction is that if you distribute clojure in object form with your code, you need to also make the source available (including your changes) under the EPL.
21:00javuchi1if it is not a contribution then it can be closed software
21:01ambientchouser clojure code? perhaps a link for github would suffice? ;)
21:01jbendigI thought only the EPL code had to be made available as open source. Your changes do not have to be.
21:01Chousukejbendig: your changes to clojure have to be released. it's reciprocal like that.
21:02chouserambient: sorry, I meant if you make a change to clojure itself and distributed the class files you'd have to make the source available under EPL.
21:02Chousukejbendig: however, you can link it with a proprietary module.
21:02ambientok
21:02jbendigChousuke: Oh, okay.
21:02chouserright, only changes and additions to the program, not other thinks you link with it or any class files or jars it produces.
21:03chouserother things
21:03javuchi1what is rich afraid of? why this agreement enforcement if you want to contribute?
21:03ambientjust because you're paranoid doesn't mean they're not out to get you
21:03_atohehe
21:03_atoas said earlier it's so that the license can be changed to a different open-source license
21:04_atoeg. if the GPL-incompatiblity becomes really problematic Rich can do something about it
21:04javuchi1am i the paranoid, or the one who make that agreement?
21:04javuchi1why not using LGPL?
21:04chouseralso he's very careful to track the provinence of every patch so that any claims that clojure contains code owned by others can be effectively refuted.
21:05Chousukejavuchi1: the CA basically makes licencing a non-issue.
21:05Chousukeif it becomes a problem, it can be changed.
21:05Chousukeor if someone wants to pay Rich 2 million USD for a custom-licenced version of Clojure, that can be done :P
21:05chouserat the cost of losing some potential contributors who don't like. A know cost that rich has chosen to accept.
21:06chouserman I can't type
21:06_atoRich doesn't like the LGPL since someone can take clojure and make it GPL and then he can't use their changes
21:06javuchi1oh yes i'm pretty sure he can accept a lot of thing for 2 millions
21:07javuchi1_ato: then they should change the name, if he has the trademark, as i supose he has
21:07somniumjavuchi1: is there a particular scenario you're concerned about?
21:08javuchi1i'm not american, this is the first
21:08_atojavuchi1: it's not about trademarks, it's about him being able to use their changes
21:08ChousukeDoes that matter?
21:08ChousukeI'm not American either :/
21:08javuchi1the second is, if somebody, for example sun, or anything else, want to buy clojure, they can do with clojure whatever they want
21:09Chousukejavuchi1: the old versions will still be available to us.
21:09jbendigThen the source code up to that point could be forked and kept under the existing license.
21:09chouserjavuchi1: but they can't take away our ability to fork at the point before they take it. This is tru of all free software.
21:09Chousukejavuchi1: and Rich is bound to release his contributions to the open as well.
21:09Chousukebut if that 2mil USD thing actually happens it'll be awesome though.
21:10Chousukesomeone just gets a ProprietaryClojure and Rich can work full-time on Clojure.
21:10javuchi1but you are not the ownership
21:10javuchi1even for past versions
21:11ambientit would be pretty awesome if sun adopted clojure and started developing jvm into that direction more
21:11javuchi1he can change the license even for past versions
21:11chouserjavuchi1: nope
21:11_atojavuchi1: no, it's non-revokable
21:11javuchi1 you hereby
21:11javuchi1grant to me a perpetual, irrevocable, non-exclusive, worldwide, no-charge, royalty-free, unrestricted license to exercise all rights under those
21:11javuchi1copyrights
21:12javuchi1that's what it says
21:12javuchi1he can do whatever he wants
21:12Chousukejavuchi1: the contributors also retain those rights.
21:12_atonad he's already released old versions of Clojure under the EPL, and he can't undo releasing it
21:13_atoChousuke: which branch should I look at for your reader? reader-integrated?
21:13javuchi1where does it say so, Chousuke?
21:13Chousuke_ato: oh, the latest stuff is not there.
21:13Chousuke_ato: the latest stuff is a mess.
21:13Chousuke:)
21:14ChousukeI'll push it, wait a moment.
21:15jbendigjavuchi: Look at section 2A of the EPL. http://www.opensource.org/licenses/eclipse-1.0.php
21:16javuchi1jbendig: the problem is that, with the CA, Rich makes himself the owner of everthing
21:16_atohe made *joint* owner
21:16_atoyou retain ownership
21:16jbendigFor future work, yes. Once the code is distrubted under the EPL then that set of work is tied to that license.
21:17javuchi1yes, but your contribution alone has not much value
21:17jbendigdistributed*
21:17javuchi1jbendig: that is not what it says in his CA
21:18Chousukejavuchi1: yes, but it holds still.
21:18javuchi1you grant him an unrestricted license to exercise all rights under your code
21:18Chousukejavuchi1: revoking a licence for no reason after you grant it is fraud :P
21:18chouserif you want to contribute to emacs you have to assign copyright to the FSF, retaining no ownership of your own code. This is less extreme.
21:19jbendigThe CA just makes it easier for Clojure to mature. Look how Squeak suffered later on by not having such a system in place.
21:20ambientCA is certificate authority or something?
21:20hiredmanclojurebot: ca?
21:20clojurebotCA is Contributor Agreement: http://clojure.org/contributing
21:21Chousukejavuchi1: all the horror scenarios are purely theoretical and will simply not happen :)
21:22Chousukeand because of that the CA is a minor annoyance that gives flexibility benefits
21:23javuchi1I know that the FSF is not going to shell Emacs to Sun...
21:23chouserhow do you know that?
21:24somniumif Sun bought emacs would you stop using it?
21:24javuchi1and, the most important
21:24javuchi1you give the copyright to the FSF, but you don't allow them to sublicense it with another license
21:24Chousukechouser: Well, it's the FSF :P
21:25javuchi1with this CA, you allow Rich to change the license
21:25javuchi1it's much, much worse
21:25_atojavuchi1: giving FSF copyright allows them to change the license
21:25_atojavuchi1: in fact it means you can no longer change the license
21:25_atosince you don't retain ownership in your own code
21:26Chousukeyeah. you won't be able to use that contributed code under any other licence :/
21:28chouserred-letter edition with question-links at http://clojure-log.n01se.net/
21:28chouserthe links still need some kind of tweaking, but I'm not sure exactly what.
21:29chouserbut I've got to quit messing with it for now.
21:30Chousuke_ato: I pushed my current code into reader-mess
21:30_atoChousuke: so the idea is, you compile once with the java reader generating clojure-slim.jar, then copy that to bootstrap/clojure.jar and recompile and this time it's with your reader?
21:31Chousukeclojure-slim.jar has to be a full-java clojure
21:31ambientchouser nifty, i think the arrows are too tiny, though
21:31ambientor too close together
21:31Chousukethe buildfile takes care of the rest
21:31Chousukeoh, and you'll need to use -Dclojure.reader=true to use my reader... I think
21:31ChousukeAs I said, it's a mess. :P
21:32Chousukethere are debug prints in core.clj and syntaxquote-macro is broken and temporarily not even in use
21:32chouserambient: yeah, probably both.
21:32Chousukesyntax-quote* (the function) should work instead of LispReader's syntaxquote method.
21:33_atoah, so I build clojure-slim.jar with rich's "new" branch?
21:33ChousukeI haven't tested.
21:33Chousukeuse master.
21:33_atook
21:33jbendigchouser: Very nice! I can see myself using this to catch up on questions over night. Would it be possible to fold the questions for faster scanning?
21:34chouserambient: but small links are better than none, and big links may be worse (depending on what they do to the layout)
21:34Chousukeyou can also edit the build file a bit to try and enable the "complete" build process (which still fails for me)
21:34chouserjbendig: yes, possibly, but will require more work.
21:36Chousuke_ato: if you get any exceptions using the reader in a repl, report to me. I haven't found anything.
21:37_atoChousuke: cool it works. was getting some NPE with build because I was using the wrong clojure-slim.jar.
21:37_atoI'll have a play with it and see if I can break it
21:37Chousukedid you use the -D switch?
21:38Chousuketry typing for example '(foo] in the repl. if the error message includes column you're fine :)
21:38_atojava.lang.Exception: Unexpected closing character ] (line 1, column 7)
21:38_atovery nice :)
21:40Chousukethere's also a known bug with one of contrib's tests. for some reason, I get a stack overflow :/
21:41Chousukebut now I need to sleep. have fun :P
21:42leafwis there any way to do an "if-let" for multiple bindings? I.e. bind all if none are nil?
21:48krumholtwill doseq execute every command?
21:48somniumattempt ->
21:48somnium,(if-let [[x y z] (if (every? #(not (nil? %)) [1 nil 3]) [1 2 3] nil)] (println x y z))
21:48clojurebotnil
21:48somnium,(if-let [[x y z] (if (every? #(not (nil? %)) [1 2 3]) [1 2 3] nil)] (println x y z))
21:48clojurebot1 2 3
21:48somniuma bit clunky
21:48_atokrumholt: you mean will it consume the entire sequence? yes
21:49krumholtso i can use it for side effects?
21:51_atokrumholt: yes, that's what it's intended for
21:51_ato,(doc doseq)
21:51clojurebot"([seq-exprs & body]); Repeatedly executes body (presumably for side-effects) with bindings and filtering as provided by \"for\". Does not retain the head of the sequence. Returns nil."
21:52krumholtwhat i want to do is measure speed. i need fast matrix multiplication and my first implementation in clojure is allready about 60% faster then the java implementation that seems strange
21:55krumholtwhat i want is a block in which no lazyness can happen. is that possible? like (without-lazyness ...)
21:56_ato,(doc doall)
21:56clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
21:57_atoas in:
21:57_ato,(time (doall (map inc (range 10))))
21:57clojurebot(1 2 3 4 5 6 7 8 9 10)
21:57clojurebot"Elapsed time: 0.183 msecs"
21:58krumholtthanks
22:01krumholtok now its really slow :) is there a fast-math library or something for clojure?
22:01somniumkrumholt: you can use primitives and arrays
22:02danlarkinIs there a better way to check that everything in required is in sent? (reduce #(and (sent %1) (sent %2)) required)
22:03krumholtsomnium, ok thanks
22:03_ato,(empty? (difference #{:a :b} #{:a})
22:03clojurebotEOF while reading
22:03_ato,(empty? (difference #{:a :b} #{:a}))
22:03clojurebotjava.lang.Exception: Unable to resolve symbol: difference in this context
22:04_ato,(use 'clojure.set)
22:04clojurebotnil
22:04_ato,(empty? (difference #{:a :b} #{:a}))
22:04clojurebotfalse
22:04_ato,(empty? (difference #{:a :b} #{:a :b}))
22:04clojurebottrue
22:04danlarkin_ato: difference doesn't work because sent can have things that aren't required
22:04_ato,(empty? (difference #{:a :b} #{:a :b :c}))
22:04clojurebottrue
22:05_atooh
22:05_atowait no (difference required sent) ?
22:05_atoshouldn't that work?
22:06_atoyour way might be faster though as it doesn't tell you what's missing
22:06somniumsent is a map and required is a collection of keys?
22:07somnium(every? {:foo :bar :baz :quux} [:foo :bar])
22:08somnium,(every? {:foo :bar :baz :quux} [:foo :bar])
22:08clojurebotfalse
22:08somnium(every? {:foo :bar :baz :quux} [:foo :baz])
22:08somniumbah
22:08danlarkin_ato: difference does work that way... I didn't realize it wasn't commutative
22:08danlarkin_ato: so it'll work just fine, thanks
22:09_atosomnium: ah yeah, that's nicer
22:11Anniepoo,(doc load-file)
22:11clojurebot"([name]); Sequentially read and evaluate the set of forms contained in the file."
22:12AnniepooThe page http://clojure.org/evaluation says
22:13AnniepooThe loading functions occur in a temporary context, in which *ns* has a fresh binding. That means that, should any form have an effect on that var (e.g. `in-namespace), the effect will unwind at the completion of the load.
22:13leafwwhat could be an efficient way of searching a table for for keys that match a specific regex?
22:14leafwdo I have to loop all keys, or are clojure keys somehow different? PArticularly if searching for a "starts with" predicate?
22:17AnniepooI can't figure out what this means. It obviously doesn't mean I can't put (def foo 7) in a file and load it and have
22:17Anniepoofoo be 7 afterwards.
22:17hiredman:/
22:18hiredmanannoyingly the developement appengine environment doesn't seem to want me to delete records from the datastore
22:19_atoleafw: you'll have to loop all the keys in the general case. If you really wanted I guess you could implement something that speeds up partial matches, but Java's standard regex library won't do that for you AFAIK. You might be able to find another java library that does it though
22:19_atos/partial matches/prefix matches/
22:20Anniepoodoes it mean simply that *ns* will be rebound to some local version, so if you do in-namespace it won't have any effect?
22:21somniumhiredman: what's your url?
22:21_atoAnniepoo: yes.. it just means if you do (ns bar) (load-file "foo.clj") (def x 3) and foo.clj contains (ns foo), then x will be decalred in namespace bar not namespace foo
22:22hiredmansomnium: my url?
22:22somniumis your site up on ae?
22:22hiredmanyes
22:22hiredmanbut the only thing that works right now is a single facebook app
22:22Anniepooah, ok, thanks
22:22somniumhiredman: I want to look at it :)
22:22konr!proxy
22:23hiredmanapps.facebook.com/agegraph I think
22:23konrclojurebot: proxy
22:23clojurebotproxy is <Chouser> proxy teases with its ease of use, then suddenly betrays.
22:23_atoAnniepoo: but if foo.clj contains (ns foo) (def y 4) then y *is* declared in ns foo. It's just means changes to *ns* within a loaded file don't leak out of that file
22:23Anniepoook, yes
22:24Anniepooeffectively load-file contains
22:25Anniepooa wrapper that binds *ns* locally
22:25_atokind of like: (let [old-ns *ns*] .... do the load .... (ns old-ns))
22:26Anniepookk, got it
22:29AnniepooOooh!
22:34leafw_ato: I suspected so. Thanks in any case.
22:38mikehincheyAnniepoo: hi!
22:38Anniepoo8cD
22:41djorkinteresting, chouser
22:42djorkI guess always had the sieve right in my head and wondered why examples were usually wrong
22:42djorkoh wait that was at 3:11... way to go, me
22:44AnniepooI bet this is one line somehow. I want to write (load-without-side-effects [reader]) that does a load but doesn't allow any side effects (modulo java interop)
22:45krumholtis there a way to just write (parseInt "5") instead of (Integer/parseInt "3")
22:45slashus2create a wrapper function
22:46somniumI think there's a static import function somewhere in contrib
22:47somnium,(doc import-static)
22:47clojurebot"clojure.contrib.import-static/import-static;[[class & fields-and-methods]]; Imports the named static fields and/or static methods of the class as (private) symbols in the current namespace. Example: user=> (import-static java.lang.Math PI sqrt) nil user=> PI 3.141592653589793 user=> (sqrt 16) 4.0 Note: The class name must be fully qualified, even if it has already been imported. Static methods are defined as MACROS, not
22:48krumholtcool thanks
22:48somniumhmm, it makes macros though, so it might not do what you want
22:49krumholtthats exactly what i want :0
22:49krumholtthanks
22:57_atoAnniepoo: I don't think that's possible, well unless you somehow sandbox the file so the only functions available to it are ones that can't have side-effects. Is there a particular use-case you have for this?
22:57Anniepooyes
22:58Anniepooif I can make such a thing, then I can make a sandboxed repl
23:00Anniepoowhich could make a wonderful tool for making web stuff - you interact with me by sending clojure code
23:00_atoyou could have a look at what clojurebot does: http://github.com/hiredman/clojurebot
23:00_atobut I don't think it's easy
23:00Anniepooalready have done so
23:01Anniepoono, it's not turning out to be, but I'm digging
23:01AnniepooGeorge Jahad gave a talk about server-socket at last clojure meetup, inspired me,
23:02Anniepoothis seems like a nice remote agent mechanism.
23:07AnniepooIt seems like it should be the sort of thing that's 25 lines of file and net IO stuff and 6 completely incomprehensible lines that do the real work
23:09Anniepoobut it's being icky
23:10Anniepoowell, I'm done 4 2day
23:10Anniepoonighte
23:22leafwhum
23:22leafwhow to call super in a proxy ?
23:22clojurebota is b
23:24leafwclojurebot: zen ?
23:24clojurebotExcuse me?
23:24leafwnot zen enough.
23:25chouser,(doc proxy-super)
23:25clojurebot"([meth & args]); Use to call a superclass method in the body of a proxy method. Note, expansion captures 'this"
23:25chouserleafw: be careful, that's not thread-safe.
23:26tomojhum, why not?
23:28leafwthanks chouser
23:53_atogood grief, Chousuke's reader exception is non-deterministic, each time I run it it happens in a different place
23:55hiredmantime to start disabling pieces