#clojure logs

2010-11-09

00:04replacaRaynes: are you here?
00:05Raynesreplaca: No.
00:05RaynesYes, I'm here. :)
00:05replacaRaynes: got your pull req on autodoc, but I'm kind of moving in a different direction with autodoc
00:06RaynesI didn't send a pull request. :o
00:06replacaRaynes: I'm on the verge of pulling the lein plugin out into a separate plugin and here's why:
00:06Raynesreplaca: Oh, my message.
00:06replacais my senile memory messing with me?
00:06replacayeah, that :)
00:06Raynesreplaca: That's completely cool. I'm fine with cake-autodoc being separate. I just wanted to check with you to make sure I was being consistent.
00:07replacawhen you have leinigen, autodoc and a project all running with possibly different versions of clojure
00:07replacayou get version headaches out the wazzoo
00:07replacawe had it with 1.2 and we'll have it with 1.3
00:08replacaso a very light external plugin that depends on autodoc and invokes it with args based on the project params seems like the way to go
00:09replacaI hope to get to that soon for leiningen and you could just copy me, but there are a lot of things I hope to get to soon :)
00:09replacaRaynes: that's all!
00:10Raynesreplaca: Awesome.
01:06lenwhi all
01:06scottjnew library for webapps, feedback welcome: https://github.com/scottjad/slice/blob/master/src/slice/example.clj
01:09lenwscottj: that looks very neat
01:42quizmehow do you do a hard reload, where it reloads the file and recompiles?
01:42scottjC-c C-k in slime
01:42lenw(use 'x :reload)
01:42quizmeI'm using (load) but it doesn't seem to be recompiling
01:42quizmelenw i'll try that
01:42quizmethnx
01:45quizmewhen i reload I'm getting this error: java.lang.IllegalStateException: flatten already refers to: #'clojure.contrib.seq/flatten in namespace: triangle.core (core.clj:1)
01:45quizmeso it's preventing it from reloading
01:47quizmeis there a way to ignore that warning?
01:47quizme*error* ?
01:50lenware you not getting that error the first time ?
01:56quizmelenw: it's a warning the first time
01:59LauJensenMorning all
02:01ppppaulmoo
02:03Deranderlenw: I have the same issue as quizme w/ my setup
02:04lenwi am not really sure about whats going on there guys - what is the warning that you get the first time - perhaps that the thing to look at ?
02:05quizmeWARNING: flatten already refers to: #'clojure.core/flatten in namespace: triangle.core, being replaced by: #'clojure.contrib.seq/flatten
02:11lenwwhat does your uses bit look like in your code ?
02:13quizmelenw: http://pastie.org/1283802
02:21lenwok i can reproduce the error now
02:23quizmelenw: great, we're starting a movement.
02:28lenwhttp://clojuredocs.org/clojure_contrib/clojure.contrib.seq/flatten ?
02:29lenwuse this rather http://clojuredocs.org/clojure_core/clojure.core/flatten
02:50quizmelenw: I took out the reference to clojure.contrib.seq and it seems to have removed that warning.
02:50quizmelenw: hope it doesn't break anything though...
02:51lenwi dont think that the behaviour of flatten has changed
02:55quizmelenw: ok awesome thanks.
03:20raekawesome! someone on the mail list used Clojure to solve a Myst puzzle... :D
04:01npoektophi! i've just read a post about how to make server pick up changes without restarting repl: http://blog.darevay.com/2010/11/compojure-the-repl-and-vars/. There is an example what happens if we do not use var, but i do not get it. Why it prints hi, not hey, when the function greet is redefined?
04:04raekin code, the vars are used. in data, the var value is used.
04:04raek(fn [] (foo)) ;; <--- this will always call the most recent version of foo
04:05raek(some-fn foo) ;; <-- here, the value of foo is looked up, and the function that the var foo currently has is passed as the arg
04:09raekso, in the example, partial receives the current value of greet (the function that prints "Hi!")
04:12raekwhen a function is compiled (like the call function in the example) the functions is uses are not looked up, but references to the vars are remembered instead.
04:15npoektopraek: i thought there may be only one version of a function. It's a bit confusing. Do i get it right? When i do defn, it just binds an anonymous function to symbol, and if i redefine it, it just rebinds. So there really may be versions of functions.
04:16npoektoprebinds to a new anonymous function
04:16raekyes, when you reevaluate the defn, you rebind the var to a new function object
04:17npoektopreak: cool. thanks
04:17raekthe old function object remains unchanged
04:19raekI usually start the web server using something like this:
04:19raek(def web-server (atom nil))
04:20raek(defn start [] (swap! #(do (assert (nil? %)) (run-jetty #'the-handler {:port 8080, :join? false}))))
04:20raeksorry, "... (swap! web-server #(do..."
04:21jowagif I have a function (defn my-fun [a b c] (foo a) (bar b) (baz c)), what is the best way to document what kind of arguments it accepts? In this case one needs to look into source or doc for foo, bar and baz to know the types of arguments, so some kind of documenting the arguments in my-fun would be helpful
04:22jowagsome partial solutions could be - choose a good argument name, - document it briefly in the docstring, - add a comment explaining arguments, - use metadata/type hints
04:23npoektopjowag: http://tech.puredanger.com/2010/02/08/clojure-1-whats-up-doc/
04:26jowagnpoektop: so you recommend to use docstring to document the argument types?
04:29npoektopjowag: sorry. i posted before i read your second line.
04:30raeki would write that in the docstring, along with the explanations of what the args are for
04:31raekyou should always have docstrings for public fns
04:35raekideally, the fn and namespace docstrings should contain everything the user needs to know in order to use the fn
04:53jowagI agree that docstring should contain everything user needs
04:53jowagbut sometimes I find myself writing too large docstring if I want to describe fully what the parameters should be
04:56jowagin one case my function expects map with specified keys present and docstring is than a bit verbose
04:57RaynesI wrote excellent documentation for my secret-but-not-so-secret-that-you-cant-find-it-on-github-if-you-look-for-it project. I'm proud of myself.
05:00jowagI came from strongly typed land and the feeling that the only way how to elucidate arguments is in the docstring makes me a bit uneasy
05:06jrphm, when I try to run a simple hello world function from a repl inside vim, i get '#<user$hello user$hello@3b26456a>' or similar when i try to run it
05:06jrpwhats going on here?
05:10jjidojrp: where's your code?
05:11jrpjjido: In the vim window below it. I send it to the repl with vimclojure I think...
05:14jjido_jrp: please post the code on github or pastebin
05:15jrpjjido_: (defn hello [] println ("Word"))
05:17jjidook, then the output is the result of your code. You define a function.
05:17jjidotry: (defn hello [] (println "Word")) (hello)
05:18jrphm ok, that works. Why cant I call it via the repl though once Ive defined it?
05:19jjidothis is a function call: (hello)
05:19jjidothe repl will forget the function when you restart it
05:20jrpbut Im not restarting the repl?
05:23bartjI see a very weird behaviour with clojure.contrib.json
05:23bartjHere is the code sample: http://pastie.org/1283998
05:24bartjcan anyone please take a look?
05:27bartjis this a bug?
05:28bartj, (type (json-str (Math/sqrt -1)))
05:28clojurebotjava.lang.Exception: Unable to resolve symbol: json-str in this context
05:28bartj, (type (clojure.contrib.json.json-str (Math/sqrt -1)))
05:28clojurebotjava.lang.ClassNotFoundException: clojure.contrib.json.json-str
05:29bartjie. (type (json-str (Math/sqrt -1))) = (type (json-str "abc"))
05:30bartjbut, when I do a read-json on this: (read-json (json-str (Math/sqrt -1))) it fails!
07:19lenwhow do i see the queue's behind an agent ?
07:55cemericklenw: it's in a package-private field `aq` in the agent
07:56Raynescemerick: Mornin'!
07:56cemerickThere's roughly no good reason to look at the queue, though.
07:56cemerickRaynes: Morning :-)
07:57jcromartiehi
07:58Raynesjcromartie: Hi.
07:58jcromartieI have to confess... Smalltalk (Pharo) is winning me over.
07:58RaynesI played with Pharo a while back.
07:58jcromartieIt's like the opposite of Clojure.
07:58jcromartieIt is basically just a toolkit for mutable state.
07:58RaynesI do declare that I cannot tolerate trying to work in an 'environment'.
07:59jcromartieheh, yeah it's weird
07:59jcromartiebut I wonder if something like Seaside wouldn't be possible in Clojure?
07:59RaynesMy environment is whatever I want it to be at any particular moment in time, not what somebody decided beforehand.
07:59jcromartiehey, at least it's consistent right?
07:59RaynesThat it is.
08:00RaynesNo "Help, I can't get SLIME working"
08:00jcromartieSeaside is just hands-down the best web development framework I've ever seen (and I've evaluated a lot)
08:00jcromartiewhat does Clojure have in terms of continuations?
08:00Raynescemerick: I own raynes.me now. I'm getting all fogus_-like.
08:01jcromartiecould fns be used to build continuations?
08:02cemerickRaynes: nice :-)
08:02cemerickBTW, what *is* "Raynes", anyway?
08:02Raynesamalloy asked me that earlier.
08:03RaynesI started using it as a username after playing the bloodrayne games several years ago. It started as Rayne, and then became 'Raynes' when I started running into (everything) where Rayne is already taken.
08:03RaynesI am become Raynes.
08:08Raynescemerick: I remember people calling me Raynes at the conj. It always shocked me back to reality about where I was, because it was so bizarre.
08:20Raynesstuartsierra: I tawt I taw a blue haired Clojurian. I did! I did!
08:21stuartsierraWhat's up, doc?
08:21stuartsierra(I forget what the cat says.)
08:21RaynesThat's bugs bunny.
08:29cemerickstuartsierra: I think you were looking for…sufferin' succotash! :-D
08:29cemerickof course, severe lisps don't translate in irc
08:30stuartsierraI only program in Severe Lisps.
08:30stuartsierraOther lisps are too milquetoast for me.
08:31cemerick"milquetoast" is a fantastic word
08:31Raynes$dict milquetoast
08:31sexpbotRaynes: noun: a timid, unassertive man or boy fearful of confrontation and easily manipulated and dominated.
08:31stuartsierraThat's going to be the name of my next project then.
08:33cemerickthe etymology of it is pretty amusing
08:36cninjaHi all! Im new to clojure. As part of teaching myself the language, I was looking at clojure.core and it seems to me the implementation of "distinct" is overly complex. I wrote https://gist.github.com/669075 that seems to be faster. What is it missing?
08:37scottj_jcromartie: see clj-cont and weblocks for what's possible.
08:37Raynes$source distinct
08:37sexpbotdistinct is http://is.gd/gRO3Q
08:40cninjaI thought maybe my faster version held onto the head of the column, but I'm not familar enough with the language to test for that sort of thing.
08:45chousercninja: yours isn't lazy after the first step
08:46Rayneschouser: You're a ninja.
08:46chouserno, c is.
08:46chouserhar har
08:46cninjaha ha
08:46RaynesI actually didn't make that association when I saw his nickname.
08:46cninjaHow did you test for that?
08:46RaynesI guess that's a sign that I've been awake too long.
08:47chousercninja: still working on a test, but from your code it's clear enough to make a bold assertion on IRC. :-)
08:48Rayneschouser: Write me a map function that works like map, but when it comes across a collection, it maps into that collection and always returns the same data structures. It must not blow the stack. I want it on my desk by 9.
08:48cninjachouser: I figured I missed something. It didn't make since that I just rewrote a core function and made it twice as fast
08:48chousercninja: :-)
08:49chouser& (take 2 (distinct (map #(do (prn :took %) %) (list 1 2 3 1 2 3 4))))
08:49sexpbot⟹ (:took 1:took 21 2)
08:49chousercninja: now, try that with distinct2
08:50cninjak
08:50stuartsierraRaynes: clojure.walk/postwalk
08:51Raynes&(doc clojure.walk/postwalk)
08:51sexpbot⟹ "([f form]); Performs a depth-first, post-order traversal of form. Calls f on each sub-form, uses f's return value in place of the original. Recognizes all Clojure data structures except sorted-map-by. Consumes seqs as with doall."
08:55Raynesstuartsierra: You're my bestest buddy ever.
08:59RaynesMy life is so much easier now.
09:00chousercontrib generic has multimethod-based solutions
09:00chouser((fn gmap [f coll] (clojure.contrib.generic.collection/into (empty coll) (map #(if (coll? %) (gmap f %) (f %)) coll))) inc '[1 2 3 [4 5 6] 7 8 (9 10 11)])
09:01chouserhm, that's not quite right
09:01chouser(12 11 10)
09:03fliebelOh, I really want a function-need identification graph.
09:05RaynesI find it amusing that Leiningen takes so much memory that I cannot run the 'deps' task with sexpbot running at the same time on my VPS.
09:07RaynesNot that it's Leiningen's fault. sexpbot isn't exactly lightweight. My VPS only has a gig of guaranteed RAM with 2gb burst.
09:07RaynesI should be moving him to a higher end box soon.
09:09fliebelRaynes: How hard would it be for me to implement pingpong timing? So me "Raynes: ping" you "fliebel: pong" sexpbot "Raynes's responds time id 5 sec"
09:10Raynesfliebel: Isn't that irrelevant when you can just use CTCP PING?
09:10Raynes* Ping reply from fliebel: 0.84 second(s)
09:10jjidoirc messaging ping
09:11fliebelRaynes: It's not about my computers response time, but just to see how long it takes someone to respond ;)
09:11RaynesOh, I misread what you said.
09:11RaynesMeh, shouldn't be very difficult.
09:12RaynesI need to write a plugin tutorial.
09:13RaynesPeople seem to get by pretty well just by looking at existing plugins.
09:13fliebelRaynes: That would be awesome! I looked at one and it didn't seem that hard, but there where a few magic bits.
09:14RaynesI'd be happy to explain those magic bits. In PM or #clojure-casual, though. Don't want to fill up #clojure with sexpbotspam. :p
09:15fliebelRaynes: I didn't know about casual...
09:15RaynesIt's a very, very quiet channel.
09:16jjido#clojure is casual enough
09:16Raynesjjido: That's exactly right. Most of the time it is.
09:16fliebelRaynes: I'm going to look at a plugin and I'll be there with questions in a moment.
09:16RaynesI like to reserve #clojure-causal for totally non-clojure related stuff, or just long discussions about anything that just doesn't seem quite appropriate for #clojure.
09:19romainpHi, what are a few good sources of clojure code to use as inspiration? (not domain-specific, just to get the feel of it)
09:20belunclojuredocs.org
09:20belunhttp://clojuredocs.org/
09:22beluni got a q too :)
09:22belunif there is let
09:22belunand letfn
09:22belunis there a mxin function
09:22belun?
09:22belunthat can bind vars and functions ?
09:24chouserbelun: no, but you can use let to bind fns. letfn is only needed when the fns are mutually-recursive, a generally pretty rare use case.
09:24stuartsierra~seen dysinger
09:24clojurebotCool story bro.
09:24belunwhat does muttualy recursive mean ?
09:25stuartsierra$seen dysinger
09:25sexpbotdysinger was last seen quitting 21 hours, 27 minutes ago.
09:25joegalloA calls B, B calls A, A calls B, etc...
09:25chouserbelun: the functions call each other, so at least one of them is calling a function that hasn't yet been defined.
09:26jjidobelun: if you don't need mutually recursive let is fine
09:26belunthat's the only usecase for let fn ? i was thinking to use it to give names to inline functions
09:26belunfor readability...
09:27chouser,(letfn [(odd [x] (if (zero? x) false (even (dec x)))) (even [x] (if (zero? x) true (odd (dec x))))] (odd 5))
09:27clojurebottrue
09:27chouserbelun: you can give any fn a name for readability
09:28chouser& (let [cool (fn cool [a b] (+ a b))] (cool 4 5))
09:28sexpbot⟹ 9
09:29belunya but this way cool stays in the namespace...
09:30jjidobelun: no it does not go in global nakedness
09:30jjidolol iPhone autocorrect
09:33chouserneither let nor letfn nor fn change any namespace
09:36jjido_was I kicked? it was an autocorrect mistake
09:36chouseryou weren't kicked
09:36RaynesNobody kicked you.
09:36RaynesWe <3 you.
09:37jjido_lol
09:45belunfn does not put functions into namespace ? what does then ?
09:45chouserdean: def-things. defn, defmacro, etc
09:45chouserbelun: ^^^ (sorry dean)
09:47Raynes'fn' creates a function. A function is just an object. def things give these things names. For example, (def x (fn [])) is the same as (defn x []). These don't do anything magical, they just create functions with fn and bind them to a name.
10:04fliebelWhere in Joy of Clojure are reify, defprotcol and deftype covered?
10:06fliebelah, 9.3
10:06Raynes1.1.4, 9.3
10:11fliebel&(= (array-map 1 2 3 4) (hash-map 1 2 3 4)) ; what is the difference?
10:11sexpbot⟹ true
10:12cemerickfliebel: you should use the latter :-)
10:13chouserreally?
10:13jjidono
10:13cemerickor, actually (into {} …)
10:13chouser& (hash-map 3 4 1 2)
10:13sexpbot⟹ {1 2, 3 4}
10:13chouser& (array-map 3 4 1 2)
10:13sexpbot⟹ {3 4, 1 2}
10:13jjidothat is a map indexed by integers, is that what you want?
10:14cemerickchouser: you use array-map explicitly on occasion?
10:14fliebeljjido: Not particularly… Just to lazy to type :a 1 :b 2
10:14chousercemerick: absolutely
10:15fliebelcemerick: I used it in a case where I was doing some strange apply thing that did not work with hash-map, not knowing what I was doing exactly.
10:16fliebel$(type {})
10:16fliebel&(type {})
10:16sexpbot⟹ clojure.lang.PersistentArrayMap
10:16jjido&(get (hash-map 1 2 3 4) 3)
10:16sexpbot⟹ 4
10:16cemerickchouser: not (into {} …)?
10:17chousercemerick: array-map guarantees order. I do on occasion use that.
10:17cemerickhuh
10:17cemerickI'd be too paranoid about the resulting map getting too big at some point, and tripping over into PHM
10:18fliebelchouser: Is that the only difference?
10:18chousercemerick: right, you can't conj onto it and assume it'll still be an array-map
10:19chouserbut, array-map always returns an array map, so as long as you use only that particular value, you're good to go.
10:22fliebelI still don't get the difference though, could you show me an example where it matters if I'm using one or the other?
10:22chouserI did.
10:23chouser& [(hash-map 3 4 1 2) (array-map 3 4 1 2)]
10:23sexpbot⟹ [{1 2, 3 4} {3 4, 1 2}]
10:24fliebelchouser: But why does that matter? get is going to return the same thing for both, right? or are you thinking about looping over it?
10:24jjidoif you map or loop over it the order differs
10:25cemerickfliebel: also FWIW, equality isn't a very good indication of the natures of respective data structures. e.g.:
10:25cemerick&(= {1 2 3 4} (doto (java.util.HashMap.) (.put 1 2) (.put 3 4)))
10:25sexpbot⟹ true
10:25RaynesMy heart stops every time something gets evaluated.
10:25RaynesAnd then I smile.
10:35bartjIn a map like this: (def x {:a [1 2 3] :b [] :c [4 5] :d []})
10:35bartjIs there a better way to remove :b and :d (ie. they have empty vectors/collections)
10:35bartjthan this: (select-keys x (remove nil? (map #(when (> (count (x %)) 0) %) (keys x))))
10:37jjidoempty? tells you if the collection is empty
10:38Raynes&(into {} (filter (comp seq second) {:a [1 2 3] :b [] :c [4 5] :d []}))
10:38sexpbot⟹ {:a [1 2 3], :c [4 5]}
10:39jjidowhat does seq do here?
10:40jjido,(seq [])
10:40clojurebotnil
10:41Raynes&(seq [])
10:41sexpbot⟹ nil
10:41clojurebot⟹ "Returns the metadata of obj, returns nil if there is no metadata."
10:41RaynesIf seq is called on an empty collection, it returns nil.
10:41jjidoand nil is interpreted as false... almost obfuscation
10:41mfex&(into {} (remove (comp empty? val) {:a [1 2 3] :b [] :c [4 5] :d []}))
10:41sexpbot⟹ {:a [1 2 3], :c [4 5]}
10:42RaynesRight, val works here as well. I should have used val.
10:42RaynesVals have more fun.
10:43bartjmfex, Raynes thanks!
10:44bartj&(remove (comp empty? val) {:a [1 2 3] :b []))
10:44sexpbotjava.lang.Exception: Unmatched delimiter: )
10:44bartj&(remove (comp empty? val) {:a [1 2 3] :b [])
10:44sexpbotjava.lang.Exception: Unmatched delimiter: )
10:44RaynesMissing a }
10:44bartj&(remove (comp empty? val) {:a [1 2 3] :b []})
10:44sexpbot⟹ ([:a [1 2 3]])
10:46bartjfor a moment, I thought that the [:a [1 2 3]] was a vector!
10:46RaynesWell, it pretty much is.
10:46Raynes&(type (remove (comp empty? val) {:a [1 2 3] :b []}))
10:46sexpbot⟹ clojure.lang.LazySeq
10:46jjidobartj: yeah that is how clojure handles entries
10:46Raynes&(type (first (remove (comp empty? val) {:a [1 2 3] :b []})))
10:46sexpbot⟹ clojure.lang.MapEntry
10:47RaynesA MapEntry is similar to a vector.
10:48bartjcool
10:48jjido,(first {:a [1 2 3]})
10:48clojurebot[:a [1 2 3]]
10:48bartj, (into {} [[:a 1] [:b 2]])
10:48clojurebot{:a 1, :b 2}
10:50bartjcool, thanks everyone
10:53fliebelhrm, I thought there was a chapter like "when to use reify", but looking at it, those are for atom, agent, ref and these. I guess I'll just have to think hard about my problem ang do some hamocking afterwards.
10:56jjidothe hammock joke is still making rounds ;)
10:58bartjjjido, care to explain?
11:00beluni think it;s from teh rich preentation
11:00belunhttp://www.livescribe.com/cgi-bin/WebObjects/LDApp.woa/wa/MLSOverviewPage?sid=R4XrwCpdzj5m
11:00fliebelbartj: Something to do with Clojure-conj. Rich gave a talk about problem solving, I think, and he said something about hamock time.
11:00fliebelto slow again.
11:02belun:)
11:03LauJensenMost dev communities are plauged by insomnia, long hours of coding. Looks like Rich solved that for #clojure :)
11:04bartjfliebel, belun thanks!
11:09fliebelouch, this hurts… Python has only 68 core functions, Clojure over 400.
11:10jjidofliebel: I did notice clojure has many functions in core
11:10Raynesfliebel: clojure.core covers a very wide range of tasks. The entire sequence library is stuffed in there, for example.
11:10fliebeljjido: I'll be doing a project about this after the hamock.
11:11fliebelRaynes: I know. That is my whole point. Pythons functions are not very useful on their own at all, so you need to look in the corret module, which makes searching a lot easier.
11:11fliebel*correct
11:12RaynesI tend to agree, but I very much like having so much available to me all the time.
11:13jjidoRaynes: it would not do much harm to do one more (use) at the top
11:13fliebelRaynes: Wait and see, it'll be awesome :) But for now: hammock time.
11:13Raynesjjido: Yeah, but not necessarily just one.
11:13jjidoagreed
11:15LauJensentomoj: Hows that screencast coming along?
11:16scottj_uses are a pain. I'd hate to start every file of with uses clojure.agents clojure.seq clojure.files clojure.files.extra clojure.futures
11:17Raynesscottj_: Exactly.
11:21bartjIs this a bug in clojure.contrib.json or am I just using it inappropriately? - http://pastie.org/1283998
11:21bartjI mean with the read-json function
11:21bartjcan anyone please have a look at the paste ?
11:27vibrantook, so i'm defining a macro in namespace a which produces code using functions from that namespace
11:27vibrantand when i try to call the macro in namespace b, it says that it can't resolve a given symbol (that function name)
11:27vibrantis there a correct way to do it?
11:28LauJensenbartj: IIRC clj-json on github is the preferred way to go. Should be 2.5x faster IIRC
11:28jjidovibrant: don't use a macro?
11:28bartjLauJensen, thanks a bunch, but what is IIRC ?
11:28LauJensenIf I Remember Correctly
11:29bartjLauJensen, will check it out; but, the issue is not of speed, I think there is a bug?
11:30bartjLauJensen, to put it lightly, what goes in, doesn't come out the same
11:30LauJensenbartj: Not sure. I never use JSON.
11:31bartjLauJensen, may I ask what do you use?
11:32LauJensenbartj: Well it depends a lot of what Im doing. If its just data to/from a browser I use the regular {key: val} notation. I've seen people use JSON is non-web contexts as well. Would never do that.
11:33bartjLauJensen, interesting...if you had to use Redis, and had to store mutliple values in a hash map, would you still not serialize the values to json?
11:33LauJensenAsk me again once Ive implemented my first Redis solution
11:34LauJensenafk
11:35bartjforget Redis
11:35bartjif you had to serialize mutliple values in a hash key ?
11:36vibrantwhy is there no sequential binding clause?
11:36vibrantor is there?
11:37scottj_vibrant, do you really mean binding or actually let?
11:37vibrantlet is sequential i mean binding
11:38scottj_vibrant: re macro, are the functions fully qualified after expansion?
11:38vibrantscottj; nope.
11:39scottj_vibrant: bc you're quoting them?
11:39vibranthttp://pastebin.ca/1986444
11:40vibrantcmd-* functions reside in another namespace which is :used in the one in which the macro is
11:41scottj_maybe wrap (symbol...) in resolve
11:41Deranderso many functions to learn in clojure
11:41Deranderfun fun fun
11:41opqdonutyou must mean fn fn fn
11:45vibrantscottj; now it says 'can't call nil'
11:46scottj_update pastebin
11:48DeranderWhen should I use "use" vs "require"?
11:49scottj_the bot must have an answer for that faq
11:49Deranderhttp://stackoverflow.com/questions/871997/use-vs-require-in-clojure <-- I should have just googled.
11:56tonylmorning
11:58amalloymorning for real, tonyl
11:59tonylamalloy: i'm in a conference, early morning. now some free time
12:00amalloytonyl: fun. maybe erc?
12:00fliebelIs there something like exclusive or other than the bitwise one?
12:01tonylamalloy: don't know emacs :( i'm using irssi
12:01technomancythey have gui IRC clients now?
12:01amalloyawww, no emacs! your life is so sad
12:02amalloytechnomancy: the irc guis all collect identification data so that the command-line folks will have no trouble wiping us out when the revolution comes
12:02tonylamalloy: I am learning it... slowly
12:02hsuhhi guys... so i have this hairy macro which isnt working (doesnt it always start like this?)... http://pastie.org/1284771
12:03hsuhthe "argmap" can't be used like that, i tried using argmap# but that didn't work too, although it would give another error
12:03hsuhi'm wondering if i'm on the right direction or macros like this will just bring pain to me instead of making the rest of the code simpler
12:03clojurebotBarking spiders!
12:04amalloyargmap# is the right first step
12:04amalloyafter that, time to see what the real error is
12:05hsuhwhy? one would think that since argmap is quoted there would be no complaint?
12:05scottj_fliebel: don't think so. like this? (defn xor [x y] (= x (not y)))
12:05amalloy`(let [argmap 1])
12:05amalloy&`(let [argmap 1])
12:05sexpbot⟹ (clojure.core/let [clojure.core/argmap 1])
12:05amalloy&(let [clojure.core/argmap 1])
12:05sexpbotjava.lang.Exception: Can't let qualified name: clojure.core/argmap
12:05fliebelscottj_: Yea, think so...
12:05amalloyhsuh: ^^
12:06amalloy`(syntax-quote) is not the same as '(quote)
12:06hsuhamalloy: what are you saying that clojure is different from elisp ?
12:07amalloyhsuh: say it ain't so! :P
12:07hsuhok with argmap# i have a much more interesting error, now at "runtime"
12:07amalloyit also looks like ~(args-names args) is a problem
12:08amalloyit will be saying you can't call the first element of args-names as a function
12:08hsuhyeah something like that, java.lang.String cannot be cast to clojure.lang.IFn
12:08hsuhnice clojure evaluator you got there
12:09amalloy?
12:09hsuhin your head.. because i totally missed that...
12:09amalloyhaha
12:09amalloywell
12:09amalloyi had the exact same issue last night
12:09amalloyso...
12:09amalloy&(let [args '("foo" "bar")] `(blah ~(args)))
12:09sexpbotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
12:09amalloy&(let [args '("foo" "bar")] `(blah ~args))
12:09sexpbot⟹ (clojure.core/blah ("foo" "bar"))
12:10amalloyhsuh: see what ~args is expanding to?
12:10amalloy&(let [args '("foo" "bar")] `(blah ~(vec args)))
12:10sexpbot⟹ (clojure.core/blah ["foo" "bar"])
12:10hsuhgimme two days
12:10amalloythis is more like what you meant
12:21amalloyhsuh: working now?
12:22hsuhamalloy: err.. almost
12:24amalloyoh. you want ~@body
12:25hsuhok, but the error is still on that like, the args-name thing
12:25amalloyand you changed it to use (vec args-names)? i don't see that in the paste
12:25hsuhi didn't changed the paste, i actually moved 'vec' inside args-names
12:27Chousukewhat's your macroexpansion at the moment?
12:29hsuhi posted a little simpler version
12:29hsuhhttp://pastie.org/1284828
12:29Tordmor~pasge
12:29clojurebotI don't understand.
12:29Tordmor~paste
12:29clojurebotlisppaste8, url
12:30Tordmorhm
12:30hsuhwhile i get amalloy example, i can't translate it to what is wrong there
12:30hsuhoh and the error is, when trying to eval (test) i get java.lang.String cannot be cast to clojure.lang.IFn (like before...)
12:30Chousukehsuh: I don't understand at all what you're trying to do
12:31Tordmoranybody knows why this won't quit, after printing my packages list? http://pastie.org/1284834
12:31Chousukebut in (map name (vec args)) the vec is completely redundant
12:31hsuhhm
12:32Chousukeargs-names is still returning a list
12:32Chousukeor a seq
12:32Chousukewhich means a function call
12:32hsuhok now it works...
12:32hsuhwhat do you mean by "whcih means a function call" ?
12:32Chousukea list form is a function call.
12:33Chousukeyour macro emits a list, therefore it's evaluated as a function call
12:33hsuhof course, now it makes sense
12:33hsuhtks amalloy, Chousuke
12:34hsuhits kinda like '[1 2 3] can be understood as [1 2 3], but '(1 2 3) cant be seen as (1 2 3), right?
12:34Chousukehsuh: hm, well
12:35Chousuke,'(1 2 3) :P
12:35clojurebot(1 2 3)
12:35Chousukethe thing is, when you evaluate (1 2 3) it's treated as a function call
12:35amalloysure: &|[1 2 3]|& is okay, but &|(1 2 3)|& is no good, and the latter is what you were running after macroexpansion
12:35sexpbot[1 2 3] ⟹ [1 2 3]
12:35sexpbot(1 2 3) java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
12:36Chousukenote though that there's a difference between '[foo bar] and [foo bar] :P
12:36Chousukethe former is a vector if symbols, and the latter is a vector of whatever foo and bar evaluate to
12:37hsuhhm, true... forget what i said
12:40Chousukemacros become a lot easier after you understand the whole "code is data" thing
12:41Chousukeand the evaluation semantics of the different data elements used.
12:42hsuhamalloy: strangely it only works with ~body instead of ~@body
12:42Chousukehsuh: that's because you only accept a single expression as the body
12:43ChousukeYou should destructure decl as [args & body]
12:43hsuhbeautiful
12:43amalloyalso if won't let you splice
12:44amalloyi mean, it will, but won't do what you want
12:44amalloyyou should probably use when here
12:44Chousukeor you can just do (.. [name args & body] ...)
12:45Chousukeor you can just use do
12:45Chousukefor the if
12:46hsuhChousuke: there is an else part to that if, is just that you are seeing the second version i think... let me post the working version
12:47hsuhdoes seeing a "with-meta" on the macroexpansion means anything special about my code?
12:48ChousukeI'm not sure
12:48Chousukedo you intend for the macro to expand to code that attaches metadata to something?
12:48hsuhno
12:48hsuhi'm just afraid of reflection because i read its eevil
12:48Chousukethen it's probably wrong .)
12:48amalloyhsuh: metadata has nothing to do with reflection
12:49hsuhi also dont knew that too of course
12:49Chousukeamalloy: :tag metadata is used to avoid it.
12:49hsuhpastie is slow, or i am
12:49Chousukefor symbols
12:49Chousukeand lists
12:49hsuhhere is the working thing: http://pastie.org/1284771
12:49amalloyChousuke: okay, fair enough
12:49hsuhthe idea is that defn* will help me write dozens of similar functions for a webapp
12:49hsuhwithout repeating code... is that a fair use of macros?
12:50amalloythat's pretty much what macros are for
12:51Chousukeseems fine.
12:51ChousukeI'm not seeing with-metas either :P
12:52hsuhso i'm not using macroexpand right
12:52hsuhcheck the withMeta on http://pastie.org/1284771... am i doing something wrong?
12:53hsuhoh i'm on slime.. that might be it ?
12:54Chousukehsuh: that's defn, not your macro :)
12:54hsuhbut i want to expand an usage of the macro, or the macro? :)
12:54Chousukeanyway, it's fine
12:54Chousukeyour macro expands to a defn which expands to something .withMeta
12:55hsuhheh
12:55jfieldsdo dosyncs retry infinitely?
12:55amalloyjfields: no
12:55amalloybut they try quite a few times
12:55Chousuke10000, or something :P
12:55jfieldsamalloy, any docs on the web? I'm looking in the Joy of Clojure and not seeing any details
12:55hsuhChousuke: hm, but my test function is almost mempty..
12:56amalloyjfields: that's funny, JoC is where i remember learning this. i'll take a look
12:56Chousukehsuh: yes? the expansion looks correct to mee
12:56Chousuke-e
12:56hsuhChousuke: what about the withMeta?
12:56Chousukehsuh: that's correct too
12:57Chousukehsuh: it's just adding metadata to the resulting function
12:57hsuhoh
12:57Chousukehsuh: it's what defn does
12:57hsuhohhh
12:57hsuhok ok
12:58amalloyjfields: check out 11.1.4
12:59amalloy"First, there are transaction restart limits..."
12:59hsuhto be sincere though, if your patience allows, i still don't get why i can't use argmap without gensym... since that is just "literal text" that should appear on the expanded form
12:59jfieldsamalloy, thanks
12:59amalloyhsuh: no it isn't
13:00Chousukehsuh: it's not text :)
13:00Chousukeit's a symbol
13:00Chousukehsuh: and it might conflict with local bindings
13:00amalloyif you used exactly the same name every time, there would be problems with nesting. someone else might use that same name, or you might step on a local
13:00amalloyor you might even expend your macro recursively, stepping on your own local
13:01Chousukewhat are you going to do if someone does (let [argmap foo] (defn* test [a b c] (somestuff argmap)))?
13:01hsuhsee it know
13:02hsuhnow
13:02amalloyhsuh: clojure makes it very hard to make that mistake on accident, but there are occasions when you actually want to do it
13:02amalloysee the google group for an example
13:06hsuhusing a macro like this i have to make sure that functions used by the macro (the expanded defn) are acessible where the macro is used... is there any alternative to this or just live with it ?
13:07kotarakhsuh: use a foo.internal namespace which is :use'd in foo (where your macro lives) or @#'foo/shout-at-the-private-var long enough.
13:14hsuhkotarak: tks
13:35kotarakSomeone ever used expect on Windows? Does anyone still use expect anyway?
13:54fogus_pdlogan: Are you the author of the blog http://patricklogan.blogspot.com ?
13:55pdloganfogus_: yep
13:55fogus_pdlogan: One of my favorite blogs of all time. I miss it.
13:56pdloganhmm... thanks. I've been thinking about posting a new one re: some clojure / web stuff I've been dinking with.
13:57fogus_Well, here's me hoping you do.
13:57pdlogan(n.b. my views on clojure have changed a good bit since I was blogging there)
13:58fogus_for better or worse. ;-)
13:59pdlogan(better)
14:03pppaul(inc better)
14:03sexpbot⟹ 1
14:03fliebelWhen I wrote this function, only God and I knew what I was doing. Now only God knows. https://github.com/pepijndevos/clj-fneeid/blob/master/src/fneeid.clj
14:04pppaulweird
14:04pppaul(doc resfn)
14:04clojurebotIt's greek to me.
14:06amalloyfliebel: having a truth parameter is bizarre, since you just use (not) anyway
14:07amalloywhich always returns either true or false
14:07fliebelamalloy: How is it bizarre?
14:08fliebelamalloy: What I'm doing is that if truth is true, I "filter" while otherwise I "remove"
14:08amalloyugh. just make your users pass in (complement f) instead of f; it's more readable on both sides of the function call
14:09fliebelamalloy: Doesn't work the same… function is determined on the outer fn, while truth is defined on the inner fn.
14:12fliebelamalloy: Depending on how you call the inner fn it gives you one or the other half of input, which is passed around through either positive or negative.
14:12pppaul,(clojure.contrib.math/round (rand 10))
14:12clojurebotjava.lang.ClassNotFoundException: clojure.contrib.math
14:13amalloy&(rand-int 10)
14:13sexpbot⟹ 5
14:13kotarak,(require 'clojure.contrib.math)
14:13clojurebotjava.io.FileNotFoundException: Could not locate clojure/contrib/math__init.class or clojure/contrib/math.clj on classpath:
14:16amalloyfliebel: i'm not going to try to understand why you want your function to do this. but you could make it more readable, i think, by using (filter (comp #{truth} boolean function)), since you seem to just be using (not) to coerce things to booleans
14:18fliebelamalloy: I'm doing sort of a conditional complement, so I could do (if truth fuction (complement function))
14:19amalloyyep, you could do that too
14:19amalloywhich is probably nicer since it doesn't involve booleans where they don't belong :P
14:22pppaul,(repeatedly 40 #(rand-int 11))
14:22clojurebot(10 6 1 4 10 6 6 4 5 4 ...)
14:22amalloy&(repeatedly 40 #(rand-int 11)) :)
14:22sexpbot⟹ (3 7 7 5 6 4 1 9 5 5 10 10 10 8 2 2 10 8 1 4 3 7 2 0 10 1 2 3 5 4 9 3 10 4 0 4 8 5 0 7)
14:27pppaul&(repeatedly 400 #(rand-int 11))
14:27sexpbot⟹ (4 8 10 6 10 5 8 3 3 5 8 9 4 9 5 8 1 3 6 8 2 10 10 8 3 6 9 8 9 5 5 5 2 9 1 10 8 0 7 2 0 2 8 4 1 8 0 0 4 1 10 7 10 6 6 8 4 9 4 10 10 4 1 6 1 6 1 10 6 1 6 3 9 2 9 6 6 10 10 0 10 6 7 9 1 10 9 3 2 1 7 8 8 0 2 8 6 7 9 4 7 8 10 3 5 8 8 2 1 3 6 4 1 6 4 0 4 3 1 6 2 10 0 8 1 2 10 0 9 1 2 10 4 4 10 9 4 9 3 6 ... http://gist.github.com/669654
14:28pppaulsexbot is the way to go!
14:28bobo_im impressed!
14:28ohpauleezalso funny that you called him sexbot, I wonder how many times that will happen
14:29pppaulsexbot should know his nick-name
14:30ohpauleezhaha
14:30amalloyohpauleez: it will happen a lot :P
14:31amalloyi have to type sex<TAB> to get into my repo; i never use the p, so if i ever need to use it in a non-tab-completion context...
14:31pppaulit would be cool if clojurebot has a lisp
14:32amalloy$sed -pppaul s/s/th/
14:32sexpbot<pppaul> it would be cool if clojurebot hath a lithp
14:32amalloy:P
14:32pppaulahaha
14:35pppaul&(= '(1 2 3 4) '(4 3 2 1))
14:35sexpbot⟹ false
14:36pppauli guess i have to sort to compare for equality if order doesn't matter for me?
14:37kotarakclojurebot: botsnack
14:37clojurebotthanks; that was delicious. (nom nom nom)
14:37amalloypppaul: use sets
14:37fliebelHow can I make partial retain the meta of the original fn?
14:37pppaula set wouldn't work because i need duplicate entries
14:37amalloy&(= #{1 2 3 4} #{3 4 1 2})
14:37sexpbot⟹ true
14:38pppaul&(= #{1 3 3 3} #{3 3 1 1})
14:38sexpbotjava.lang.IllegalArgumentException: Duplicate key: 3
14:38kotarakfliebel: (with-meta (partial f arg) (meta f))?
14:38amalloypppaul: you could sort, or use every?/some
14:38ohpauleezpppaul: You can use sets, or map a set operation across both lists
14:38fliebelkotarak: Yea, that sort of stuff.
14:38ohpauleezdamnit amalloy, stop jumping on my suggestions
14:38ohpauleez:)
14:38kotarakfliebel: well, that was the answer
14:38amalloyohpauleez: mine isn't actually any good
14:38pppaul(doc every)
14:38clojurebotTitim gan éirí ort.
14:38fliebelkotarak: Thanks :)
14:39amalloyoh! i know the answer pppaul!
14:39pppaul!
14:39pppauli think i need to sort
14:39amalloynonono
14:39pppaul^_~
14:39ohpauleezI think you can use all, or another set operation
14:39amalloy&(= (map frequencies [[1 2 3 4 3] [3 4 1 3 2]])
14:39ohpauleezon the lists
14:39sexpbotjava.lang.Exception: EOF while reading
14:39amalloy&(= (map frequencies [[1 2 3 4 3] [3 4 1 3 2]]))
14:39sexpbot⟹ true
14:39pppaulwooah
14:39pppaul&(doc frequencies)
14:39sexpbot⟹ "([coll]); Returns a map from distinct items in coll to the number of times they appear."
14:40amalloygonna be much faster than sort
14:40pppaulsure that isn't sorting?
14:40amalloyalthough haha i typed it wrong
14:40amalloy&(apply = (map frequencies [[1 2 3 4 3] [3 4 1 3 2]]))
14:40sexpbot⟹ true
14:40amalloyyeah it's not doing a full sort. it's hashing
14:41ohpauleezyeah, that's a good one actually
14:41amalloy&(apply = (map frequencies [[1 2 3 4 3] [3 4 1 4 2]]))
14:41sexpbot⟹ false
14:42pppaul$(freguencies [ 1 2 2 3 3 4 5 5])
14:42pppaul&(freguencies [ 1 2 2 3 3 4 5 5])
14:42sexpbotjava.lang.Exception: Unable to resolve symbol: freguencies in this context
14:42kotarak(defn =-by [f & items] (apply = (map f items)))
14:42pppaul&(frequencies [ 1 2 2 3 3 4 5 5])
14:42sexpbot⟹ {1 1, 2 2, 3 2, 4 1, 5 2}
14:42pppaulum, that is a sort
14:43amalloypppaul: no it isn't. it's a hashmap
14:43pppaulit's like count-sort
14:43amalloy&(frequencies [ 1 2 2 3 3 4 5 55 1231])
14:43sexpbot⟹ {1 1, 2 2, 3 2, 4 1, 5 1, 55 1, 1231 1}
14:43pppaulor bucket-sort
14:43amalloybucket-sort, if you like. but that's faster than actually sorting the list
14:43kotarak&(frequencies [1 2 3 4 2 1231 55])
14:43sexpbot⟹ {1 1, 2 2, 3 1, 4 1, 1231 1, 55 1}
14:43pppauli know ^_^
14:43amalloyah. thanks kotarak
14:44pppauloh
14:44amalloythere, see? no sorting pppaul, just hashing :P
14:44kotaraksmall maps are array maps.
14:44amalloyoh yeah
14:44LauJensenlarge maps are sorted with rand-elt
14:44amalloy&(frequencies (range 2000))
14:44sexpbot⟹ {0 1, 1024 1, 32 1, 1056 1, 64 1, 1088 1, 96 1, 1120 1, 128 1, 1152 1, 160 1, 1184 1, 192 1, 1216 1, 224 1, 1248 1, 256 1, 1280 1, 288 1, 1312 1, 320 1, 1344 1, 352 1, 1376 1, 384 1, 1408 1, 416 1, 1440 1, 448 1, 1472 1, 480 1, 1504 1, 512 1, 1536 1, 544 1, 1568 1, 576 1, 1600 1, 608 1, 1632 1, 640 ...
14:44amalloy&(frequencies (range 200))
14:44sexpbot⟹ {0 1, 32 1, 64 1, 96 1, 128 1, 160 1, 192 1, 1 1, 33 1, 65 1, 97 1, 129 1, 161 1, 193 1, 2 1, 34 1, 66 1, 98 1, 130 1, 162 1, 194 1, 3 1, 35 1, 67 1, 99 1, 131 1, 163 1, 195 1, 4 1, 36 1, 68 1, 100 1, 132 1, 164 1, 196 1, 5 1, 37 1, 69 1, 101 1, 133 1, 165 1, 197 1, 6 1, 38 1, 70 1, 102 1, 134 1, 16... http://gist.github.com/669681
14:45pppaulcool
14:45LauJensen&(set (range 32))
14:45sexpbot⟹ #{0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
14:45amalloyit's "sorted" by hashcode, because it's a hashmap
14:45LauJensen&(set (range 33))
14:45sexpbot⟹ #{0 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31}
14:45kotarak&(frequencies (range 8))
14:45sexpbot⟹ {0 1, 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 7 1}
14:45amalloyLauJensen: that one never gets old :)
14:45kotarak&(frequencies (range 9))
14:45sexpbot⟹ {0 1, 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 7 1, 8 1}
14:45pppaul&(frequencies (repeatedly 10000 (rand-int 11)))
14:45sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
14:45LauJensenamalloy: that and hardcoded small ints and booleans
14:45kotarak&(frequencies (range 10))
14:45sexpbot⟹ {0 1, 1 1, 2 1, 3 1, 4 1, 5 1, 6 1, 7 1, 8 1, 9 1}
14:46kotarakbleh
14:46amalloy?
14:46kotarak8 entries is the limit IIRC.
14:46kotarakfor array maps
14:46amalloykotarak: small integers hash to themselves, so even a hashmap will look sorted
14:47amalloy&(frequencies (range 50 60))
14:47sexpbot⟹ {50 1, 51 1, 52 1, 53 1, 54 1, 55 1, 56 1, 57 1, 58 1, 59 1}
14:47pppaul&(frequencies (repeatedly 1000 (rand-int 11)))
14:47sexpbotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
14:47pppaulwhat am i doing wrong?
14:47amalloy&(frequencies (repeatedly 1000 #(rand-int 11)))
14:47sexpbot⟹ {0 105, 1 101, 2 85, 3 94, 4 71, 5 80, 6 83, 7 91, 8 99, 9 93, 10 98}
14:47pppauloh yeah
14:48pppaulsilly me
14:48amalloysexpbot: you don't like 4?
14:48amalloy(inc 4)
14:48sexpbot⟹ 1
14:48amalloy*giggle*
14:49pppaul&(frequencies (repeatedly 100000 #(rand-int 11)))
14:49sexpbot⟹ {0 9216, 1 9098, 2 8977, 3 9098, 4 9005, 5 9053, 6 8979, 7 9227, 8 9041, 9 9151, 10 9155}
14:50pppaulso, in your solution, what's the diff of (=... and (apply =...
14:50amalloy&(= (range 2))
14:50sexpbot⟹ true
14:50amalloy&(apply = (range 2))
14:50sexpbot⟹ false
14:51amalloy1: is (range 2) equal to itself? yes
14:51amalloy2: is 0 equal to 1? no
14:52micahmartinWhat's the better name for a rspec port to clojure: 'specl' or 'speclj' (both pronounced 'speckle')?
14:52pppaul&(map frequencies '((1 2) (2 1)))
14:52sexpbot⟹ ({1 1, 2 1} {2 1, 1 1})
14:53pppaul&(=(map frequencies '((1 2) (2 1))))
14:53sexpbot⟹ true
14:53pppaul&(apply = (map frequencies '((1 2) (2 1))))
14:53sexpbot⟹ true
14:53pppauli understand the reason to use apply, since we are getting back a seq
14:53amalloy&(=(map frequencies '((1 2) (212321))))
14:53sexpbot⟹ true
14:54pppaulwhy is (=... working?
14:54amalloyit's not
14:54amalloyit will always return true
14:54pppauloh
14:54pppaul&(= 5)
14:54sexpbot⟹ true
14:54pppauli see
14:56amalloy&(=)
14:56sexpbotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: core$-EQ-
14:56amalloyaw
14:56amalloy&(+)
14:56sexpbot⟹ 0
15:03pppaul&(replicate 100 '10)
15:03sexpbot⟹ (10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10... http://gist.github.com/669721
15:03pppaulbetter than cycle!
15:07fliebelIt is working! https://github.com/pepijndevos/clj-fneeid/blob/master/src/fneeid.clj Line 17 and 18 can be other questions, which can contain other questions in turn. This way you can get down to the function you need.
15:10pppaulmy input is (1 + 2 + 3 + 4) i want my output to be (1 2 3 4) (+ + +) i've looked over the seq functions and thought (partition would do what i wanted, but i don't think so... is there something like (take with steps?
15:11fliebelpppaul: take-nth?
15:12pppaulthanks
15:13fliebel&((juxt #(take-nth 2 %) #(take-nth 2 (next %)) [1 2 3 4 5 6])
15:13sexpbotjava.lang.Exception: EOF while reading
15:13pppaul(take-nth 2 data) & (take-nth 2 (rest data))
15:14kotarak&((juxt #(take-nth 2 %) #(take-nth 2 (next %))) '(1 + 2 + 3 + 4))
15:14sexpbot⟹ [(1 2 3 4) (+ + +)]
15:14kotarak&separate
15:14sexpbotjava.lang.Exception: Unable to resolve symbol: separate in this context
15:14pppaulis there a reason for using next instead of rest?
15:14fliebelpppaul: Not unless you care about total lazyness
15:14kotarakpppaul: next is faster in case you know you'll need the result anyway
15:15kotarakpppaul: rest is required to be 100% lazy
15:15pppauli thought they were almost the same cept one returned nil
15:16kotarakpppaul: which implies that it can't be 100% lazy.
15:16kotarakpppaul: it has to realise the sequence to judge whether to return nil or not.
15:16amalloy$source next
15:16sexpbotnext is http://is.gd/gSsNS
15:16amalloyhm. i didn't realize next was faster; i just assumed it was (comp seq rest). thanks kotarak
15:17kotarakamalloy: using the result of next may be faster
15:17pppaulthe details of the source is pretty hidden
15:17pppaulone calls more, one calls next...
15:18kotarakamalloy: whether next is (comp seq rest) depends on what you have. eg. for lazy-seq yes. For a seq on a vector rest is rather (or (next s) ()).
15:19amalloypppaul: you can look up the java source for more and next, though that tends to be hard to track down too :P
15:19amalloykotarak: huh. i guess that makes sense
15:19kotaraklook in src/jvm/clojure/lang/ASeq.java
15:19fliebelWhat questions do you ask yourself to get to the function you need? I'm trying to come up with useful questions for https://github.com/pepijndevos/clj-fneeid/blob/master/src/fneeid.clj
15:20kotarakamalloy: it depends on your underlying thing being lazy or not. datastructures are not lazy.
15:20amalloyright
15:21pppaul^_^
15:21amalloyfliebel: what are you trying to do? write a decision tree that asks the user "are you doing x? what about y? in that case, maybe you should use pmap"?
15:22fliebelamalloy: Exactly :)
15:22amalloyyou could do it like those online 20-question games
15:23amalloyhm, i can't find one easily
15:23amalloyaha! fliebel: http://www.guessthename.com/
15:26fliebelamalloy: That's the plan. :)
15:26amalloyfliebel: my point is, they don't build this ahead of time
15:27fliebelamalloy: huh?
15:27amalloythey crowdsource it: if you think of an entry they can't guess, then they prompt you for a question that would disambiguate
15:27amalloyand add that to the question database
15:27amalloyhttp://www.guessthename.com/movie/?pos=20387n
15:28amalloyso rather than building a tree yourself by hand, write a program that will ask you questions and build a tree itself
15:31fliebelamalloy: Then it'd have to be a web app or something.
15:32amalloyfliebel: my plan was for you to run it yourself at the repl to build up the db :P
15:33amalloythe idea being that that's easier than hard-coding the tree
15:33fliebelamalloy: And another problem is that their system only rules out one show per question, if I'm correct.
15:34amalloyno, although it does have kinda a poor database
15:36amalloyimagine you had a tree that looked like: (is it a sequence? {yes: (do you want a sequence as a result? {yes: map, no: reduce}), no: inc})
15:36amalloythen answering no to the first question eliminates both map and reduce
15:36fliebelamalloy: How? I tell them at the end that I was thinking about b and now a and give them a rule to define that. So depending on my answer they can rule out a or b, but there is no way to tell if c matches my question or not.
15:37fliebelamalloy: They haven't a tree where you can kill branches.
15:37pppaul&(drop 3 [1 + 2 + 3 + 4])
15:37sexpbot⟹ (#<core$_PLUS_ clojure.core$_PLUS_@8b8791> 3 #<core$_PLUS_ clojure.core$_PLUS_@8b8791> 4)
15:37amalloyfliebel: yeah, actual crowd-sourcing tends to lead to not-very-good data
15:38KirinDaveSo you all can see what a lousy clojure coder I am. ;)
15:38amalloyi was just proposing a way to make your development more interactive and intuitive by having the program ask you for questions. if you want to do it another way, feel free
15:38pppaul&(drop 3 [1 '+ 2 '+ 3 '+ 4])
15:38sexpbot⟹ (+ 3 + 4)
15:39fliebelamalloy: You have a point there.
15:39pppaulwisdom in crowds
15:39pppaulor was is crows?
15:41amalloyKirinDave: how can we see what a lousy coder you are? i don't see any other messages from you
15:41KirinDaveamalloy: Oh. There is this twitter thing. But...
15:41KirinDavehttps://github.com/BankSimple/Clothesline
15:43KirinDaveamalloy: I guess it's customary to fire off an ANN to the mailing list, huh?
15:44amalloyKirinDave: i dunno. i've seen some of those and it certainly wouldn't be spam, but you can invent your own customs
15:44amalloybut some of us don't follow twitter
15:45KirinDaveBetter people than me don't use twitter. ;)
15:45kzarHow come 08 is an invalid number? ,08
15:45kzar(well I get that it's because it starts with 0 but why does that make it invalid?)
15:46kzar&08
15:46sexpbotjava.lang.NumberFormatException: Invalid number: 08
15:46amalloyKirinDave: i don't use twitter either :P
15:46amalloy&010
15:46sexpbot⟹ 8
15:46tlockneykzar: because it's read as octal when you put the 0 in front
15:46KirinDavekzar: Here is a hit
15:46KirinDave,07
15:47clojurebot7
15:47kzarOh gotya, thanks
15:47KirinDave,09
15:47clojurebotInvalid number: 09
15:47KirinDave(fail)
15:47fliebel&(read-string (str "0." "08" "e2"))
15:47sexpbot⟹ 8.0
15:48kzarOh cool there was an easy way to strip the leading 0 in my code
15:49amalloykzar: &(apply str (drop-while #{\0} "0008"))
15:49amalloykzar: &|(apply str (drop-while #{\0} "0008"))|&
15:49sexpbot⟹ "8"
15:50amalloyhmmm. maybe i should get sexpbot to recognize nick: &expr
15:50fliebelamalloy: Good one :)
15:51kzaramalloy: and then get it to check the nick and if it's kzar fuck with me by showing the wrong results
15:51amalloykzar: that code is already there
15:51kzarheh
15:52amalloykzar: &|(= (map range [10 20]))|&
15:52sexpbot⟹ true
15:52amalloysee?
15:53kzaramalloy: I get it, you want apply =
15:53amalloy*chuckle* yes. but for a second it looks like sexpbot is lying to confuse you
15:53fliebelamalloy: I think that made it upstream into Clojure, it gives the same result for me on my own repl :S
15:53amalloyhahaha
15:53kzaramalloy: (apply = (map range [10 20]))
15:53kzaroops
15:53kzaramalloy: |&(apply = (map range [10 20]))
15:53kzaramalloy: &|(apply = (map range [10 20]))
15:54fliebelkzar: traing one as well
15:54amalloykzar: &|'[some expr]|&
15:54sexpbot⟹ [some expr]
15:54amalloyit needs to be on both ends
15:54kzaramalloy: &|(apply = (map range [10 20]))|&
15:54sexpbot⟹ false
15:54kzaroh yea
15:54amalloyand yes, i know. this was a topic of discussion in #clojure an hour or two ago
15:54fliebelthat is what i... tried to say :(
15:55amalloykzar: btw, if you can think of a better way to unambiguously delimit exprs than the &| nonsense, let me know
15:55kzaramalloy: How about this, if you type a sexp with no special characters the bot doesn't eval but it notices. Then if you type eval it evals it
15:55amalloyi will happily add it
15:56amalloykzar: too hard, and also vague. everything you type is a sexp
15:56amalloyhow does he know "sexp" wasn't something i might want to eval later? it's a valid symbol
15:57kzaramalloy: Well for that feature it would just worry about things in parenthesis I guess but good point
15:57amalloy&[(inc 1) (dec 1)]
15:57sexpbot⟹ [2 0]
15:57amalloyanyway
15:58amalloybut if you can think of something within a single message that's easier to type than &| i'd love to hear it
15:58amalloymaybe #=expr=#
15:59jarpiain,`=#
15:59clojurebot=__147__auto__
15:59amalloyah
15:59amalloyjarpiain: =# is legal clojure, but so is |&. they're both things nobody is likely to type though :P
15:59jjidoamalloy: does it have to have a closing tag?
16:00kzarYea I mean if there's a end of message before the closing tag couldn't it just take the hint ?
16:00amalloyjjido: without it, you can't do &|'clever|& stuff like &|(inc 1)|&
16:00sexpbot'clever ⟹ clever
16:00sexpbot(inc 1) ⟹ 2
16:00amalloybut you're right, i could let it implicitly close at EOM
16:02amalloythough atm only Raynes has permission to restart sexpbot, and he's taking a nap
16:03jjidohow about &|('clever) &|((inc 1))
16:04amalloyjjido: yeah, i can do that too
16:05amalloyi think i'll add ## as well, with similar shorthand forms
16:09amalloyjjido: ##10 ##11
16:09buttered-toast10 ⟹ 10
16:09buttered-toast11 ⟹ 11
16:10amalloygood? any other suggestions?
16:11jjidoamalloy: good. I suggest skipping ## if it appears inside a matched pair of double quotes
16:11buttered-toastjava.lang.Exception: Unable to resolve symbol: if in this context
16:11amalloyjjido: sadly that's kinda too hard :P
16:11amalloyregexes aren't that clever
16:11jjido(println "## hello")
16:11buttered-toastjava.lang.Exception: Unable to resolve symbol: hello in this context
16:11amalloyyes, i know what you mean
16:12amalloybut such is life. that's why Raynes picked the super-obscure &|'syntax|& - to avoid any accidental matches
16:12sexpbot⟹ syntax
16:12buttered-toast⟹ syntax
16:12amalloyhaha sorry bots
16:12pppauli want to (eval (+ 1 2)) from seq (1 + 2) named 'data' i tried (eval (list (second data) (first data) (nth 3 data))) but got a cast error from lazySeq to number
16:13amalloy&|(nth [1 2 3] 2)|& &|(nth 2 [1 2 3])|&
16:13sexpbot(nth [1 2 3] 2) ⟹ 3
16:13sexpbot(nth 2 [1 2 3]) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
16:14pppauli think my problem is (class +) != (class (second data))
16:14amalloyno pppaul, see my eval above for what your problem is
16:14amalloyyou have two: params in wrong order; (nth n 0) == (first n)
16:15pppauloh
16:15amalloyi think you also need to quote the + if it's not already quoted
16:15pppaul(eval (list (second data) (first data) (nth data 3)))
16:15pppauljava.lang.Exception: Unable to resolve symbol: 1 in this context (NO_SOURCE_FILE:159)
16:15pppaulthe error changed
16:16pppaul&(class +)
16:16sexpbot⟹ clojure.core$_PLUS_
16:16pppaulmy '+' is a symbol, though
16:16jjido,(re-seq #"(([^\"]*\"){2})*##" "(println \"## hello\")")
16:16clojurebot(["##" nil nil])
16:16pppaul&(class (quote +))
16:16sexpbot⟹ clojure.lang.Symbol
16:17amalloy&(list* (map #(nth '(1 + 2) %) [1 0 2]))
16:17sexpbot⟹ (+ 1 2)
16:17pppaul&(class (unquote (quote +)))
16:17sexpbotjava.lang.IllegalStateException: Var clojure.core/unquote is unbound.
16:17amalloyjjido: and what about \\"? that really is the end of a quote
16:17amalloyand \\\" isn't
16:18amalloyit's probably possible but i think failing when ## is part of the string is an acceptable compromise for getting easy multi-eval
16:19jjidoyes, at worse there will be more messages in the channel
16:19amalloyright, or someone who actually wants to write ##(println "##foo") will have to use & instead :P
16:19amalloypppaul: see my list* for how i would rearrange your list
16:20pppaulyeah, that's what i'm doing, your's is shorter
16:20amalloyand eval isn't working?
16:22cs02rm0does anyone know why lein would complain at _everything_ (e.g. lein deps) that it is not a task?
16:22amalloycs02rm0: lein self-install?
16:22cs02rm0amalloy: it complains that isn't a task too
16:23amalloyclojurebot: lein?
16:23clojurebotlein is http://github.com/technomancy/leiningen
16:23pppauli was inputting wrong data, i changed it and debugging now...
16:23amalloycs02rm0: you could get a fresh copy of lein from https://github.com/technomancy/leiningen/raw/master/bin/lein and see if that helps
16:23raekcs02rm0: did it work before, or is this after a fresh install?
16:24technomancycs02rm0: there's a bug in 1.3 where it would say that if you ran tasks that required a project.clj in a directory without one.
16:24cs02rm0raek: fresh. OSX.
16:24cs02rm0technomancy: this is 1.2.0
16:24amalloycs02rm0: fresh from where? last i heard the macports version of lein wasn't very good
16:25cs02rm0amalloy: ports. i'll give it a go from github. thanks
16:27technomancycs02rm0: that bug may be present there too
16:29romain_pHi everyone, http://clojure.pastebin.com/D4AjBJ80
16:29romain_phow do I make this function return an empty vector if the input is an empty seq?
16:29hsuhshouldn't you be using map ?
16:30amalloyhsuh: i would, but for is fine too
16:30hsuhfun, wasnt aware of its existence
16:31amalloy&(let [x #{}] (if (seq x) [] (conj x 10)))
16:31sexpbot⟹ #{10}
16:31amalloy&(let [x #{}] (if-not (seq x) [] (conj x 10)))
16:31sexpbot⟹ []
16:31amalloyromain_p: this what you want?
16:32romain_pamalloy: probably, thanks
16:34cs02rm0superb - the github version of lein seems to work flawlessly, many thanks.
16:36amalloycs02rm0: enjoy
16:36amalloytechnomancy: just pinging you for ^^
16:37technomancygreat!
16:38kotarak,(or (seq nil) [])
16:38clojurebot[]
16:39jccchow do i best accomplish something like (insert [1 2 3] 0 4) -> [1 4 2 3]
16:40kotarakjccc by using finger trees maybe. vectors are not designed for such things.
16:40jcccyeah i was hoping not to have to pull in contrib
16:41kotarakjccc: if you need to: (defn insert [vektor idx value] (into (subvec vektor 0 idx) [value] (subvec vektor idx))) or something like that
16:43jccckotarak: yeah i was thinking i would have to do something like that. guess ill try to figure out finger trees. thnx
16:49raekinstead of _insterting_ elements at the right places, would i be possible to make a function that _selects_ the elements in the right order and returns them as a sequence?
16:50raekjccc: ^
16:50kotarakraek: (concat (subvec v 0 idx) [value] (subvec v idx))
16:50kotarakBut you loose random access.
16:52raekI was thinking about something like the difference between insertion sort and selection sort
16:52pppaulwoot! got my recursive infix function working
16:57raek...since instertion into the middle is costly, but making lazy sequences is cheap
16:57jcccraek/kotarak: i think just vectorizing kotaraks solution is fine for now. not sure of its performance
16:57rata_hi all
16:57hsuhKirinDave: i'm trying to understand how clothesline/webmachine differ from ring in how you have to write your services
16:58kotarakjcc: O(N) in vector length
16:58jccckotarak: yeah where like assoc on a vector is O(1)
16:59kotarakjccc: yes, but assoc != insertion
16:59kotarakhonestly it's O(log_32 N)
17:00jccckot: no i know. i wish it could though :). oh true
17:00LauJensenkotarak: enough chatting, start blogging :)
17:00kotarakLauJensen: argh.
17:00kotarak;)
17:01kotarakLauJensen: currently mulling about a C program.
17:13kzarHow would I do something like this?
17:13kzar&(map + [[1 2 3] [1 2 3]])
17:13sexpbotjava.lang.ClassCastException: Cannot cast clojure.lang.PersistentVector to java.lang.Number
17:13amalloy&(apply map + [[1 2 3] [1 2 3]])
17:13sexpbot⟹ (2 4 6)
17:14kzaramalloy: How come map gets evaled there?
17:14amalloy&(doc apply)
17:14sexpbot⟹ "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
17:15amalloykzar: so it turns into (map + [1 2 3] [1 2 3])
17:15kzar&(apply map + - * / [[1 2 3] [1 2 3]])
17:15sexpbotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$_
17:15amalloy&(apply map (juxt + - * /) [[1 2 3] [1 2 3]])
17:15sexpbot⟹ ([2 0 1 1] [4 0 4 1] [6 0 9 1])
17:16kzaramalloy: I don't really understand how you can have one extra function but not two?
17:16amalloykzar: you don't have any extra functions
17:16amalloyapply is a way to tell clojure that the last argument should not be treated as a single list-argument, but rather expanded, and each element treated as its own argument
17:17amalloyso apply mucks around with the last argument, then gets out of the way and calls map
17:17kzaramalloy: OK so (apply map + [[1 2] [1 2]]) only expands the last argument so it's something like (apply map + [1 2] [1 2]) which is then something like (map + [1 2] [1 2])?
17:18amalloyyep. i said that, in fact, with my "so it turns into..."
17:19kzaramalloy: yea thanks, I got that it worked but I didn't understand the process
17:19kzaramalloy: so my dodgy example would be (map + - * / [1 2 3] [1 2 3]) which ovbiously isn't going to work
17:19amalloyexactly
17:19kzarsweet I understand :)
17:20amalloybut you can get results basically like that by wrapping + - * / all into a single function, like i did with juxt
17:20kzaramalloy: Yea I get you
17:21kzarto start with I thought it was some special case or something
17:22KirinDavehsuh: I don't understand
17:22KirinDavehsuh: Clothesline uses ring.
17:22amalloyKirinDave: i think he's asking what clothesline does for him that ring doesn't
17:22KirinDaveOh
17:22KirinDavehsuh: It provides (or, it will provide) correct http 1.1 behavior by default.
17:23hsuhKirinDave: yep, kinda.. because from what it seems to me now, using ring, because you get the http request as a map, you can do anything with it easily..
17:23KirinDavehsuh: Well, you won't be altering the request.
17:23KirinDavehsuh: WebMachine's benefit is not in golfing low code count on a simple http service.
17:24KirinDavehsuh: It's more about providing a very clean way to link your code with a http handler and not have to worry about crazy edge cases in protocol.
17:24KirinDaveYou get correct behavior by default.
17:24KirinDaveIt also lets you do things like handle incoming content types much more easily.
17:25ohpauleezKirinDave: re: "...but none of them are specifically oriented towards designing APIs with correct HTTP 1.1 behavior"
17:25KirinDaveohpauleez: Did I miss one>
17:25ohpauleezIn the past I have found Moustache to fill this spot for me, quite well
17:25KirinDaveI know of coda's jersey for Scala...
17:25technomancyit does begs the question why not just fix ring...
17:26ohpauleezor enhancing Ring
17:26hiredmantechnomancy: or at least implement as a wrapper for ring
17:26KirinDaveRight now it produced handler functions that are suitable for use with ring.
17:26KirinDaveThere are some produce-sever functions for convenience there, but they all just use ring.
17:26hiredmanwell then
17:27KirinDaveI mean, Ring is plenty good at what it does. It's like Rack. Putting tools for making restful APIs into Ring seems outside the scope of that project. The same argument would work against compojure (w.r.t serving generated content).
17:28KirinDavehsuh: Does that answer the question?
17:29hsuhKirinDave: oh yeah, i'll keep an eye as well :) sooner or later someone will use it for something neat and mind will be blown.. or something
17:30KirinDaveMaybe.
17:32KirinDaveohpauleez: You know, I have been considering making some mustache-like syntax for generating clothesline handlers.
17:32KirinDaveohpauleez: Currently Clothesline is awkward.
17:32ohpauleezKirinDave: I've been doing the same for some stuff I'm working on in Aleph
17:32KirinDaveIt'd be nice to get a familiar and helpful layer on top for actually delivering things.
17:32ohpauleezI find it extremely powerful and elegant
17:33KirinDaveCould I see a snippet of moustache code for doing some restful stuff?
17:35KirinDaveohpauleez: Do you have a git project I could peer at?
17:36ohpauleezCurrently none of that is sitting in git, but when I hurray up and finish net-ns, it'll be in there
17:36ohpauleezlet me link you
17:37ohpauleezKirinDave: https://github.com/ohpauleez/net-ns A whole lot of nothing but scratches right now.
17:37KirinDaveI'm curious how you'd do things like handle http headers properly
17:37KirinDavee.g., if-modified-since
17:37KirinDave(Not that clothesline does that just yet)
17:43nickikdoes anybody know why form-dot-clj isn't working on the appengine?
18:09pppaulsomeone want to help me with a regex problem?
18:11amalloypppaul: don't use regexes? :)
18:11pppaulbut they are sexy
18:11amalloyclojurebot: ask?
18:11clojurebotGabh mo leithscéal?
18:11amalloyclojurebot: anyone?
18:11clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
18:11pppaul^(?:\d[\\+])+\d$ what does the '$' mean?
18:11amalloyclojurebot: regex?
18:11clojurebotSometimes people have a problem, and decide to solve it with regular expressions. Now they have two problems.
18:11amalloybah
18:11amalloyanyway pppaul it means only match at end of input
18:11replacapppaul: you said that the other night. I think you need to go review "sexy" as a concept :)
18:12pppaulregex is kinky
18:12amalloypppaul: are you trying to match either a \ or a +? that's kinda a weird thing to want
18:12replacapppaul: in the sense that you might get all tangled up and not be able to get out, yeah
18:12pppaul^_^
18:12amalloyreplaca: haha awesome
18:13pppauli want to match "1+2+3+4" and not "12+2+3+4"...
18:13amalloyyou want...only single digits?
18:13pppaulit is weird, but it's for the 24 game, so it's got to be that way
18:13amalloyah
18:14amalloy[\\+] is not what you want. \+ is fine, and so is [+], but what you have will match 1\2\3+4
18:14pppaulmy tests pass with \\+. i'll try with \+
18:15amalloyyes, it matches everything you want, and also some things you don't want
18:15amalloyis my point
18:15replacapppaul: you don't need any \ there. inside the [] you don't need to escape +
18:16amalloy&(re-find #"^(?:\d[\\+])+\d$" 1\2\3\4)
18:16sexpbotjava.lang.IllegalArgumentException: Wrong number of args (5) passed to: core$re-find
18:16amalloy&(re-find #"^(?:\d[\\+])+\d$" "1\2\3\4")
18:16sexpbot⟹ nil
18:16pppaulok, i'll try not escaping...
18:16amalloypppaul: don't "try" it; it's guaranteed to work :P
18:17replacapppaul: *either* escape or [] will work, both doesn't really make sense
18:17pppauljava.util.regex.PatternSyntaxException: Illegal character range near index 10
18:17pppaul^(?:\d[+-\*])+\d$
18:17pppaul ^
18:17pppauljava.lang.Exception: Unable to resolve symbol: string in this context (NO_SOURCE_FILE:0)
18:17pppauljava.lang.Exception: Unmatched delimiter: )
18:17pppauljava.lang.Exception: Unmatched delimiter: ]
18:17pppauluser=> java.lang.Exception: Unable to resolve symbol: match in this context (NO_SOURCE_FILE:683)
18:17pppauljava.lang.Exception: Unmatched delimiter: )
18:17pppauljava.lang.Exception: Unmatched delimiter: )
18:17pppauldidn't work
18:17amalloypppaul: don't escape * either!
18:17amalloyinside []
18:17pppauli wasn't
18:17pppauli want to capture it
18:17replacawhat's this for: \
18:18replaca?
18:18amalloy\ != /
18:18pppaul^(?:\d[+-/*])+\d$ works
18:18replacaamalloy: I think you made a new emoticon
18:18amalloyhahaha
18:18joegalloAh, \ != /, I'm pretty sure that's an operator in perl.
18:18replacajoegallo: most things are
18:18amalloymy secret identity is Angry Regex Man
18:18pppaullol
18:19pppaullove regex
18:19pppaulregex grows hair on my chest
18:19amalloyor maybe "I'm so excited by operators!"
18:37amalloyanyone have experience with somnium.congomongo? i'm trying to store a tree/nested-map like {:word "doctor" {:links {"phil" 1}}} {:word "phil" {:links {...}}}
18:37amalloybut it coerces all the map keys to keywords, and all the map values to strings. i'd be totally fine with only strings or only keywords, but i'm having some serious trouble getting either
18:38amalloy(because if i look up "doctor"s links i see that the key is :phil, not "phil", and so the map manipulation i do in clojure doesn't work too great)
18:50Raynesamalloy: Hahaha a nap.
18:52amalloyish
18:55Raynesscottj: Huh?
18:55Raynesscottj: I used it in SLIME, and almost all of my development was in a cake REPL. I don't understand.
18:59RaynesOh shit. You're right. How weird.
19:03gertalothey all. I need to write a function that given a vector [a b c d] returns a vector [a a+b a+b+c a+b+c+d]. How would I do that?
19:04amalloy&(reductions + [1 2 3 4])
19:04sexpbot⟹ (1 3 6 10)
19:04gertalotah!
19:04gertaloti love clojure :)
19:04gertalotthx
19:04amalloywelcome gertalot
19:05pppaul(inc gertalot)
19:05sexpbot⟹ 1
19:10pppaulcommenting in emacs is messed up
19:11amalloy...blaming emacs for your problems tends to end with "gosh, i see now why the way it works is better than what i expected"
19:12pppauli dono
19:12pppauli'm putting in comments, and emacs is doing it's own thing
19:12pppaulthen i try to format the comments and my code suddenly ends up in the middle of sentences i wrote in my comments
19:14technomancypppaul: are you using M-;?
19:15pppauli'm not sure
19:15pppauli'm using ;
19:15pppaullet me try the meta key
19:16pppaulso, how do i change the setting where it word-wraps?
19:16amalloyM-x autofill-mode to toggle it entirely, C-x f to change the width
19:16pppauldoesn't C-x f open a new file?
19:17amalloyno, that's C-x C-f
19:17pppaulmy emacs settings are diff
19:17pppaulC-x f does file stuff
19:18pppauloh well
19:18Raynestechnomancy: ping
19:19Raynestechnomancy: What is SLIME's 'eval thread' and how can one kill it with Clojure code? It appears that I'm doing just that, and I have absolutely no clue how. In any case, when my code runs, C-x C-e and the like don't work any longer.
19:21amalloyRaynes: is it possible that starting the java security manager kills some daemon threads?
19:21amalloyie, i bet it's swank, not slime
19:21technomancyI'm not sure how to do it from clojure. you can try M-x slime-list-threads
19:21RaynesIt never did this from clj-sandbox, so it has to be something specific to my code.
19:23Rayneshttps://github.com/Raynes/clojail/blob/master/src/clojail/core.clj#L65 Is the relevant function if anyone has any epiphanies.
19:25amalloyRaynes: it happens when all you do is call (sandbox ...)?
19:25RaynesI believe so. Not sure if it happens then or when you call what sandbox creates.
19:25RaynesI'll test.
19:25amalloyif the former then it *has* to be the security manager, since that's the only code that actually executes
19:26RaynesIt's the former then.
19:27defnHey Raynes -- what's this new project I heard about on twitter?
19:27Raynesamalloy: Removing that code doesn't do anything to fix this.
19:27amalloyhm
19:27Raynesdefn: This one. My awesome new sandbox problem that doesn't work properly in SLIME.
19:28RaynesGreat introduction, eh?
19:28Raynesproject*
19:28Raynesamalloy: Maybe it happens when I use, let's try that.
19:29amalloyhey technomancy: C-c M-p doesn't work if the ns form has ^{metadata}
19:30RaynesIt actually appear SLIME isn't working properly for me at all, even fresh.
19:30Raynes...
19:31Raynesamalloy: Can you clone clojail and try this out yourself, pretty please?
19:31amalloyRaynes: just did
19:31amalloyin the slime repl, i evaluated (sandbox secure-tester)
19:31amalloyC-x C-e still works fine
19:31defnRaynes: How is this different from yours and Licenser's sandbox?
19:31RaynesYeah, I guess my SLIME is just all of a sudden broken.
19:31technomancyamalloy: true. IMO ns metadata is not a good idea, but I would take a patch to fix slime.
19:32amalloyRaynes: and now i've called the resulting sandbox: (s '1), and C-x C-e still works
19:32Raynesdefn: Mine is arguably a bit cleaner, and it's simpler. Most of all, it's documented and not monolithic.
19:32amalloydefn: he's reimplementing it but in a less bad way
19:33defn:D
19:33Raynesdefn: I'm trying to take clj-sandbox and just reimplement it in a more sane way.
19:33defnCool.
19:33Raynesamalloy: I'm going to nix Emacs and restart it.
19:34defnI'd love to see a sandbox that is like Licenser's, but runs in an honest-to-god VM
19:34defnso you can be liberal about running everything under the sun
19:34amalloyRaynes: sounds good. really everything slime is working for me still: C-c C-m and friends work fine
19:34defnside effects and all
19:35amalloydefn: if you have a few GB of ram to host some VMs on we're accepting donations
19:35RaynesYep, it's all working great now.
19:35RaynesI don't know what happened with scottj.
19:36RaynesI found a bug though.
19:38amalloyhah, what was it?
19:46hsuhcan someone give me an insight on how to go from [["a" "b"] [1 2]] to [["a" 1] ["b" 2]] ? trivial in imperative way, but cant see it in clojure
19:46amalloy&(apply map vector [["a" "b"] [1 2]])
19:46sexpbot⟹ (["a" 1] ["b" 2])
19:46amalloyeven more trivial in clojure :)
19:48amalloyhsuh: the apply converts it to (map vector [...]), which is effectively [(vector "a" 1) (vector "b" 2)]
20:04hsuhamalloy: that code is puzzling me a little bit because map accepts more than one collection
20:04hsuh&(map vector ["a" "b"] [1 2])
20:04sexpbot⟹ (["a" 1] ["b" 2])
20:04hsuhbut if that works, why isnt this allowed?
20:04hsuh&(map (fn [x] (* x 2)) [1 2 3] [4 5 6])
20:04sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: sandbox4138$eval6573$fn
20:04amalloy&(map (fn [x y] (* x y)) [1 2 3] [4 5 6])
20:04sexpbot⟹ (4 10 18)
20:05hsuhoh, its like clojure doesnt need map2
20:05amalloy&(doc map)
20:05sexpbot⟹ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls ... http://gist.github.com/670171
20:06amalloyi don't know what map2 is, but no, we don't need it :P
20:06amalloy&(apply map + (replicate 100 (range 10)))
20:06sexpbot⟹ (0 100 200 300 400 500 600 700 800 900)
20:06amalloylook, a map100 :)
20:07hsuhi think map2 memory came from ocaml, which probably explains its need to exist
20:07hsuhamalloy: thanks a lot
20:21livingstonhow do I type hint for a non-primitive array? e.g. I want to hit this method: [ 3] add : void (Iterable,Resource[])
20:22amalloylivingston: ISTR it's ^LResource or something close to that
20:23amalloyjava has weird classnames for arrays
20:23livingstoni'll give that a shot, thanks
20:23amalloylivingston: &|(make-array Object 0)|&
20:23sexpbot⟹ #<Object[] [Ljava.lang.Object;@b62f6>
20:24amalloythe [Ljava.lang.Object is the array's official classname
20:24amalloyso you probably have to do like ^{:tag "[Ljava.lang.Object"}
20:24amalloyanyway i'm off. good luck
20:25livingstonamalloy: that will give me an empty array right? that's cool, that's what I happen to want (this time)
20:25livingstonthanks
20:25amalloyyes it will
20:25livingstonlooks like that worked
20:33pppaul(ns rosettacode.24game
20:33pppaul (:require '[clojure.string :as str]))
20:33pppaulrosettacode.24game=> (str/capitalize "12312312")
20:33pppauljava.lang.Exception: No such namespace: str (NO_SOURCE_FILE:83)
20:33pppaul:(
20:34pppaulwhat am i doing wrong?
20:34pppaul^_^
20:34technomancypppaul: no need to quote require clauses inside the ns form
20:35pppaulok, i copied it off of the clojure API
20:35technomancyI find that ... unlikely?
20:35technomancybut if there's a typo in the official docs it should get fixed
20:35pppaulIt is poor form to (:use clojure.string). Instead, use require
20:35pppaulwith :as to specify a prefix, e.g.
20:35pppaul(ns your.namespace.here
20:35pppaul (:require '[clojure.string :as str]))
20:36pppaulworks now, thanks :)
20:36pppaulshould get the official docs edited
20:36technomancyeep; do you have a URL for that?
20:37pppaulhttp://clojure.github.com/clojure/clojure.string-api.html
20:37technomancyok, good catch. sorry I doubted you. =\
20:37pppaul^_^
20:38replacaThat whole comment doesn't even really belong there
20:38replacaI think it was Stuart reacting to the old (googlecode) autodoc for contrib which had use in it
20:41pppauli use :use for clojure.test... is that bad?
20:41pppauldoes it make sense at all?
20:42technomancyI think that's acceptable
20:42pppaulwhy is :use in the language?
20:42technomancynothing wrong with :use if you also have :only to limit the scope of what you bring in
20:42technomancyit's a design bug that leaving out :only brings in everything
20:42pppauli need a tutorial on ns stuff :(
20:42Derandercan you :require :as?
20:43technomancyit's slated for fixing; everyone agrees it is needlessly complex
20:43technomancypppaul: the best thing to do is read existing code
20:43pppauli find it really tricky (been having lots of problems getting my stuff to work using (ns :require) form
20:43Deranderyes, the whole use/require/import stuff is one of my biggest sticking points as a newbie
20:43DeranderI'm still cargo-culting it
20:44pppauli use clojuredocs, but the examples for ns stuff seem a bit weak
20:44Deranderyes
20:44Derandersame problem
20:47replacaDerander: yes, you can :require :as
20:47pppaul?
20:48pppaulns rosettacode.24game
20:48pppaul (:require [clojure.string :as str])
20:48pppaul (:use (clojure.test))) rosettacode.24game=> java.lang.Exception: Unable to resolve symbol: deftest in this context (NO_SOURCE_FILE:158)
20:49pppaulso, i use :use, but deftest still isn't defined
20:50pppaulbut, i created the ns before, and then tried to fix it by adding :use
20:50pppaulare namespaces allowed to change? or are they immutable?
20:51tomoj(:use clojure.test)
20:51tomojnot (:use (clojure.test))
20:51amalloypppaul: tomoj is right
20:52amalloysymbols, vectors, and lists all behave differently in a :use entry
20:52tomojvectors and list are the same, aren't they?
20:52pppaulfrom (doc ns) (ns foo.bar
20:52pppaul (:refer-clojure :exclude [ancestors printf])
20:52pppaul (:require (clojure.contrib sql sql.tests))
20:52pppaul (:use (my.lib this that))
20:52pppaul (:import (java.util Date Timer Random)
20:52pppaul (java.sql Connection Statement)))
20:52tomojI mean, they're seqs
20:52tomoj(my.lib this that) means both my.lib.this and my.lib.that
20:52amalloy&(map class () [])
20:52sexpbot⟹ ()
20:53technomancyugh; that's awful. one more thing to be fixed in CLJ-272 I guess.
20:53amalloy,(map class () [])
20:53clojurebot()
20:53amalloyoh hah
20:53amalloy&(map class [() []])
20:53sexpbot⟹ (clojure.lang.PersistentList$EmptyList clojure.lang.PersistentVector)
20:53pppaulwooo
20:53amalloytomoj: maybe you're right. namespaces still confuse me :P
20:54amalloy&(macroexpand (ns foo (:require [clojure.contrib math] (clojure.contrib math))))
20:54sexpbotjava.io.FileNotFoundException: Could not locate clojure/contrib/math__init.class or clojure/contrib/math.clj on classpath:
20:54amalloy&(macroexpand '(ns foo (:require [clojure.contrib math] (clojure.contrib math))))
20:54pppaulworks now :D
20:54sexpbot⟹ (do (clojure.core/in-ns (quote foo)) ((fn* loading__4410__auto__ ([] (dot clojure.lang.Var (clojure.core/pushThreadBindings {clojure.lang.Compiler/LOADER (dot (dot loading__4410__auto__ getClass) getClassLoader)})) (try (clojure.core/refer (quote clojure.core)) (clojure.core/require (quote [clojure.... http://gist.github.com/670215
20:57amalloytomoj: yeah, okay, [] and () are the same in ns. another of my delusions spoiled
20:57pppauli would assume that [] gets converted to a seq
20:58pppaulit would have to if any seq funcs were applied to it
20:58amalloypppaul: true as far as it goes. but rich *could* check whether it's a vector or a list before doing anything to it, and then do different things depending. apparently he doesn't
20:59pppaulyeah... it looks like that is sorta being done, since (clojure.contrib is not an op
20:59tomoja list is a list :)
20:59pppaulleast i don't think it is
21:00amalloytomoj: ?
21:00pppaulit's an unevaluated list, which is different from an evaluated one
21:00tomojthere doesn't need to be any special handling to avoid treating clojure.contrib as an op
21:00tomojit's just a list
21:01pppaulwouldn't the special handling be in the macro?
21:01amalloypppaul: yes, but not necessarily in the expansion
21:01tomojno need for special handling in the macro either
21:01tomojthe macro just receives a list and can process it like a seq
21:01pppaulthe macro doesn't say to not evaluate the list?
21:02amalloytomoj: i know. (i think) we're discussing the hypothetical situation where rich wants to treat lists and vecs differently
21:02tomojyeah, hypothetical, not sorta being done
21:02pppaulanyway, it doesn't matter much... documentation matters more now :)
21:02pppaulnewbs in trouble
21:03amalloy(defmacro is-list? [var] (if (list? var) () [])
21:03amalloy(is-list? [1 2 3]) ; expands to [] with no trace of the list/vec check
22:33tomoj&(keys [1 2 3])
22:33sexpbotjava.lang.ClassCastException
22:33tomojtry that in a plain repl
22:34tomojoh, nevermind
22:34tomojI was trying to figure out why it prints a single '(', but that's seqiness
22:34tomojfor some reason, though, (keys [1 2 3]) causes slime to error
22:34tomojsomething strange about the exception I guess?
22:45amalloytomoj: keys is lazy
22:45amalloy&(let [x (keys [1 2 3])] 1)
22:45sexpbot⟹ 1
22:46Raynes,(.replace (.replace "x" "x" "y") "y" "x" "x")
22:46clojurebotjava.lang.IllegalArgumentException: No matching method found: replace for class java.lang.String
22:46amalloyso (keys [1 2 3]) completes without error, and then when the repl tries to show it to you the exception finally comes up
22:46tomojright
22:46amalloyRaynes: ?
22:47RaynesToo many arguments.
22:47RaynesWeird error message.