#clojure log - Mar 18 2011

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:48 tufflax: ,(macroexpand '(with-open [r (java.io.FileReader. "asdf.txt")] (.read r)))

0:48 clojurebot: (let* [r (java.io.FileReader. "asdf.txt")] (try (clojure.core/with-open [] (.read r)) (finally (. r clojure.core/close))))

0:48 tufflax: I find that "clojure.core/close" strange...

0:50 I mean, FileReader doesn't have a method name clojure.core/close. How does this work? :P

0:50 amalloy: tufflax: ISTR that the interop forms call .name on the symbol representing the member they should access

0:50 &((juxt str name) `close)

0:50 sexpbot: ⟹ ["clojure.core/close" "close"]

0:51 amalloy: they have to turn the symbol into a string anyway, to do the reflective call; they use name rather than str so that the namespace half becomes irrelevant

0:51 tufflax: Aha, ok.

0:51 Thanks

1:01 tomoj: binary juxt is sorta (a -> b) -> (a -> c) -> a -> (b,c) right?

1:02 if so hoogle claims they don't have it. was wondering what they named it

1:22 scottj: if they had had it there'd be a pretty good chance rhickey would have copied the name

1:40 brehaut: tomoj: (&&&), its in Control.Arrow

1:43 amalloy: brehaut: i think i might be getting sick. tomoj's description of juxt in haskell made sense to me

1:45 brehaut: tomoj: hoogle might have been misleading because the type is Arrow a => a b c -> a b c' -> a b (c, c')

1:45 amalloy: haha dont worry, im sure type definition has resolved your symptoms

1:46 tomoj: it happens that there is an instance of Arrow a for ->

1:50 tomoj: it also has a related operator (***) that is (for functions) (a -> b) -> (a' -> b') -> (a, a') -> (b, b')

1:51 tomoj: brehaut: aha

1:53 brehaut: hurrah arrows :P

1:54 tomoj: are we missing that one?

1:54 brehaut: we are i believe

1:55 (defn *** [& fs] (fn [& as] (map invoke fs as))) i guess?

1:55 clojurebot: ,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 11 25))

1:56 brehaut: i want to call it par, but that confuses everyone

2:04 haha amazon is recommending me C++ stuff on the O'Reilly Clojure Programming preorder page. target audience failure

3:28 amalloy: Customers who bought these two items together also frequently bought...Treating Yourself for Multiple Personalities

3:54 dat_eye_socket: all of yourselves?

4:15 amalloy: anyone have an opinion about these two implementations of cond? https://gist.github.com/875767

4:18 in practice only the latter is viable in clojure.core because things like partition (and reverse!) aren't around yet

7:00 notsonerdysunny: https://gist.github.com/875893

7:02 Hello everybody, When I tried to understand deftype and picked up the pasted code from stack overflow .. and tried to compile it .. i get

7:02 error: java.lang.ClassCastException: isomorphism.half-edge.Point cannot be cast to compile__stub.isomorphism.half-edge.Point

7:03 (p.s. it is in file by name half_edge.clj whose namespace is defined by (ns isomorphism.half-edge) .. can anybody help me to figure this out?

7:04 my clojure version is {:major 1, :minor 2, :incremental 0, :qualifier ""}

7:04 clgv: notsonerdysunny: do you have to use definterface?

7:05 if not, switch to defprotocol

7:05 (defprotocol IPoint

7:05 (getX [this])

7:05 (setX [this, v]))

7:08 Raynes: defprotocol and deftype go together like mashed and potatoes.

7:08 clgv: Raynes: is that good or bad meaning?

7:08 notsonerdysunny: clgv: it didn't help ...

7:08 Raynes: clgv: Mashed potatoes are very good.

7:09 notsonerdysunny: It gives the same error

7:09 clgv: notsonerdysunny: figured out that your error is here: (set! (.x this) v) I overread it the first time

7:09 use (set! x v) instead

7:10 notsonerdysunny: ah .. that fixed it .. thanks clgv

7:10 clgv: Raynes: good. clojure world image remains sound ;()

7:10 ;)

7:11 notsonerdysunny: but in the hind sight .. I don't find any reason why the earlier version should not work...

7:12 clgv: Raynes: how am I supposed to organize my code i clojure when I have a lot of functions as parameter for a meta-algorithm?

7:12 I need them at very different "levels" within the algorithm

7:13 always passing them as parameters to the next level is quite hideous as there a lot of them

7:13 notsonerdysunny: you can't access ".x" anymore when you declare it :volatile-mutable

7:13 Raynes: Would it be better to just factor out the algorithm into smaller functions so that there are fewer 'levels'?

7:14 clgv: I dont think so, since I am very close to the mathematical definition already ;)

7:15 it has a general structure of an iteration-loop and subiteration-loops within each iteration

7:16 and the parameter functions are used to adjust it to a specific problem instance

7:16 Raynes: Sounds like your best bet is to just wear a blindfold while reading that code.

7:17 clgv: no, it's quite readable. right now I use a execution context object (deftype) that is composed of the problemspecific functions and exposes them via defprotocol

7:18 it's convenient right now, but looks very much OOPish... that's why I ask

7:19 Raynes: I'm the king of writing OOPish code.

7:19 Which is surprising, since I don't really know any OOP languages.

7:19 clgv: I have some history with them ;)

7:20 Raynes: I don't have the excuse of having been using OOP languages for many years before Clojure. Alas, it's just bad manners.

7:22 clgv: I think there must be a general solution to it. When having functions as first class citizens you will often need multiple functions as parameters for a highlevel algorithm, I guess.

7:22 notsonerdysunny: can I define the methods directly inside a deftype...? instead of defining a seperate interface/protocol and then defining it in the deftype...?

7:23 clgv: notsonerdysunny: I don't think so. I got a compiler exception when I tried

7:23 Raynes: notsonerdysunny: No.

7:26 fbru02: hey guys do you remember where's that clojure trivia ?

7:26 what was it called ?

7:26 notsonerdysunny: may be a macro is in order .. which would automatically create an interface/protocol with all the getters and setters for all the members .. have any of you written anything like that...

7:27 (ofcourse with all the members being mutable .. something like defmutabletype)

7:27 clgv: notsonerdysunny: do you really need all of them mutable?

7:28 notsonerdysunny: yes .. I am trying to implement the half-edge datastructure .. which has a lot of cyclic dependencies..

7:28 http://www.flipcode.com/archives/The_Half-Edge_Data_Structure.shtml

7:29 clgv: cyclic dependencies can also be implemented with immutable member if you introduce an indirection

7:31 powr-toc: I'm getting an error trying to build cljque ... It's complaining with: Cannot find parent: com.stuartsierra:cljque-parent for project: com.stuartsierra:cljque-base:clojure:${cljque.version} for project com.stuartsierra:cljque-base:clojure:${cljque.version}

7:31 any ideas?

7:35 notsonerdysunny: clgv: hmmm...

9:41 ZabaQ: I'm trying to get swank and compojure to work in harmony

9:42 all the examples (that don't use jetty) tell you to use (run-server .. ) .. but I can't find what namespace it lives in..

9:44 where is it supposed to be?

9:46 stuartsierra: You have to have some sort of web server.

9:47 ZabaQ: I'm using the lein-ring plugin

9:51 guess I'd be better off with jetty and the ring-jetty-adapter?

9:54 stuartsierra: I don't know what lein-ring or compojure do.

9:54 But you need a web server somewhere. Compojure doesn't have one built-in that I know of.

9:56 ZabaQ: something must be serving pages if I can see them :-)

9:56 obviously not compojure, though ..

9:57 chouser: I think ring depends on jetty, and compojure on ring

9:59 clgv: stuartsierra: hello. a question that's bugging me on a conceptual level. I have a complex meta-algorithm that needs a lot of functions as parameters to be able to solve a given problem instance. simply passing them as single parameters to the "main" function would really look ugly. how would you organize this?

10:05 Chousuke: clgv: is it common for the problem instances to have some parameters be the same?

10:06 stuartsierra: clgv: Could you define a data structure, such as a map, that describes one instance of the problem, including those functions?

10:08 clgv: Chousuke: to be more specific, being a meta-algorithm it can handle a certain classes of problems. one problem class has the same set of functions for all instances that shall be computed. but there some strategic function parameters that I want to be able to exchange even for the same problem instance to be able to compare those strategies

10:08 cemerick: ZabaQ: Ring will work as a servlet with any app server. Jetty is by far the most common one use in development contexts.

10:09 s/use/used

10:09 sexpbot: <cemerick> ZabaQ: Ring will work as a servlet with any app server. Jetty is by far the most common one used in development contexts.

10:09 clgv: stuartsierra: currently I have a deftype object holding those functions and exposing them via a protocol. but it didn't really feel like I was using clojure correctly here.

10:09 Chousuke: clgv: sounds like a map of the functions would work fine.

10:10 clgv: you could then use merge to combine a "base" map with another that specialises the problem instance.

10:11 using a record will work as well I guess but it sounds like overkill

10:11 clgv: Chousuke: hmm interesting thought. I played with the idea to write a DSL for configuring the functions in a file externally.

10:14 so in general I can summarize that there is no other concept than the single configuration object (map, record..) that I might be missing?

10:15 stuartsierra: not that I know of

10:17 clgv: ok. thanks. :)

10:20 ZabaQ: got it!

10:20 I was looking for run-jetty in ring.adapter.jetty

10:29 clgv: can I set up leiningen for a project that contains clojure and java implementation where I have the directories src/clj and src/jvm? if so, how do I tell leiningen to use these two?

10:39 rhickey: about to pollute the core ns with a fn that can tell you whether a delay/promise/future has a value without blocking or forcing - candidates?

10:40 also coming - (deref future-or-promise timeout-ms timeout-val)

10:41 fliebel: rhickey: Sound cool, though the core ns is already quite big. When you said 'candidates?', where you looking for objections, comments, a function name, or all of the above?

10:41 rhickey: fn name

10:42 (I'm sure objections will come unsolicited :)

10:43 fliebel: rhickey: Is it a predicate, or also a non-blocking getter?

10:43 rhickey: just a predicate

10:43 deref with timeout is non-blocking getter

10:43 fliebel: ah, yes.

10:44 stuarthalloway: value-available?

10:44 rhickey: stuarthalloway: ugly enough that no one has used it :)

10:44 TimMc: the-future-is-now?

10:45 rhickey: has-value

10:45 stuarthalloway: value-arrivaed

10:45 ?

10:45 rhickey: ?

10:45 stuarthalloway: ready?

10:45 fliebel: done?

10:45 concrete?

10:45 stuarthalloway: immediate?

10:46 * clgv votes for "done?" or "ready?" in that order

10:46 TimMc: Ooh, concrete? sounds good, and isn't likely to conflict.

10:46 rhickey: a future completes, a promise gets delivered, and a delay gets realized, if that helps frame the things we are trying to unify

10:46 stuarthalloway: fulfilled?

10:47 rhickey: the interface that unifies them is IPendingDeref

10:47 fliebel: pending? then?

10:47 chouser: isnt-not-unempty?

10:47 rhickey: chouser: -yet?

10:47 chouser: :-)

10:47 fliebel: valuable? :P

10:47 stuarthalloway: imminent?

10:48 clgv: lol @ "valuable?"

10:48 TimMc: rhickey: Do you anticipate the done? or not-done? sense to dominate in usage?

10:48 stuarthalloway: I think the dictionary definition of imminent is actually close...

10:49 rhickey: delay makes it tricky, since always available, but the predicate won't realize if not already

10:49 TimMc: fliebel's "pending?" is opposite in meaning to the others so far, for instance.

10:49 chouser: I like "ready?", esp. for a nice fundamental interface like IPendingDeref

10:49 stuarthalloway: TimMc: the done? sense, I think, in guard clauses

10:50 chouser: instant-deref?

10:50 rhickey: delays seem always ready, and all of them seem always imminent

10:50 thickey: finished?

10:50 stuarthalloway: completed?

10:51 rhickey: realized?

10:51 stuarthalloway: consummated?

10:51 rhickey: stuarthalloway and his consenting adults metaphor :)

10:52 fliebel: folfulled?

10:52 wow, good spelling...

10:52 stuarthalloway: would calling this on an atom always return true?

10:53 if it is even legal to ask of an atom, implies a different set of names

10:53 rhickey: stuarthalloway: not taking it to any of the refs that don't need it, for now

10:53 pjstadig: blocked?

10:54 rhickey: pjstadig: looking for the opposite polarity, also remember delays

10:54 stuarthalloway: rhickey: ok, but that might create a breaking name change later

10:54 pjstadig: unencumbered?

10:55 TimMc: I don't like names with negation in them.

10:55 rhickey: delays are never encumbered

10:55 TimMc: Makes it hard to read when wrapped in a (not ...)

10:55 rhickey: stuarthalloway: we can look at the winner here in that light

10:56 so, realized? is most correct so far. Another way to look at these is that the values are all calculated, so, executed? etc make sense too

10:56 stuarthalloway: immediate?

10:56 doh, said that already

10:56 dakrone: done?

10:56 pjstadig: did someone already say 'available?'?

10:57 clgv: why "executed?" if the are calculated how about "calculated?" ;)

10:57 rhickey: delays are always available

10:57 fliebel: obligated?

10:57 fogus`: pregnant?

10:57 stuarthalloway: nigh?

10:57 * fogus` stinks at naming

10:58 mids: cooked?

10:58 stuartsierra: FYI, org.clojure:data.json:0.1.0 is on its way to Central

10:58 clgv: fogus`: "pregnant?" would be the wrong time. born? would match ;)

10:58 stuarthalloway: achieved?

10:59 fogus`: infused?

10:59 chouser: I would expect 'realized?' to work on LazySeqs as well

10:59 pjstadig: fogus`: sounds delicious

11:00 rhickey: chouser: that's interesting

11:00 fliebel: yea, chouser has a point, if we make the name to broad, it'll be expected to do more than it does.

11:00 pjstadig: attained?

11:00 stuarthalloway: extant? (courtesy jgehtland)

11:00 pjstadig: actualized?

11:00 chouser: fliebel: but I would find a predicate like that to be useful for LazySeqs. I've even written (hacked together) such a beast.

11:01 pjstadig: concluded?

11:01 fliebel: stuarthalloway: You expect people to find that in the function heap?

11:01 rhickey: extant is more like - still around

11:01 pjstadig: substantiated?

11:01 fogus`: possessed? (I'm going to stop now)

11:01 stuarthalloway: too bad, extant is such a cool word ... could you create a reference type that erodes over time so we can use it?

11:01 pjstadig: accrued?

11:02 rhickey: hrm, LazySeq could satisfy this interface...

11:02 chouser: finallized? static? immutable?

11:02 Chousuke: stuarthalloway: entity extinction, huh? :P

11:02 fliebel: value?

11:02 pjstadig: stuarthalloway: technomancy has this idea of entropic memory that decays over time

11:02 err enthropic?

11:03 * rhickey thinks we're all looking at the same thesaurus

11:03 stuarthalloway: accomplished?

11:03 * fogus` OSX Dictionary

11:03 thickey: obtained?

11:03 pjstadig: thesaurus.com

11:04 rhickey: delay is the hardest to fit

11:04 stuarthalloway: I am using a different thesaurus for sure: http://www.thanatosrealms.com/war2/sounds/orcs/basic-orc-voices/work-complete.wav

11:04 fliebel: rhickey: What is the method on the interface called to do this?

11:04 stuartsierra: We talked about "has-value?" a long time ago.

11:05 fliebel: stuartsierra: Then I like concrete? better

11:05 pjstadig: rhickey: you're convinced that they can all be unified though?

11:05 rhickey: stuartsierra: right, so that idea confined to delay/promise/future

11:06 chouser: If lazy-seq implements it, 'realized?' is my favorite.

11:06 pjstadig: delay/promise/future done?/delivered?/realized?

11:06 fliebel: waiting? (ok, wrong side)

11:06 fogus`: (inc chouser)

11:07 fliebel: (inc chouser)

11:07 rhickey: chouser: me too, looking at it right now

11:07 clgv: realized? for lazy-seqs sounds good :)

11:07 pjstadig: lazy-seq would be IPendingDeref?

11:07 chouser: IPendingDeref sounds like the wrong name then, though, since deref isn't used

11:07 IPendingValue

11:07 rhickey: IPending

11:08 pjstadig: sure

11:08 IPending

11:08 jkkramer: ripe?

11:08 chouser: jkkramer: nice

11:08 pjstadig: do those concepts weigh each other? pending vs. realized?

11:08 i suppose

11:09 hard problems in computer science!!!!!!1111

11:10 stuarthalloway: I like IPending, too bad there is not antonym for "pend"

11:10 unpent?

11:10 fliebel: depent?

11:10 rhickey: stuarthalloway: yeah

11:12 fogus`: occupied?

11:12 Chousuke: collapsed? (as in a wave function) :P

11:12 rhickey: realized? wins, with support for delay/promise/future/lazy-seqs

11:12 thanks all

11:12 fliebel: yay!

11:12 stuarthalloway: thanks for adding this!

11:12 clgv: :)

11:12 stuartsierra: gotta go. Back this afternoon.

11:13 clgv: then I can throw away the current "realized?"-hack for lazy-seqs in my debugging code :)

11:14 rhickey: doc string?

11:15 fliebel: So, the first who presents a demonic use of realized? for lazy seqs gets a botsnack. :)

11:16 "are we there yet?"

11:17 clgv: fliebel: define "demonic"

11:17 fliebel: rhickey: How is realized? defined for lazy seqs? Is it only realized when the whole thing is done, or can a part of it be realized?

11:18 rhickey: seqs aren't things, they are chains of things. so, first link only

11:19 clgv: otherwise realized? on an infinite seq wouldnt work^^

11:19 fliebel: rhickey: So I could do (take-while realized? seq)?

11:20 fbru02: fliebel: that sounds interesting

11:20 rhickey: fliebel: for what purpose?

11:21 TimMc: Would that only get the elements that had already been computed?

11:21 rhickey: fliebel: don't forget the predicate is called on the values, not the seqs

11:22 * rhickey still waiting for the demand for CL maplist equivalent

11:23 Chousuke: (defn super-lazy-seq [lseq] (lazy-seq (if (realized? lseq) (cons (first lseq) (super-lazy-seq (rest lseq))) (cons :too-lazy (super-lazy-seq lseq))))

11:25 rhickey: the most useful fact is - if the head of a lazy-seq hasn't been realized, the rest hasn't either, e.g. as a printing control etc

11:26 fliebel: Chousuke: Make it implement IDeref :) That would be fun a lazy seq you explicitly have to tear values out.

11:27 fogus`: rhickey: Would the same people demanding reductions also need maplist?

11:28 hmm, "need" is too strong

11:28 fliebel: what is maplist?

11:29 rhickey: fliebel: calls the function on each successive seq, not value of head

11:29 fogus`: in the same family

11:30 http://www.lispworks.com/documentation/HyperSpec/Body/f_mapc_.htm

11:31 fogus`: maplist is a bad name IMO

11:32 fliebel: Oh, so it's like the opposite of reductions, kind of.

11:37 tsdh: In a leiningen project.clj file, how can I specify that I depend on the foo lib in either version 0.1.0 or any newer version?

11:38 fliebel: tsdh: Maven version ranges

11:38 rhickey: realized? - "Returns true if a value has been produced for a promise, delay, future or lazy sequence."

11:38 tsdh: fliebel: Is [0.1.0,) the right syntax?

11:39 fogus`: What happens if you do (realized? 42) ?

11:40 Chousuke: an exception?

11:40 that's what I'd expect :P

11:47 fogus`: First cut: (defn maplist [f & colls] (apply map f (map #(take (count %) (iterate rest %)) colls)))

11:47 rhickey: https://github.com/clojure/clojure/commit/84710838d6996d9144d83c5b659bdeda4c656100

11:49 jkkramer: fogus`: (defn maplist [f & colls] (apply map f (map #(take-while seq (iterate rest %)) colls))) ; no need for count?

11:51 fogus`: jkkramer: That seems to work. :-)

11:51 chouser: I've wanted 'tails' more often than maplist

11:51 oh, wait.

11:51 * chouser reads the docs

11:53 fliebel: rhickey: "See also - realized?" I think it would be useful to have a metadata key for related functions, but that is another subject entirely.

12:31 * jcromartie waves at fiz_

12:31 pjstadig: rhickey: there's a typo in the docstring for deref "and will return timeout-val of the timeout..." ITYM "and will return timeout-val if the timeout..."

12:45 Tomsik: Hi, I've got an enumeration of buttons and I want to just remove them all. The problem is that if get enumeration-seq and just remove buttons one by one then it removes the every other button. How do I create a *strict* collection from an enumeration?

12:46 That is I want the list of buttons to be fully evaluated before being passed further, so it won't be altered by removal of buttons.

12:47 stuarthalloway: (into [] your-stuff)

12:48 but what does "remove" mean in an immutable data structure? :-)

12:49 Tomsik: I'm removing radiobuttons from a buttongroup

12:50 and if I just reduce over this seq from enumeration-seq then it skips every other button, as if the item it points to is removed and then it takes the next one

12:50 and btw, is there a better thing to do then reduce if I just want to kind-of fold a list just for side effects?

12:50 than* uhh

12:52 ohpauleez: Tomsik: I'd take a look at doseq

12:52 not exactly folding, but you'll get the idea

12:52 http://clojuredocs.org/clojure_core/clojure.core/doseq

12:53 Tomsik: hmm

13:00 With doseq I still have to use this into []

13:01 oh well, I guess it's manageable :p

13:07 devn: Tomsik: could you give an example of what the data looks like, and what you want it to look like?

13:08 that usually is a good way to eek out a few options

13:09 Tomsik: It was mostly about this:

13:09 (def odp (JButton. "Odpowiedz"))

13:09 (def odpsy (ButtonGroup.))

13:09 (.addActionListener odp (proxy [ActionListener] [] (actionPerformed [e]

13:09 (doseq [r (into [] (enumeration-seq (.getElements odpsy)))] (.remove panel r) (.revalidate panel) (.repaint panel) (.remove odpsy r)))))

13:09 devn: Tomsik: please gist it in the future if it spans multiple lines

13:10 Tomsik: well, it's just four lines

13:11 devn: *nod* just an etiquette thing on IRC

13:46 rhickey: pjstadig: typo fixed - thanks

13:46 pjstadig: rhickey: awesome!

14:12 TimMc: ,'<symbol>

14:12 clojurebot: <symbol>

14:13 TimMc: The clojure.org docs don't mention < and > as legal characters for symbols.

14:14 http://clojure.org/reader claims only alphanumerics, *+!-_? , and / and : in certain cases.

14:15 technomancy: TimMc: just because something works now doesn't mean it's officially supported.

14:15 TimMc: Eep.

14:15 * TimMc hurries off to change some var names.

14:17 jcromartie: it has to be officially supported

14:17 what about ->

14:18 TimMc: '=4

14:18 ,'=4

14:18 clojurebot: =4

14:21 nteon: ,'8==>

14:21 clojurebot: Invalid number: 8==>

14:22 TimMc: no, no ,no

14:22 nteon: whoops!

14:22 jcromartie: oh we're talking about the first character

14:22 nteon: ,'<==8

14:22 clojurebot: <==8

14:23 nteon: thats better

14:23 TimMc: Thou shalt not name thy variables after ASCII art penises.

14:23 jcromartie: stop doing awful things to clojurebot

14:23 TimMc: I'm just glad that the language allows it.

14:23 '(_y_)

14:23 nope

14:24 not a symbol...

14:25 TimMc: Parens can't be part of a symbol.

14:25 jkkramer: ,(symbol "foo bar!@#$%^&*()~`{}[]|\\/<>")

14:25 clojurebot: foo bar!@#$%^&*()~`{}[]|\/<>

14:25 jkkramer: won't be readable though

14:25 jcromartie: they won't be *read* as part of a symbol

14:25 right

14:25 TimMc: Ah, thanks for that distinction.

14:25 Chousuke: those symbols are illegal anyway

14:25 devn: ,(symbol foo->bar)

14:25 clojurebot: java.lang.Exception: Unable to resolve symbol: foo->bar in this context

14:25 Chousuke: they work, but that's not guaranteed

14:25 devn: ,(symbol "foo->bar")

14:25 clojurebot: foo->bar

14:26 TimMc: ,'foo->bar

14:26 clojurebot: foo->bar

14:26 devn: i've seen <, >, an | in more than a couple of libraries

14:26 jcromartie: yeah, < and - etc. are built in anyway

14:26 of course the reader supports them

14:26 devn: IIRC it's ill-advised, but not illegal...yet

14:26 Chousuke: | might not be a good idea but yeah, > and < should be fine.

14:27 TimMc: phew

14:27 jcromartie: devn: how could it be made illegal?

14:27 TimMc: Oh yeah, and aren't there two different pipe chars?


14:27 devn: jcromartie: i don't remember all the details of the discussion but I remember rich saying something about it awhile back in IRC

14:27 you can search n01se.net's logs if you're interested

14:28 TimMc: Can't I use most of unicode for symbols?

14:28 jcromartie: I'd be OK with it if it didn't include things that were already part of the core namespace

14:28 TimMc: My impression is that it's just ASCII that's dangerous territory.

14:28 jcromartie: + - < > -> = etc.

14:28 they aren't special forms

14:29 Chousuke: anything that is in core is probably fair game. except /, which is kinda special :P

14:29 ,`/

14:29 clojurebot: clojure.core//

14:30 jcromartie: why is / special

14:30 Chousuke: It's the only symbol that can have two /s

14:30 ,foo/bar/fail

14:30 clojurebot: java.lang.Exception: No such namespace: foo/bar

14:30 Chousuke: ,'foo/bar/fail

14:30 clojurebot: foo/bar/fail

14:30 Chousuke: hmm

14:30 jcromartie: no, any symbol with a slash in the middle is considered "qualified"

14:31 Chousuke: oh well, you can't have a namespace called foo/bar anyway

14:31 TimMc: ,*ns*

14:31 clojurebot: #<Namespace sandbox>

14:31 jcromartie: interesting... if I (def / 1) in user, then I get user//

14:32 mec: Could anyone explain how or if the following is lazy? I understand that the first call would be lazy but after that shouldn't it just keep going? https://github.com/naleksander/instrumentos/blob/master/src/instrumentos/yield.clj

14:32 jcromartie: but I can't access it through the qualified name

14:32 so, yeah, don't use /

14:32 mec: you mean funnel

14:33 take-while is lazy

14:33 mec: well using it, something like (def fibs (yieldish (loop [a 0 b 1] (yield a) (recur b (+ a b)))))

14:34 it looks like yield just becomes (.put q a) so shouldnt the loop just keep going?

14:35 jcromartie: yeah loop is not lazy

14:37 what's with all the funky spacing of this code

14:37 it is hard to read

14:38 and the misleading indentation

14:39 mec: https://gist.github.com/876598

14:41 jcromartie: this is pretty interesting by the way

14:41 yours?

14:41 mec: no, im just trying to understand it

14:45 jcromartie: what's bound-fn

14:45 mec: `(future-call (bound-fn [] ~@body))

14:45 err

14:46 its a builtin, defines a function that the same previous bindings

14:46 raek: jcromartie: like fn, but it inherits the values of the thread-locally rebound vars from the creating thread

14:47 jcromartie: oh derp, I didn't read the output when I evaluated bound-fn in the REPL and assumed it said it was not found

14:48 but it was "Can't take value of a macro"

14:50 TimMc: Well, if I can't use < or > at some future date I'll just switch to guillemets: ##'«»

14:50 sexpbot: ⟹ «»

14:53 mec: ah hah! SynchronousQueue is blocking

14:55 it all makes sense now, except why it would crap out if (count (take 10000 fibs))

15:02 jcromartie: ,'™

15:02 clojurebot:

15:02 jcromartie: sweet

15:04 (defmacro ƒ [& fntail] `(fn ~@fntail))

15:04 the ƒ is for ƒancy

15:04 TimMc: haha

15:04 mec: lol

15:04 stuartsierra: jcromartie: Some people have their Emacs set up to replace "fn" with ƒ .

15:04 Drives me crazy.

15:04 TimMc: (defn foo™ "Do stuff to bar. Copyright (c) 2011 jcromartie." [bar] (inc bar))

15:04 jcromartie: ouch

15:05 mec: that would be neat if it were easy to type

15:05 technomancy: https://github.com/technomancy/emacs-starter-kit/blob/master/starter-kit-lisp.el#L59

15:06 jcromartie: hah wow

15:06 I had no idea people did that

15:06 it's anti social

15:06 technomancy: jcromartie: it's way more useful in javascript since you save 7 chars instead of 1

15:07 jcromartie: oh well if Emacs does the replacing

15:07 yeah

15:07 technomancy: lambda => λ in elisp is nice though

15:07 it's totally a render-time hack

15:07 TimMc: technomancy: Doesn't it mess with your ability to keep within 80 columns?

15:08 technomancy: TimMc: probably would if I still wrote JS these days

15:08 jcromartie: (defn ± [x y] (+ x (- (rand y) (/ y 2))))

15:09 TimMc: I probably shouldn't use $ in symbols though, yeah?

15:10 It seems that processor designers like to use I$ for Instruction Cache, you see.

15:14 devn: When you're writing clojure code do you take a strict approach to writing the docstring before you start on the body?

15:15 TimMc: devn: I feel uneasy if I don't have a docstring by the time I start writing the body, but I don't take a strict approach.

15:15 Sometimes I don't know what the function will do until I write it.

15:16 devn: TimMc: Yeah I do that too, but in general I find writing out a nice complete docstring before I start is a good way to keep me focused.

15:17 When I have to go back and write a docstring I sometimes think: Hm, the name no longer matches the functionality, the args have changed, etc.

15:18 mec: start with a comment and after you're done make it a docstring?

15:19 * dnolen writes comments, doc strings as the very last step.

15:21 TimMc: I can see my Fundies prof shaking his head and looking dissapointed when I don't write a docstring first. :-P

15:23 klang: any Danish mac and users around to give quick advice on how to make emacs give me curly/square brackets?

15:25 mec: in emacs is there a way to print the exception to the repl instead of starting a stack trace

15:26 raek: mec: what do you mean by "print the exception to the repl"?

15:27 mec: ##blah

15:28 raek: ##(blah)

15:28 sexpbot: java.lang.Exception: Unable to resolve symbol: blah in this context

15:28 klang: mec .. as in the exception is just printed as a warning and then back to repl mode right away

15:28 mec: like that, instead of opening a stack trace in another buffer

15:28 ya

15:29 raek: I don't know. I usually want to look at the stacktrace. (you can press 0 to hide that window)

15:30 klang: I usually only need the first line to figure out what I did wrong .. I am not doing complicated stuff ..

15:36 For completeness sake: http://stackoverflow.com/questions/3376863/unable-to-type-braces-and-square-braces-in-emacs (I am now able to use my mac for clojure, yay)

15:39 joshua__: So no Clojure using organizations were accepted into GSoC ;(?

15:40 mec: which datatype lets you define only some fields from an interface?

15:42 stuartsierra: mec: don't follow there, interfaces don't have fields.

15:43 mec: err methods sorry

15:43 stuartsierra: As far as I know, deftype, proxy, and reify all allow you to define a subset of methods of the parent interface.

15:44 If a method without a definition is invoked, it will throw AbstractMethodError.

15:44 mec: Oh, i must have just read it wrong, thanks

16:54 hiredman: does nrepl have a jira page?

16:54 stuartsierra: not yet

16:55 hiredman: where is the best place to raise an issue?

16:55 stuartsierra: email

16:55 hiredman: to chas?

16:55 stuartsierra: yeah, or the dev list.

16:55 hiredman: ok

17:30 Raynes: brehaut: I'm playing with necessary-evil. Also 'officially' deprecated clj-xmlrpc in favor of it.

17:30 brehaut: Raynes: awesome :)

17:31 Raynes: did you know that both projects are on the Wikipedia page for xml-rpc?

17:31 Raynes: Someone else added mine.

17:31 brehaut: and mine

17:32 Raynes: We've got stalkers.

17:32 brehaut: apparently. strange given that theres probably only 4 people in the world using either library tops

17:33 Raynes: ive got a breaking change to make for the lib shortly, so its going to get a 2.0.0 release (yay semver)

17:33 I need to make the struct type have string keys rather than keyword keys

17:34 Raynes: I'm writing a wordpress client with it. I've mostly given up my dreams of a blogging library that implements the various APIs. I don't have it in me. ;)

17:34 brehaut: Raynes: haha yeah its a pretty apocalyptic landscape of APIs

17:40 Raynes: brehaut: You should put the marginalia docs on the github pages for necessary-evil.

17:40 brehaut: Raynes: you are quite right. i'll do that ASAP

17:42 jcromartie: why does #() return an/the empty list

17:42 ,(#())

17:42 clojurebot: ()

17:43 Chousuke: probably because it expands to (fn [] ())

17:43 jcromartie: ah

17:43 and you don't have to escape ()

17:44 I mean quote

17:50 brehaut: Raynes: uberdocs pushed

17:51 Raynes: although i realise not as a gh-pages. need to work out how to do that

17:52 TimMc: ,#[]

17:52 clojurebot: No dispatch macro for: [

17:56 brehaut: Raynes: http://brehaut.github.com/necessary-evil/

17:56 Raynes: Yay!

17:56 brehaut: i still need to work out how to automate that :P

17:56 (i suck at git)

17:59 TimMc: brehaut: You also need to escape your brokets.

17:59 brehaut: my what now?

18:07 semperos: brehaut: Github gives you instructions if you go to your non-existent Github pages URL: http://brehaut.github.com/

18:09 brehaut: semperos: huh thanks

18:10 TimMc: brehaut: things like <method-name> need to be &lt;method-name&gt;

18:11 brokets = angle brackets, sorry

18:11 brehaut: TimMc: in the marginalia docs?

18:11 TimMc: Or maybe fogus needs to. :-)

18:12 semperos: they're fixed

18:12 in a very recent commit

18:12 brehaut: hah maybe yes :P i believe one of the major projects in marginalia is a full blown clojure parser

18:12 semperos: bc yeah, it wasn't escaping the brackets and some of my marginalia docs looked interesting :)

18:12 brehaut: im running 0.5.0

18:13 semperos: it's committed to master

18:18 tsdh: Where's the difference between adding metadata with ^ or with #^?

18:19 TimMc: tsdh: #^ is deprecated

18:19 brehaut: tsdh: <= 1.1 or >= 1.2

18:19 tsdh: Thanks.

18:37 semperos: probably unimportant, but who do I need to contact to have my name corrected on http://clojure.org/contributing ? just don't want to have any issue contributing, if that list acts as a reference

18:45 rata_: semperos: I don't really know, but I imagine rhickey

18:51 semperos: can't go wrong there, but was hoping to bug someone a little less busy :)

18:51 not a big deal

18:53 TimMc: $findfn '[a b c] '[[a b] [b c] [c d] [d a]]

18:53 sexpbot: []

18:53 TimMc: Hmm, I guess it would be a seq anyway.

18:53 I wrote this function in-channel at some point but I can't remember what it was.

18:54 brehaut: (doc partition-all)

18:54 clojurebot: "([n coll] [n step coll]); Returns a lazy sequence of lists like partition, but may include partitions with fewer than n items at the end."

18:55 brehaut: nope not quite

18:56 TimMc: http://richhickey.github.com/clojure-contrib/combinatorics-api.html

18:57 TimMc: also, seems unlikely findfn would find your example because your input has less symbols than your output

18:59 rata_: &(let [v [1 2 3]] (concat (partition 2 1 v) [[(last v) (first v)]]))

18:59 sexpbot: ⟹ ((1 2) (2 3) [3 1])

18:59 rata_: TimMc: ^

19:01 brehaut: &(let [s [1 2 3]] (take (count s) (partition 2 1 (cycle s))))

19:01 sexpbot: ⟹ ((1 2) (2 3) (3 1))

19:03 TimMc: Ah, that might be the one.

19:03 brehaut: &(let [s [1 2 3]] (map second s (parition 2 1 (cycle s))))

19:03 sexpbot: java.lang.Exception: Unable to resolve symbol: parition in this context

19:04 brehaut: &(let [s [1 2 3]] (map second s (partition 2 1 (cycle s))))

19:04 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$second

19:04 brehaut: &(let [s [1 2 3]] (map #(%2) s (partition 2 1 (cycle s))))

19:04 sexpbot: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

19:04 brehaut: fail

19:05 &(let [s [1 2 3]] (map (comp second vector) s (partition 2 1 (cycle s))))

19:05 sexpbot: ⟹ ((1 2) (2 3) (3 1))

19:07 brehaut: TimMc: and the correct solution: (comp (partial apply map (comp second vector)) (juxt identity (comp (partial partition 2 1) cycle)))

19:08 TimMc: I *thought* you were point-golfing...

19:08 brehaut: TimMc: only as far as it took to get juxt in :P

20:53 dnolen: Google is also interested in logic programming it seems, http://code.google.com/p/or-tools/

21:03 TimMc: OK... I need to compute a number for each element of a sequence. If any numbers are negative, I want to return nil. Else, I want to return the smallest number.

21:04 Seems like a lazy seq is called for, at the very least.

21:05 reduce would be appropriate for finding a min.

21:05 joshua__: It is starting to look like I'm not going to be doing any Clojure programming for GSoC =(. Can't find any organizations that are interested.

21:06 brehaut: timMC: (reduce min (keep computation s))

21:06 TimMc: (doc keep)

21:06 clojurebot: "([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."

21:07 TimMc: Ah! The computation could return nil instead of negative results.

21:07 brehaut: :D

21:07 TimMc: But reduce would still reduce the whole sequence, even once it encountered a nil.

21:08 I don't suppose there's a short-circuiting reduce?

21:08 brehaut: nope

21:08 hmm

21:08 TimMc: (first (filter ... (reductions ... ))) ?

21:09 brehaut: huh i dont think i have seen reductions before

21:09 joshua__: If you need to compute a number for each element in a sequence why not use map?

21:09 TimMc: joshua__: I only need the later values if earlier values are non-neg.

21:10 Oh, but map is lazy...

21:10 brehaut: so is keep

21:10 joshua__: (doc reductions)

21:10 clojurebot: "([f coll] [f init coll]); Returns a lazy seq of the intermediate values of the reduction (as per reduce) of coll by f, starting with init."

21:12 TimMc: No, keep is the wrong thing -- I want to know if there's a nil.

21:13 brehaut: TimMc: perhaps (some nil? …) would be useful?

21:13 TimMc: (partition 2 1 ...) would let me look ahead.

21:15 I'm going to write this with (some nil? ...) and (reduce min ...) for now.

21:15 brehaut: i think that is pretty clear

21:16 TimMc: It has to walk the sequence twice, which is annoying.

21:16 I'm being quite silly, though -- in this case the seq is always of length 3. :-P

21:16 brehaut: hahaha

21:17 TimMc: operands?

21:18 TimMc: what?

21:18 clojurebot: what is exceptions

21:18 brehaut: your sequences of three ?

21:18 TimMc: Vertices of triangles.

21:18 brehaut: thats not as fun :P

21:18 TimMc: Err, not vertices...

21:19 The distances from each edge to a point. I'm testing whether a point is on the triangle.

21:20 brehaut: did you make progress with your mips parser?

21:20 TimMc: brehaut: I wrote it all in regexes.

21:21 brehaut: haha

21:21 fair enough, but yuck :P

21:21 TimMc: Works beautifully, and I don't have to muck about with building all the fiddly bits of a full parser.

21:22 I think it turned out rather well, actually.

21:22 brehaut: …for regexps :P

21:24 * brehaut dislikes regexps intensely

21:25 hiredman: I have concluded nrepls protocol is ridiculous

21:26 Raynes: I'll alert the men.

21:27 TimMc: brehaut: https://gist.github.com/877123 <-- Second file. It's not that bad.

21:28 brehaut: TimMc: i'll give you that

21:29 hiredman: each message from nrepl is prefix with the number of forms, rather than the number of bytes of the message

21:30 impossible to deal with unless you scan it a character at a time

21:30 ugh

22:13 livingston: underscore as a namespace for a symbol is special, isn't it?

22:18 nevermind... I slipped and couldn't figure out why this was giving me a nil namespace '_:R1 when what I meant was '_/R1 (old lisp habits strike again)

22:19 hiredman: underscores in namespaces is a bad idea

22:19 clojurebot: Roger.

22:19 hiredman: clojurebot: botsnack

22:19 clojurebot: thanks; that was delicious. (nom nom nom)

22:20 livingston: why is that?

22:22 hiredman: livingston: namespaces typically map to a file on disk, and when going from namepsace to disk hyphens are replaced with underscores, and the reverse when going from disk to namespaces

22:23 livingston: oh I'm just talking about symbols (and their namespaces) I'm using as data

22:24 brehaut: livingston: its uncommon to use symbols as data in clojure. idiomatically most code uses keywords for that purpose

22:26 livingston: brb - phone

22:41 mec: Is there a primitive version of mod?

23:01 livingston: brehaut: there are uses for both.

23:02 if you want to logically group a bunch of symbols together, that's exactly what namespace part of a symbol is for.

23:35 jlf: technomancy: does the error "Unable to resolve artifact" during lein deps indicate that a dependency has gone missing from the remote repos or that my project.clj is broken?

23:40 transcript at http://paste.lisp.org/display/120649

23:45 phenom_: anyone know why #1 performs about 5 times faster than #2 here: http://pastie.org/1688494 ?

23:47 brehaut: phenom_: pastie.org doesnt want to respond for me; can you put it somewhere else?

23:50 phenom_: brehaut: http://pastebin.com/temNwRkP

23:50 brehaut: much better

23:52 phenom_: you have warn on reflection on?

23:53 phenom_: yup, nothing in that block comes up

23:53 but i see from stacktraces it's reflecting

23:54 brehaut: i cant compile either without a defintion for MyBuffer

23:55 but if i were to guess (and it really is just a stab in the dark) i would say that .append is reflecting on buf

23:55 phenom_: but buf is type hinted :S

23:56 brehaut: not in the version i have

23:56 i dont know if the compiler infers back from class names

Logging service provided by n01se.net