#clojure logs

2009-02-28

00:10durka42what does "the oft-requested letrec" do?
00:13ayrnieudurka42 - all the bindings established by let are visible within their definitions.
00:14durka42so you can let things like fibs?
00:14ayrnieuwell, that isn't a very interesting case, because it's only one binding.
00:15ayrnieu(letrec [even? #(if (zerop %) true (not (odd? (1- %)))) odd? #(if (zerop %) false (not (even? (1- %))))] (even? n))
00:17durka42so all the bindings have to be forward declared or some such magic?
00:18ayrnieuletrec isn't a function; it isn't that the definition of even? is evaluated and then the definition of odd? is. The magic is just the usual business of deciding when bindings are made and what they're visible to.
00:20ayrnieuCL has a LET that doesn't expose its bindings until after they're mind, and a LET* that exposes them sequentially. So (let ((a b) (b a)) ...) renames a B and A defined outside this let, whereas the LET* variant would give you two names for outer-b
00:23ayrnieuso does clojure have letrec now, or is it still oft-requested?
00:24durka42rhickey added an issue
00:24durka42i take it is not a synonym to the scheme letrec
00:25ayrnieuwhy do you take that?
00:28durka42i thought scheme letrec named the let so you could refer to it from within itself
00:29durka42e
00:29ayrnieuscheme's letrec is as I described. The EVEN?/ODD? example comes from t-y-s-i-f-d.
00:29ayrnieuteach yourself scheme in fixnum days.
00:30ayrnieuscheme also has named lets, but clojure has these already.
00:30ayrnieudurka - you might implement letrec in clojure as an exercise. At least at a toplevel macro, it should be very easy.
00:33danlarkinwhy wouldn't clojure's let just gain letrec functionality instead of gaining letrec? Is it that much less efficient?
00:34msinghhello is there any example code to look at that uses java sound? i'm interested in writing a small multiplatform audio comm app for voicing because there is nothing that i've tried works on linux
00:34ayrnieudanlarkin - it is *different* functionality.
00:35danlarkinayrnieu: oh, it breaks something that normal let gives you?
00:36ayrnieu,(let [a 1 a (inc a) a (inc a)] a)
00:36clojurebot3
00:36danlarkinI thought it just added more functionality: the ability to have recursive definitions
00:36durka42does this page apply? http://neilmitchell.blogspot.com/2007/03/let-vs-letrec.html
00:36durka42The rule is that in a letrec you introduce the names you are defining before computing their values (so the x = x refers to itself), but with let you only introduce the names once you get to in (so the x = 1 is still in scope).
00:38danlarkinI guess my understanding of letrec was a little off
00:38ayrnieu,(let [a 1] (let [b (inc a) a 1] [b a]))
00:38clojurebot[2 1]
00:39ayrnieuboth of these examples would be different in with letrec.
00:40ayrnieurhickey could decide that clojure's `let bind the way letrec does (the way he's already decided that it bind in the way of CL's LET* instead of its LET), but this is not a simple move 'upward'.
00:41durka42sorry, how would that last example be different? (inc a) would apply to the second a, which is still 1
00:42ayrnieuit's a shifting around of hassles. I think it's not unreasonable to say that letrec's hassles are more bearable in clojure that its present hassles. But if he does decide to do this, he should decide pretty quickly. It's a breaking change that hard to look for.
00:42ayrnieusure, the second a should be something else.
00:43ayrnieu,(let [a 1] (let [b (inc a) a :parrot] [b a]))
00:43clojurebot[2 :parrot]
00:43durka42if the inner let was letrec, ClassCastException
00:45ayrnieuanyway, you can write letrec in clojure, definitely as a top-level macro. Have (let [even? #(...) odd? #(...)] (defn integer-filter [...] ... even? ... odd?)) resolve to (do (forward-declaration odd?) (defn GENSYM_even? ...) ... (let [even? GENSYM_even? odd? GENSYM_odd?] ...))
00:53banisterfiendhey guys anyone know a tutorial that 'll tell me how to get clojure up and running on a debian linux system?
00:54ayrnieubanister - clojure.org -> wiki -> getting started.
00:54durka42~pl
00:54clojurebothave you heard about the bird? is<reply>The bird, bird, bird, the bird is the word.
00:54durka42~transform
00:54clojurebotIt's greek to me.
00:55durka42clojurebot: transform is http://github.com/hiredman/odds-and-ends/blob/8a84e6ddbad9d71f714ba16c3e1239633228a7eb/functional.clj
00:55clojurebotAlles klar
02:01bradbevI'm trying to use files in my project, like (ns memorytool.unit-tests (:refer memorytool.simheap)), and I want to do (simheap/foo 1 2). I can't figure out how to use :as.
02:03Chouser(:use [memorytool.simheap :as simheap :only ()])
02:03Chouseror more conventionally, (:require [memorytool.simheap :as simheap])
02:04bradbevah, thanks very much. That's the only thing I miss about Clojure's documentation - small examples of common usage
02:04durka42~api examples
02:04clojurebotexamples is http://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples
02:04Chouseryeah.
02:04durka42(not complete)
02:05Chouseralso, contrib
02:05bradbevah, that's cool - I didn't know about that
08:30blbrownrhickey, how do you feel about strong static typed languages like haskell or scala. They offer completely different styles from clojure/lisp. Are there places to use one style or the other
08:31blbrown...question directed to anyone else that is up, also
08:31ChousukeI like haskell's system.
08:31blbrownand ideally with haskell's type inference, you don't have to necessarily set the type for each function, etc
08:32ChousukeI think type inference is necessary for static typing not to be a nuisance :P
08:32blbrownyea
08:33blbrownChousuke, are there are apps where you might use haskell and then apps where you might use haskell. Actually I could see myself using scala for a server project I want to write
08:34blbrownscala is being used at Twitter, but I don't have all of the details
08:35Chousukehmmh
08:35ChousukeIt's difficult to say outright when static typing is better than dynamic typing.
08:36blbrownor vice versa
08:36Chousukeyeah.
08:37bOR_(apply concat \A 1 "a")
08:37bOR_?
08:37bOR_wonder what you can't do statically that you can do dynamically.
08:37blbrownChousuke: this is just my own subjective opinion, but clojure is certainly going to be a lot lighter and easier to work with. I am using clojure for GUIs and web development. I could see where scala/haskell could be used more for backend/server development
08:38blbrownI hear a lot, that lisps are good at bottom up programming
08:38rhickeyblbrown: the whole trick with type systems is expressivity - do they let you do what you want? Are the benefits they provide worth the complexity, time and effort? Do they introduce rigidity into the system as a whole? I'm not opposed, and think Haskell is fascinating
08:38ChousukeWith dynamic typing it's easy to misuse a function. in Haskell at least the type system ensures that functions are used where they make sense.
08:38Chousukeand nonsensical stuff is caught before runtime
08:39Chousukeon the other hand, overriding the type system when it's wrong about something is not as easy.
08:40blbrownChousuke, it also gives you a bit of flexibility
08:40bOR_much still to learn in the computer science department for me :).
08:41blbrownwhateve the case, architecture wise, there is no reason why you can't built a multi-language app. Clojure and Haskell. Clojure and Scala. Clojure and Java
08:41blbrown...based careful analysis and a need to do so, of course
08:43ChousukeYou said you use Clojure for GUIs and web development; I think dynamic typing fits interactive programs well.
08:44blbrownexactly
08:44Chousukeyou might have many input sources and callbacks and whatnot, and dynamic typing allows for a simpler interface because you don't have to worry about typing.
08:45blbrownclojure is the new smalltalk, hehe
08:47rhickeyE.g., what is the 'type' of Clojure code-as-data? All those nested heterogeneous collections etc. It's not hard to understand, but difficult to express using types (at least without abandoning them to a universal unifying type)
08:50bOR_taking a break from writing, and reading up on wikipedia / type system to catch a bit of the background :).
08:50blbrownhmm, so the coding style associated with clojure doesn't really lend itself to having to define the types, which is fine.
08:53Lau_of_DKGuys - Im having a little trouble incorporating jMEPhysics 2 with jME 2.0 - Any one here who's got any experienco ?
09:04Chouserblbrown: I don't know that clojure's collections are any less suited for static typing than Java's, it's just that we never bother declaring or casting.
09:05Chouserit might be an interesting excercize to try to write a DSL for asserting collection types.
09:05blbrownChouser, I need to write a larger app in haskell and see if there are differences
09:06leafwChouser: about the latter ... I had some not-so-nice experiences developing with clojure. For example, unless one is developing the program interactively, parts of the program may never be executed -- and bugs creep in that only show at run time. And some of this bugs are of the class/type kind, that a compiler or an IDE should catch.
09:06ChouserThe simplest implementation would just be runtime checks, but it would allow you to play with the syntax to find something succinct and pleasing.
09:06leafwIMO, clojure is missing a nice IDE. What is the state of enclojure for net beans? And has net beans a proper text editor (like vim or emacs) integrated?
09:06Chouserleafw: yes, but if code is never run there can also be errors that the compiler and IDE won't catch.
09:07blbrownleafw, it is how you are coding that might introduce those bugs. For example, using TDD. Code a little, test a little, code a little helps a lot with clojure and other lisps
09:07Chousera static typing compilier may catch some, but if you still need unit tests, and those unit tests would have caught the error too, what's the benefit of the static typing?
09:07blbrownsame is kind of true for python or ruby
09:07leafwblbrown: I know, but one needs a nice IDE to do that. I should change to emacs just for that ... I use vim most of the time.
09:08blbrownI use emacs and vim, I haven't needed anything else
09:08blbrownof course, eclipse for project management
09:08leafwChouser: I know; static typing is like a premature optimization, and an IDE should attempt to catch them all anyway.
09:08Chouserthere's jvi that works with netbeans. last I tried it with enclojure it didn't work so well, but that may have changed.
09:09blbrownleafw, I see your point and had the same issue with python, when I started with that 10 years ago. But learned to use different coding styles when working with dynamic languages
09:09ChouserI submitted a patch ages ago, but I don't know if it ever went in.
09:09leafwguess I spent too much time doing things, even if slowed down, than testing IDEs that would speed me up.
09:09leafwblbrown: I had the same situation with python, is one of the reasons I don't use it so much (except for Blender).
09:09blbrownand I never was a big fan of debuggers, so I normally don't use those anyway. Unless debugging a complex web app
09:10leafwblbrown: debuggers for C are a must; at least for me.
09:10blbrown...one thing I thought about trying, kind of related. Is using a design by contract development style
09:11leafwblbrown: most of the time I develop in a exploratory way; no constraints (which has its good and its bad sides)
09:11Chouserleafw: most of my C experience was network device drivers. debuggers were almost completely useless, because as soon as you breakpoint the code, the world has already changed.
09:12leafwxD indeed. I am lucky then that all I do is crunching numbers.
09:12bOR_question about a stack overflow I am causing with merge-with.
09:12bOR_(apply merge-with concat (mapcat adaptedness (subvec (vec (gather :born)) 0 20)))
09:12bOR_works fine
09:12bOR_but somewhere between a vector of 2500-3000, it gives up.
09:13bOR_I've the code here, so I can parse more details if you need them.
09:13bOR_{(#{\A \B \C \D \E \F \G \H} #{\A \C \D \E \F} #{\A \C \D \E \F \G \H} #{\B \D \E \F \G \H} #{\A \B \C \D \E \F \H} #{\A \B \C \D \E \G \H} #{\A \F \H} #{\A\ \E \F \H} #{\A \B \C \D \E \G \H}) (5.660244012764965 5.935697382497301), (#{\A \C \D \E \F \G \H} #{\A \B \C \E \F \H} #{\A \B \C \D \E \F \G \H} #{\B \C \ \D \E \F \G} #{\A \B \C \D \F \G \H} #{\A \B \C \D \E \G \H} #{\A \B \C \D \F \G \H} #{\D \E \F} #{\A \C \D \E \
09:14bOR_that is its output: a hash-map in which the key is a particular pattern/genotype, and the val is a list of viral loads associated with that genotype.
09:15bOR_so it is doing what I want to do.
09:15bOR_but not for all 5000 hosts :).
09:15drewrChouser: On the contributors page, can you change mtndrew0 -> aaraines?
09:16Chouserdrewr: Based on the word of a random IRC nick? :-) Sorry, I don't know the rules.
09:16drewrhaha
09:17drewrThat was my sf ID, but since we're using Google now, I thought I'd use my Google one.
09:17drewr...and hate to bother rhickey for trivial changes like that.
09:18ChouserI think that's a good change to make, as then it matches your name on the issues page, but I don't know what kind of auth rhickey needs for that. Possibly email from that address asking for the change? I don't know.
09:18drewrThat's fine, I'll email.
09:20drewrMake sure you check the headers of my message though. :-)
09:24bOR_hmmm. managed to circumvent the stack overflow by splitting my population in 3, doing the apply merge-with concat on each subpopulation and then doing an apply merge-with concat on the three answers.
09:25Chouserick
09:26bOR_aint going to win any pretty-prizes :P.
09:26ChouserbOR_: can you put together a small runnable example that shows the problem?
09:26bOR_should be possible. I'll make a pot of tea and do that :).
09:30rhickeybOR_: mmmm, tea
09:32bOR_hehe
09:32bOR_water finished cooking, example done
09:32bOR_pasting it now :)
09:32bOR_(def noworld (map #(hash-map (rand-int 10) [%]) (range 25000)))
09:32bOR_ef yesworld (map #(hash-map (rand-int 10) [%]) (range 15000)))
09:33bOR_(apply merge-with concat yesworld)
09:33bOR_(apply merge-with concat noworld)
09:33bOR_that ef should be a def
09:33bOR_the yesworld works fine, the noworld gives a stackoverflow :)
09:34bOR_somewhere at concatting 2000 values to a single hashkey breaks it.
09:34Chousukemaybe try to make it less lazy?
09:35bOR_how would I do that?
09:35ChouserbOR_: nice, thanks for the example.
09:35ChousukebOR_: use doall
09:36Chousukelike that, your world is just a lazy seq, so perhaps it'd help to realise it.
09:36Chousukethat puts it all in memory at once though.
09:36bOR_well, in the model, my world is a large vector of agents.
09:37bOR_is that the part you want me to make less lazy? not sure if I can change much there.
09:37Chouser,(apply merge-with concat (replicate 25000 {1 2}))
09:37clojurebotEval-in-box threw an exception:java.lang.reflect.InvocationTargetException
09:37Chouserhm. that overflows for me
09:38Chousukehmm :/
09:39bOR_shouldn't it be {1 [2]} ?
09:39Chouseryes
09:39bOR_can't concat 2.
09:39bOR_nod
09:40Chouseroverflows either way, though, which is interesting.
09:42bOR_yeah, I wondered why. it has to remember three hashmaps. the collector, the first of the seq, and the rest of it. not sure why that would overflow.
09:42Chouser(reduce concat (replicate 25000 [2]))
09:43bOR_stack overflow as well here.
09:44Chouseryep, it's concat on more than 2 args that's recursive
09:44bOR_at quite a bit lower numbers than apply concat (replicate ..
09:44bOR_ah.
09:44Chouseroh, but... hm...
09:44bOR_am I supplying more than two args?
09:44bOR_hmm.
09:45Chouseroh!
09:45Chouserhm.
09:45Chouserno
09:59Chouseras soon as you realize a concat seq, it calls 'rest' on its first arg, which realizes the next lazy-seq, ... *boom*
09:59bOR_hehe.
10:00bOR_is it absolutely neccesary that it does that?
10:01Chouserseems likely there's another way to do it, but I haven't thought of it yet.
10:03rhickey(reduce concat ...) != (apply concat ...), for same reasons as (reduce str ...) != (apply str ...)
10:04bOR_noticed that. at first I switched to reduce rather than apply to see if that helped.
10:05bOR_(I know I don't know the difference well enough between the two, but that there was a forum post that explained it quite well if I needed to know the difference better)
10:05rhickeywhat's the failing case with apply?
10:07bOR_(apply merge-with concat (replicate 2500 {1 [2]}))
10:08rhickeybOR_: no problem here - are you trying to print it or something?
10:09bOR_hmm. if you use a larger replicate number than 2500?
10:09bOR_I'll see what happens if I just want it stored in a def.
10:09bOR_yes.
10:09bOR_matters if I just enter it in the repl, or send it to a def
10:10bOR_ahh.
10:10bOR_lemme see if that is the only problem in the original case as well.
10:11bOR_yep. it is the printout that happens in the repl that causes the stackoverflow.
10:11rhickey(count ((apply merge-with concat (replicate 250000 {1 [2]})) 1))
10:11rhickeyStackOverflowError
10:12bOR_what is with the (( ?
10:12bOR_don't see that too often in code.
10:13bOR_hmm.
10:13bOR_never mind my confusion :)
10:13rhickeyconcat is such a bad operation for this
10:13bOR_it is only in a reporting function that I call once every 5 minutes.
10:14rhickeyuser=> (count ((apply merge-with into (replicate 250000 {1 [2]})) 1))
10:14rhickey250000
10:15bOR_into seems to work fine :)(
10:16bOR_what makes concat bad to use in this case?
10:25bOR_anyway, thanks for solving it. The endresult works fine: (mKsdge:#2703:^0.927:@6.40 mKsdqq:#1105:^0.515:@5.53 mKsdhj:#781:^0.422:@6.41 mKsdiP:#3\ :^0.252:@6.51)
10:28rhickeybOR_: it's expensive to add to the end of a list - we don't build up lists by saying (concat (concat (concat (concat () '(1)) '(2) ) '(3) ) '(4))
10:28rhickeywhich is effectively what you are asking for with reduce concat
10:36bOR_still a bit above my comfort level, but I'll keep it in mind. can't tell for example why into does fix this, but I'll figure that out over time.
10:38Chouservectors are efficient for adding onto the right-hand side, which is what into does on a vector.
10:38bOR_ah. getting it. and concat is adding at the end of a list.
10:39bOR_so if the place in the list doesn't matter to me, conj would have been fine as well.
10:40bOR_because adding lefthand side in lists, is fine.
10:40bOR_nod.
10:40Chouserright. into and conj always add in the way that's efficient for the collection being used.
10:41bOR_I'll remember.
10:47Chouserthe implementation of 'for' is hard to understand.
10:47rhickeyChouser: sorry
10:48Chouser:-)
10:48ChouserI've successfully patched it either without fully understanding it, or have since forgotten what I knew.
10:49ChouserI really want to tease out the shared structure between it an doseq.
10:50clojurebotsvn rev 1313; swtiched to url.openConnection().getLastModified
10:57thrrhickey: I suppose you hear this hundreds of times a day, but I just started learning clojure (comming from C# and Python, wierd combo I know) and I've got to say this is... amazing, thanks so much for all your work!
10:57rhickeythr: you're welcome!
11:11thrBtw, Am I allowed to ask "newbie"-style questions about clojure in here? Reading about it and trying out examples and find something that is a bit ambigius to me
11:12Chouserthr: sure
11:12thrI have this example that adds an extra metadata tag to shout: (defn #^{:tag String} shout [#^{:tag String} s] (.toUpperCase s))
11:12thrDisplaying it with ^#'shout seems to work fine
11:12thrbut the thing that got me was the fact that #^{:tag String} is infront of the symbol s in the argument list also
11:13thrremoving the #^{:tag String} from the argument vector, everything still seems to be the same when running ^#'shout in the repl
11:14Chousukethe latter actually applies to s
11:14thrYeah I figured that, but where is it any good ?
11:14thrI mean, you can't access s anywhere
11:14leafwcan one specify the return type of a function? That is news to me
11:14Chousuketype hinting.
11:14thrChouser: aha!
11:14thrThanks
11:15Chousukethough That's usually done with #^String isn't it? :/
11:15Chouserthose are type hints. If Clojure can't tell what method to call because of insufficient type hints, it will figure it out at runtime.
11:15ChouserChousuke: yep, that's a shortcut for what he's got.
11:15blbrownstupid general question: with clojure (defn abc [something] (.doIt something)) ...(abc something1-obj) ... (abc something2-obj) ...being able to call abc on two different objects. would that be considered 'polymorphism' or something else. And should lisp be used in this fashion. Or is defmethod a better tool for that
11:16Chouserthr: the defn macro actually can access the metadata on s
11:16thrThanks a bunch for the help guys, most appriciated
11:18Chousukeblbrown: I guess that's polymorphism, yes. and it's perfectly fine
11:20Chousukeblbrown: defmethod is for when you want *different* behaviour based on some function of the parameters
11:20Chouserif something1-obj and something2-obj are two different classes, with their own doIt() method definitions, that's normal Java polymorphism.
11:20blbrownChousuke, I am working on a small test framework. I can create simple mock objects for the test cases and then pass the mock objects to my library functions. But in the real world, I can just use the real objects
11:21blbrownkind of an interesting approach
11:21ChousukeChouser: except they don't even have to have a common parent.
11:21Chousukeor implement a common interface.
11:21blbrownChouser, yea, what chousuke said
11:22Chousukefor testing java?
11:22blbrownand I guess with other lisp's it may not be as prevalent because those lisp aren't wrapped around an object oriented language runtime
11:23Chousukethere are many clojure test frameworks that do just fine without mock objects :)
11:23blbrownChousuke, I don't really need mock objects, but I could if need be
11:25blbrownChousuke, defmethod seems more like how erlang's pattern matching works
11:28Chousukedefmethod does no pattern matching though.
11:29Chousukebut I don't know Erlang so I can't say much
11:30blbrownChousuke, it seems like it
11:30cemerickis it the case that array classes cannot currently be used as part of gen-class method or constructor signatures?
12:15blbrownwtf is waterfront
12:16gnuvince_An editor
12:24blbrownah
12:52danlarkinLau_of_DK: Nantes?
13:08Lau_of_DKdanlarkin: What does that mean ?
13:09danlarkinit's a city in France
13:12Lau_of_DKIts not bad - Dont know the city though - How 'bout Tokyo ?
13:15Lau_of_DKdk.bestinclass.sofiaba> (Vector3f. 1 1 1)
13:15Lau_of_DK#<Vector3f com.jme.math.Vector3f [X=1.0, Y=1.0, Z=1.0]>
13:15Lau_of_DKdk.bestinclass.sofiaba> (Vector3f. (apply float [1 1 1]))
13:15Lau_of_DK; Evaluation aborted.
13:15Lau_of_DK
13:15Lau_of_DKWhats the trick ?
13:26Chouserwhat you have there is the same as (Vector3f. (float 1 1 1))
13:26Lau_of_DKYea ... so whats the trick ?:)
13:26Lau_of_DKIts a destructuring of some kind I need
13:36Chouser(defmacro mapmac [t f c] (cons t (map (eval f) c)))
13:36Chouser(mapmac Vector3f. #(do `(float ~%)) [1 1 1])
13:38cmvkk,(- 1.33 1)
13:38clojurebot0.33000000000000007
13:40cmvkkis that just some weird floating point thing or what?
13:57durka42looks like floating point stuff to me
13:58cmvkkis there any good way to take x.33 for any x and reliably return 0.33?
13:58cmvkkmaybe it's just me, but i feel like that ought to be feasable...
14:00durka42you could use fixed-point math...
14:00durka42,(- 1.33M 1M)
14:00clojurebot0.33M
14:00cmvkkoooh
14:00durka42which is weird because...
14:00durka42,(- (BigDecimal. 1.33) (BigDecimal. 1))
14:00clojurebot0.3300000000000000710542735760100185871124267578125M
14:01cmvkkheh
14:01durka42apparently bigdecimal literals are not just bigdecimal literals
14:01durka42,(= 1.33M (BigDecimal. 1.33))
14:01clojurebotfalse
14:02cmvkkwell
14:02cmvkk,(BigDecimal. 1.33)
14:02clojurebot1.3300000000000000710542735760100185871124267578125M
14:03cmvkkit isn't the same number anyway.
14:03durka42right that's why i was confused
14:03durka42i guess it's because 1.33 literal is converted to a double first and then a bigdecimal
14:03dreishThat's the exact value of the floating-point number 1.33.
14:03durka42instead of
14:03durka42,(BigDecimal. "1.33")
14:03clojurebot1.33M
14:03cmvkkoh hmm
14:11thrHow are clojure vectors implemented? I assume lists are linked lists, but vectors?
14:11dreishThey're actually trees.
14:11thrOk, thanks
14:12thrdreish: you know what tree algorithm they're implemented as?
14:12thr(just curious, not that it matters for me at this point ;p)
14:13dreishI can't remember what it's called, but they're 32-way trees. You can see the code in PersistentVector.java
14:13dreishIt's pretty clever.
14:13thrOk, thanks a bunch - yeah figured it'd be clever ;p
14:13thrjust curious of the inner workings for no other reason than it's fun to know
14:13dreishIndices 0-31 go in the root node, then 32-63 in the first child of that node, etc.
14:14dreishI think. I might be describing it incorrectly.
14:14thrHm... I'd figure it would be a b-tree with 31 slots per node
14:15thrBecause I think the way you said would give horrible performance when searching
14:15thrnot sure though, semi-professional-guess
14:15dreishReally?
14:15dreishYou always know exactly what path to follow to get to a given index.
14:16thrAh, I totaly missunderstood you
14:16thrI thought you ment 0-31 (root) -> 32-63 (31) etc.
14:17dreishThe code in clojure/lang/PersistentVector.java is more authoritative than anything I could say about it.
14:18thrYeah Ill go check it out, love digging around in the inner works of stuff
14:18dreishThat's one nice thing about Clojure -- it's small enough that that's easy to do.
14:18thrYeah, I've just been toying with it for not very long, and it's my first Lisp but I do really enjoy it so far
14:19kotarakthr: may be of interest to you: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/
14:20thrthanks :)
14:21pjb3so, there's no way to use binding with out a root binding, right?
14:21pjb3,(binding [x 1] x)
14:21clojurebotjava.lang.Exception: Unable to resolve var: x in this context
14:22dreishOh, of course, the root node _becomes_ the first child node once the tree expands past 32 items.
14:24thryeah that is clever
14:25thrAnd the implementation is only ~200 lines? Goddamn I'm impressed
14:26rhickeypjb3: you can use binding without a root binding, but not without a var: (def *v*) ... (binding [*v* foo]...)
14:26Lau_of_DKkotarak: Sweet article, thanks
14:27kotarakLau_of_DK: it's not by me, of course. I just saw some weeks ago in reddit.
14:27pjb3rhickey: right, ok
14:27Lau_of_DKrhickey: The 0.5F issue we discussed isnt a pressing as I thought, it seems in most cases Java will automatically convert doubles to float when needed
14:27cmvkki need a data structure i can use as a queue but still has good random access. I was using a vector but it keeps overflowing the stack. Maybe i'm doing it wrong?
14:28dreishcmvkk: PersistenQueue.
14:28dreisht
14:28rhickeydreish: PQ doesn't have random access
14:28dreishOh, I didn't notice that.
14:29dreishWouldn't it be easy to add, since it's just a seq on a vector plus a vector?
14:29cmvkki was pushing with conj and popping off the beginning with subvec. is the fact that this blows the stack expected?
14:34rhickeycmvkk: currently, subvecs stack, i.e. subvec on a subvec on a subvec builds a chain, will fix...
14:41Lau_of_DKIts the cemerick! :)
14:42cemerickTHE cemerick?
14:42cemerickI've noticed a couple of people with handles like that -- the_joe_smith, etc.
14:43ChouserThe Astute Chas, of the House of Emerick.
14:54Lau_of_DKcemerick: Since you got that mention from Norvig I figured you'd go with The Cemerick from now on :)
14:55cemerickheh. The fanboy glee has since faded. :-)
14:56WizardofWestmarcmention from Norvig?
14:57mattreplwhat Norvig mention is this?
15:01arohnermattrepl: http://norvig.com/ibol.html
15:01arohnerhttp://blog.snowtide.com/2009/02/26/whoa-peter-norvig-used-some-of-my-code
15:06mattreplnice, congrats, cemerick. didn't connect your real name to you when read first time
15:06arohnerwhat's the syntax if I want a macro to refer to a symbol?
15:06arohner~'foo ?
15:06clojurebotexcusez-moi
15:07dreishFor symbol capture, yes.
15:07Lau_of_DKI have a macro which generates code, which produces some data, I want to call this macro from a function, but I dont want the resulting code, which generates data, I want the data - How do I do? (eval (mymac foo bar)) doesnt do it
15:07cemerickmattrepl: thanks
15:07dreisharohner: It's filthy, but I do it all the time. :)
15:08arohnerdreish: I'm doing it for a one-off that will only be used on this page
15:08arohnerit cleans up the code significantly IMO
15:08dreishYeah, sometimes it really is useful.
15:08cemerickLau_of_DK: try (eval '(mymac foo bar))
15:09cemerick,(eval '(and false true))
15:09clojurebotDENIED
15:09cemerickeh, it doesn't allow eval
15:09cmvkkheh
15:09WizardofWestmarcHah that's really cool cemerick :)
15:09cmvkkwhy doesn't the macro get evaluated automatically?
15:09durka42Lau_of_DK: what does the eval do? i would expect that to work
15:10kotarakLau_of_DK: why is it a macro generating data not a function?
15:10Lau_of_DKIts the only way to go because I need some destructuring
15:10clojurebotsvn rev 1314; avoid chaining in subvec of subvec
15:10cmvkkyeah but, when a macro returns code, that code is evaluated right then, right?
15:11cmvkkooh thanks rhickey
15:11rhickeycmvkk: its' still not a queue though
15:11dreishThat was sudden. :)
15:12Lau_of_DKCemerics trick, did it
15:12cmvkkno; well i don't know how else to do what i want to do in any sort of efficient way
15:12rhickeysince memory is not reclaimed from front
15:12Lau_of_DKcmvkk: I thought so - but no
15:13cmvkkoh. i don't suppose it would be a good idea to use (into [] (rest myvec)) instead?
15:13durka42(eval '(mymac foo bar)) is the same thing as (mymac foo bar), isn't it?
15:13durka42maybe (mymac 'foo 'bar)
15:13rhickeycmvkk: no, would be very bad perf
15:13cmvkkyeah, that's what i thought
15:14cmvkkbut anything rest returns is O(n) random access?
15:14arohnerdoes the #() form work inside of macros?
15:14ayrnieu,`(does #(%) work?)
15:14clojurebot(sandbox/does (fn* [sandbox/p1__2847] (sandbox/p1__2847)) sandbox/work?)
15:14rhickeycmvkk: right, seqs are linear access
15:15arohnerayrnieu: I did that, but got "can't use name as qualified parameter"
15:15ayrnieuarohner - what do you get that from?
15:15ayrnieuoh, actually, I see
15:16arohnerand translating to "normal" (fn [x#] x#) works fine
15:21ayrnieu`(does (fn [%] %) work?)
15:21ayrnieu,`(does (fn [%] %) work?)
15:21clojurebotarg literal not in #()
15:21ayrnieuhuh.
15:21ayrnieu,`(does (fn [a] a) work?)
15:21clojurebot(sandbox/does (clojure.core/fn [sandbox/a] sandbox/a) sandbox/work?)
15:21durka42(fn [a] a) != #(%)
15:23dreishrhickey: There's no technical reason with a little reworking nthrest couldn't be made O(1) for seqs on random-access structures, right? Just hasn't been done?
15:24rhickeydreish: for what purpose?
15:24rhickeyseq + subvec
15:24dreishrhickey: None right now. It was just a thought -- I don't really care when if ever it happens.
15:29ayrnieudreish - even if it were O(1), a series of nthrests on a random-access structure would require memory allocation. nthrest makes sense for sentineled data structures -- C strings, cons lists, where every subrest is already a proper data structure.
15:47Lau_of_DKhttp://paste.lisp.org/display/76291 <-- Could someone, with macroskillz like rhickey, please tell me why this boorks - I really dont understand how evaluation is handled
15:48kotarak(eval `(>RGBA ~v))
15:50Lau_of_DKUnable to resolve v in this context
15:51ayrnieuLau - look at (macroexpand-1 '(>RGBA v))
15:52ayrnieuyou don't need to use eval; the bare macro is sufficient.
15:55Lau_of_DKayrnieu: Thats gives me that ISeq error
15:57ayrnieuOK, now try (ColorRGBA. (map (fn [x] `(float ~x)) 'v)) :-)
15:58ayrnieuyou're doing work at macroexpansion time. You don't have the value of v at macroexpansion time -- you just have 'v itself.
16:00kotarakclojurebot: eval
16:00clojurebotPardon?
16:00kotarakclojurebot: eval is evil
16:00clojurebotc'est bon!
16:01kotarakclojurebot: eval is also sometimes useful - but only sometimes
16:01clojurebot'Sea, mhuise.
16:01durka42clojurebot: eval is also DENIED
16:01clojurebotAck. Ack.
16:01Lau_of_DKHmm, Im further now, but my setup is too complicated to see if its entirely working atm, but big thanks to ayrnieu and kotarak :)
16:02kotaraknp
16:03Lau_of_DKGuys - its working, love this community
16:04Lau_of_DKI new have a beautiful 3d island, fully detail textured, rendered on a slowly moving pacific ocean! :)
16:04Lau_of_DKk
16:04slashus2screenshots?
16:05Lau_of_DKHang on
16:06slashus2Lau_of_DK: Are you sure that you had to use a macro in that case?
16:08WizardofWestmarchm, strange
16:08WizardofWestmarctrying to get clojure working in my ubuntu vm... and when I load slime it looks for util.clj
16:09slashus2(defn >RGBA [vektor] (ColorRGBA. (map (fn [x] (float x)) vektor))) won't work?
16:09Lau_of_DKhttp://wiki.github.com/Lau-of-DK/sofiaba
16:10Lau_of_DKslashus2: There u go - And yea, I needed a macro, which will be used several places for more than just this purpose
16:10durka42awesome
16:10durka42it looks... grainy
16:11Lau_of_DKYea - texture is too detailed
16:11Lau_of_DKI think it'll work once I scale it up to full playable size
16:13durka42what's the speed like?
16:13Lau_of_DKIts like... awesome
16:13Lau_of_DKBefore I added the water it ran at about 800 fps, I havent tested, but I'll add an fps counter soon, Im just in the middle of wrapping and extending functionality
17:01dpthfltrok this is going to be a very very simple question ;) I have two strings and I want to create a seq that contains both.
17:01dpthfltrwhat function can I use ?
17:02rhickeydpthfltr: (list s1 s2)
17:27hiredman,(into-array Character/TYPE "foo")
17:27clojurebot#<char[] [C@14d0183>
17:30Lau_of_DKhttp://github.com/Lau-of-DK/sofiaba/tree/master, for those following this, Ive pushed a massive change provinding quite a few wrappers, screenshots on the wiki - I stripped jmephysics, because its quite problematic in its current state
17:31rhickeyname game again - I'm thinking of letfns for Clojure's letrec/labels
17:32Lau_of_DKexample? Im not following
17:33rhickeyhttp://paste.lisp.org/display/76297
17:34ayrnieurhickey - why not 'flet' ? It implies something different in CL, but so does LET ; and {'let* 'let, 'labels 'flet} seems consistent.
17:35ayrnieuand you can pronounce it instead of sort of mumbling it.
17:35Lau_of_DKrhickey: Rich does this have a wider application that Im not seeing, because to me it seems like its just adding bloat to Clojure
17:36ayrnieus/implies/means/
17:36rhickeyLau_of_DK: mutually recursive local fns are not currently possible
17:38Lau_of_DKoh I see, its like a built in trompoline
17:38gnuvince_rhickey: would letfns have a different syntax? something like (letfns [f [x y] (+ x y), g [a b c] (* a (- c b))] body)?
17:38Lau_of_DKletfns sounds good to me, it fits well with the rest of clojure
17:38gnuvince_Or regular [f (fn [] (...))] ?
17:39ayrnieuletrec [also pronounceable] would have the usual syntax, and also work for mutually recursive data structures.
17:40gnuvince_Oh, I see you already posted code
17:41ayrnieulet-fns corresponds to let-if
17:41gnuvince_letfns is fine by me. labels doesn't really scream functions.
17:42rhickeygnuvince_: sample: http://paste.lisp.org/display/76297
17:43rhickeygnuvince_: right, labels is definitely out, flet has reverse implications
17:43rhickeyletrec is more general
17:43rhickeythis is for fns only
17:43gnuvince_rhickey: does it support multiple-arity functions?
17:44gnuvince_(letfns [(f ([x] x) ([x y] (+ x y)))] ...)?
17:44rhickeygnuvince_: sure
17:45gnuvince_Then it looks just damn fine to me :) The name is well chosen, the syntax is pretty good.
17:45rhickeyI like flet, concerned about the reverse implication
17:45Lau_of_DKflet is awful
17:45Lau_of_DK:)
17:46rhickeyI always wished that flet did what labels did, hate the name labels
17:46ayrnieuanyone bothered by flet has gotten over being bothered by let
17:46Lau_of_DKoh, I just realized I hate it because its a danish name for certain way of styling your hair. :)
17:46rhickeythere's also letf
17:47rhickeyletfn (not plural)
17:48ayrnieulet-fn again, like let-if
17:48rhickeyayrnieu: are you asking for a dash?
17:48gnuvince_between letfns and letfn, I think I'd go with letfn
17:50ayrnieurhickey - I'd prefer that to letfn
17:51rhickeyayrnieu: dash unlikely, sorry. if-let when-let etc are two-step things
17:53gnuvince_rhickey: you have notes from 3 years ago?
17:54rhickeyyeah, all the Clojure design was done in Mac apps Notebook and OmniGraffle, Notebook has nice creation date view
17:55rhickeydozens of variants of fn syntax on same page :)
17:55gnuvince_cool
17:55gnuvince_Do you have notes on where you expected Clojure to be three years from then? :)
17:56rhickeynope, just tech specs, no way to have planned what happened
17:58gnuvince_I hope you're happy with where you are, it's truly amazing the explosion Clojure has seen in a little over a year in the public eye.
17:58rhickeygnuvince_: it's crazy
18:00gnuvince_bbl, diner
18:07duncanmi'm trying to use slime on linux, and i see this error when i load it up: java.lang.Exception: Unable to resolve symbol: lazy-seq in this context (core.clj:70)
18:10slashus2Is there a safe way to do io inside of a transaction? I was looking at the io! macro.
18:11rhickeyslashus2: you can send to an agent which does the io after the transaction commits, otherwise no, because transactions can retry
18:12hoeckduncanm: are you using latest slime & latest clojure (github/svn versions)?
18:13hoeckduncanm: i mean the latest jochu-swank-clojure, not slime, sorry
18:14slashus2Okay, didn't think of sending it off to an agent.
18:20clojurebotsvn rev 1315; added letfn, supports mutually recursive local fns
18:23slashus2something like (send (agent @overall-count) println) sometimes prints two numbers beside each other in the output.
18:24slashus2I am trying to do the producer consumer simulator.
18:25slashus2Trying to print out when the producer produces a new number.
18:30Lau_of_DKhoeck: I updated SofiaBA heavily, and initially I had to write out jMephysics, because its unstable in its current state - sorry if I got your hopes up
18:30Lau_of_DKIts not dropped, its just postponed a little bit
18:31slashus2http://pastebin.com/d61e802a3
19:51Chouserwe could just hook the svn change feed directly to reddit
19:51rhickeyheh
19:52rhickeyyeah, some of it isn't going to do anything but make people bored/annoyed
19:52ayrnieuThis Week in Clojure
19:53Chouser*ahem* not to demean your latest feature, of course. :-)
19:53rhickeyone more wart removed
19:53gnuvince_Speaking of TCO (again), is there any word if Sun is going to include it in JDK7?
19:55rhickeyunlikely in 7 I think, but there's an implementation in MLVM already
19:55ChouserI'm much more interested in tagged numbers
19:55rhickeyI haven't tried MLVM yet, nor do I know what I'd have to do to enable it
19:56Chouserthough I guess TCO would be a PR win.
19:56rhickeyChouser: tagged numbers even further away I'm afraid
19:56Chouseram I right in thinking they would removed the need for most of the explicit primitive declarations?
19:58rhickeyChouser: TCO would be genuinely nice, not for loops, but for chained function calls on indefinite input, state machines etc
19:58rhickeyChouser: tagged numbers have their own tradeoffs, #1 being that they lose a few bits vs. the machine word
20:01rhickey[11:17am] Chouser: but this does not:
20:01rhickeyCl-USER 4 > most-positive-fixnum
20:01rhickey536870911
20:05gnuvince_So numbers would be 29 bits if they were tagged?
20:06rhickeygnuvince_: depends on the tagging scheme
20:06gnuvince_byte, short, int, long
20:06gnuvince_Hmmm
20:06ayrnieubyte, short, int, long, tagged fixnum
20:07rhickeyhttp://blogs.sun.com/jrose/entry/fixnums_in_the_vm
21:10hiredmanI don't suppose anyone has tried/got to work serving content from an inputstream with ring?
21:36Chouserwhee! http://paste.lisp.org/display/76305
21:37gnuvince_damn!
21:38hiredman;_;
21:38ayrnieuwell, at least it pretty-printed
21:39hiredmanugh
21:39ChouserI pretty-printed it manually. :-/
21:39hiredmanhow can I pack a binary array into a string?
21:40gnuvince_speaking of which, whatever happened to the pretty printing project?
21:40hiredmaner
21:40hiredmanbyte array
21:41cmvkkwhat, like base64 encoding or something?
21:41Chouserhiredman: String has a constructor that takes byte[]
21:41rhickeyChouser: hmm... an early version of the Clojure compiler removed (let []) and (if true ...)
21:42hiredmanChouser: yeah, but it doesn't seem to work well with a byte[] filled with jpeg data
21:42Chouserhiredman: sounds like a poor fit for a String. why do you want it?
21:43ayrnieuhe's pretending that sockets are files, is why.
21:43hiredmanbecause ring can serve content from a string
21:43Chouserayrnieu: files can't store bytes??
21:43Chouserhiredman: sounds like ring could use a new feature.
21:43cmvkkwhat's ring?
21:43hiredmanyeah
21:44hiredmanI would really like to serve right from the inputstream I have
21:44hiredman~ring
21:44clojurebotring is http://github.com/mmcgrana/ring/tree/master
21:45hiredmanlooks like adding that might be easier then I thought
21:46hiredmanactually
21:46hiredmanit looks like it should already work
21:56hiredmanah
21:56hiredmanexcellent
21:56hiredmanthat does work
21:56hiredmanI must have been doing something wrong before, but now ring serves out of a CipherInputStream just fine
22:16Drakeson`Which virtual machine hosting you recommend/had success with? (to deploy clojure web applications, etc.)
23:13mattreplDrakeson: http://slicehost.com is nice
23:16Drakesonthanks
23:30cp2Drakeson i have a vps with http://cheapvps.co.uk/
23:30cp2if you dont have a lot of money to spend, they are worth it
23:30cp2provided you can deal with managing it yourself
23:43Drakesoncp2: great. thanks. I want something that I can manage myself.
23:45Drakesoncp2: [sorry to ask this stupid question] is the term "VPS" what I have to search for?
23:46cp2huh?
23:47DrakesonI mean, is VPS hosting what I am looking for?
23:47cp2well, i guess
23:47cp2you said virtual machine hosting
23:47cp2vpses are virtualized dedicated servers
23:47cp2there are several on a big honkin' server
23:48DrakesonI was looking for the right term to google it. virtual machine hosting wasn't the right term ;)
23:48cp2heh
23:48cp2yeah, vps would be better
23:48Drakesoncp2: cool. thanks.
23:48cp2also, i would check http://www.webhostingtalk.com/
23:49cp2lots of reviews and such about providers
23:50Drakesonnice, there is a whole VPS hosting board there (in webhostingtalk)
23:50cp2yep