#clojure logs

2011-03-18

00:48tufflax,(macroexpand '(with-open [r (java.io.FileReader. "asdf.txt")] (.read r)))
00:48clojurebot(let* [r (java.io.FileReader. "asdf.txt")] (try (clojure.core/with-open [] (.read r)) (finally (. r clojure.core/close))))
00:48tufflaxI find that "clojure.core/close" strange...
00:50tufflaxI mean, FileReader doesn't have a method name clojure.core/close. How does this work? :P
00:50amalloytufflax: ISTR that the interop forms call .name on the symbol representing the member they should access
00:50amalloy&((juxt str name) `close)
00:50sexpbot⟹ ["clojure.core/close" "close"]
00:51amalloythey 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
00:51tufflaxAha, ok.
00:51tufflaxThanks
01:01tomojbinary juxt is sorta (a -> b) -> (a -> c) -> a -> (b,c) right?
01:02tomojif so hoogle claims they don't have it. was wondering what they named it
01:22scottjif they had had it there'd be a pretty good chance rhickey would have copied the name
01:40brehauttomoj: (&&&), its in Control.Arrow
01:43amalloybrehaut: i think i might be getting sick. tomoj's description of juxt in haskell made sense to me
01:45brehauttomoj: hoogle might have been misleading because the type is Arrow a => a b c -> a b c' -> a b (c, c')
01:45brehautamalloy: haha dont worry, im sure type definition has resolved your symptoms
01:46brehauttomoj: it happens that there is an instance of Arrow a for ->
01:50brehauttomoj: it also has a related operator (***) that is (for functions) (a -> b) -> (a' -> b') -> (a, a') -> (b, b')
01:51tomojbrehaut: aha
01:53brehauthurrah arrows :P
01:54tomojare we missing that one?
01:54brehautwe are i believe
01:55brehaut(defn *** [& fs] (fn [& as] (map invoke fs as))) i guess?
01:55clojurebot,(let [testar (fn [x y] (cond (= (reduce + (filter odd? (range 0 x))) y) (str y " is an square perfect")) )] (testar 11 25))
01:56brehauti want to call it par, but that confuses everyone
02:04brehauthaha amazon is recommending me C++ stuff on the O'Reilly Clojure Programming preorder page. target audience failure
03:28amalloyCustomers who bought these two items together also frequently bought...Treating Yourself for Multiple Personalities
03:54dat_eye_socketall of yourselves?
04:15amalloyanyone have an opinion about these two implementations of cond? https://gist.github.com/875767
04:18amalloyin practice only the latter is viable in clojure.core because things like partition (and reverse!) aren't around yet
07:00notsonerdysunnyhttps://gist.github.com/875893
07:02notsonerdysunnyHello everybody, When I tried to understand deftype and picked up the pasted code from stack overflow .. and tried to compile it .. i get
07:02notsonerdysunny error: java.lang.ClassCastException: isomorphism.half-edge.Point cannot be cast to compile__stub.isomorphism.half-edge.Point
07:03notsonerdysunny(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?
07:04notsonerdysunnymy clojure version is {:major 1, :minor 2, :incremental 0, :qualifier ""}
07:04clgvnotsonerdysunny: do you have to use definterface?
07:05clgvif not, switch to defprotocol
07:05clgv(defprotocol IPoint
07:05clgv (getX [this])
07:05clgv (setX [this, v]))
07:08Raynesdefprotocol and deftype go together like mashed and potatoes.
07:08clgvRaynes: is that good or bad meaning?
07:08notsonerdysunnyclgv: it didn't help ...
07:08Raynesclgv: Mashed potatoes are very good.
07:09notsonerdysunnyIt gives the same error
07:09clgvnotsonerdysunny: figured out that your error is here: (set! (.x this) v) I overread it the first time
07:09clgvuse (set! x v) instead
07:10notsonerdysunnyah .. that fixed it .. thanks clgv
07:10clgvRaynes: good. clojure world image remains sound ;()
07:10clgv;)
07:11notsonerdysunnybut in the hind sight .. I don't find any reason why the earlier version should not work...
07:12clgvRaynes: how am I supposed to organize my code i clojure when I have a lot of functions as parameter for a meta-algorithm?
07:12clgvI need them at very different "levels" within the algorithm
07:13clgvalways passing them as parameters to the next level is quite hideous as there a lot of them
07:13clgvnotsonerdysunny: you can't access ".x" anymore when you declare it :volatile-mutable
07:13RaynesWould it be better to just factor out the algorithm into smaller functions so that there are fewer 'levels'?
07:14clgvI dont think so, since I am very close to the mathematical definition already ;)
07:15clgvit has a general structure of an iteration-loop and subiteration-loops within each iteration
07:16clgvand the parameter functions are used to adjust it to a specific problem instance
07:16RaynesSounds like your best bet is to just wear a blindfold while reading that code.
07:17clgvno, 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
07:18clgvit's convenient right now, but looks very much OOPish... that's why I ask
07:19RaynesI'm the king of writing OOPish code.
07:19RaynesWhich is surprising, since I don't really know any OOP languages.
07:19clgvI have some history with them ;)
07:20RaynesI don't have the excuse of having been using OOP languages for many years before Clojure. Alas, it's just bad manners.
07:22clgvI 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.
07:22notsonerdysunnycan I define the methods directly inside a deftype...? instead of defining a seperate interface/protocol and then defining it in the deftype...?
07:23clgvnotsonerdysunny: I don't think so. I got a compiler exception when I tried
07:23Raynesnotsonerdysunny: No.
07:26fbru02hey guys do you remember where's that clojure trivia ?
07:26fbru02what was it called ?
07:26notsonerdysunnymay 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...
07:27notsonerdysunny(ofcourse with all the members being mutable .. something like defmutabletype)
07:27clgvnotsonerdysunny: do you really need all of them mutable?
07:28notsonerdysunnyyes .. I am trying to implement the half-edge datastructure .. which has a lot of cyclic dependencies..
07:28notsonerdysunnyhttp://www.flipcode.com/archives/The_Half-Edge_Data_Structure.shtml
07:29clgvcyclic dependencies can also be implemented with immutable member if you introduce an indirection
07:31powr-tocI'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}
07:31powr-tocany ideas?
07:35notsonerdysunnyclgv: hmmm...
09:41ZabaQI'm trying to get swank and compojure to work in harmony
09:42ZabaQall the examples (that don't use jetty) tell you to use (run-server .. ) .. but I can't find what namespace it lives in..
09:44ZabaQwhere is it supposed to be?
09:46stuartsierraYou have to have some sort of web server.
09:47ZabaQI'm using the lein-ring plugin
09:51ZabaQguess I'd be better off with jetty and the ring-jetty-adapter?
09:54stuartsierraI don't know what lein-ring or compojure do.
09:54stuartsierraBut you need a web server somewhere. Compojure doesn't have one built-in that I know of.
09:56ZabaQsomething must be serving pages if I can see them :-)
09:56ZabaQobviously not compojure, though ..
09:57chouserI think ring depends on jetty, and compojure on ring
09:59clgvstuartsierra: 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:05Chousukeclgv: is it common for the problem instances to have some parameters be the same?
10:06stuartsierraclgv: Could you define a data structure, such as a map, that describes one instance of the problem, including those functions?
10:08clgvChousuke: 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:08cemerickZabaQ: Ring will work as a servlet with any app server. Jetty is by far the most common one use in development contexts.
10:09cemericks/use/used
10:09sexpbot<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:09clgvstuartsierra: 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:09Chousukeclgv: sounds like a map of the functions would work fine.
10:10Chousukeclgv: you could then use merge to combine a "base" map with another that specialises the problem instance.
10:11Chousukeusing a record will work as well I guess but it sounds like overkill
10:11clgvChousuke: hmm interesting thought. I played with the idea to write a DSL for configuring the functions in a file externally.
10:14clgvso in general I can summarize that there is no other concept than the single configuration object (map, record..) that I might be missing?
10:15stuartsierranot that I know of
10:17clgvok. thanks. :)
10:20ZabaQgot it!
10:20ZabaQI was looking for run-jetty in ring.adapter.jetty
10:29clgvcan 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@rhickeyabout 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@rhickeyalso coming - (deref future-or-promise timeout-ms timeout-val)
10:41fliebelrhickey: 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@rhickeyfn name
10:42@rhickey(I'm sure objections will come unsolicited :)
10:43fliebelrhickey: Is it a predicate, or also a non-blocking getter?
10:43@rhickeyjust a predicate
10:43@rhickeyderef with timeout is non-blocking getter
10:43fliebelah, yes.
10:44stuarthallowayvalue-available?
10:44@rhickeystuarthalloway: ugly enough that no one has used it :)
10:44TimMcthe-future-is-now?
10:45@rhickeyhas-value
10:45stuarthallowayvalue-arrivaed
10:45stuarthalloway?
10:45@rhickey?
10:45stuarthallowayready?
10:45fliebeldone?
10:45fliebelconcrete?
10:45stuarthallowayimmediate?
10:46TimMcOoh, concrete? sounds good, and isn't likely to conflict.
10:46@rhickeya future completes, a promise gets delivered, and a delay gets realized, if that helps frame the things we are trying to unify
10:46stuarthallowayfulfilled?
10:47@rhickeythe interface that unifies them is IPendingDeref
10:47fliebelpending? then?
10:47chouserisnt-not-unempty?
10:47@rhickeychouser: -yet?
10:47chouser:-)
10:47fliebelvaluable? :P
10:47stuarthallowayimminent?
10:48clgvlol @ "valuable?"
10:48TimMcrhickey: Do you anticipate the done? or not-done? sense to dominate in usage?
10:48stuarthallowayI think the dictionary definition of imminent is actually close...
10:49@rhickeydelay makes it tricky, since always available, but the predicate won't realize if not already
10:49TimMcfliebel's "pending?" is opposite in meaning to the others so far, for instance.
10:49chouserI like "ready?", esp. for a nice fundamental interface like IPendingDeref
10:49stuarthallowayTimMc: the done? sense, I think, in guard clauses
10:50chouserinstant-deref?
10:50@rhickeydelays seem always ready, and all of them seem always imminent
10:50thickeyfinished?
10:50stuarthallowaycompleted?
10:51@rhickeyrealized?
10:51stuarthallowayconsummated?
10:51@rhickeystuarthalloway and his consenting adults metaphor :)
10:52fliebelfolfulled?
10:52fliebelwow, good spelling...
10:52stuarthallowaywould calling this on an atom always return true?
10:53stuarthallowayif it is even legal to ask of an atom, implies a different set of names
10:53@rhickeystuarthalloway: not taking it to any of the refs that don't need it, for now
10:53pjstadigblocked?
10:54@rhickeypjstadig: looking for the opposite polarity, also remember delays
10:54stuarthallowayrhickey: ok, but that might create a breaking name change later
10:54pjstadigunencumbered?
10:55TimMcI don't like names with negation in them.
10:55@rhickeydelays are never encumbered
10:55TimMcMakes it hard to read when wrapped in a (not ...)
10:55@rhickeystuarthalloway: we can look at the winner here in that light
10:56@rhickeyso, 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:56stuarthallowayimmediate?
10:56stuarthallowaydoh, said that already
10:56dakronedone?
10:56pjstadigdid someone already say 'available?'?
10:57clgvwhy "executed?" if the are calculated how about "calculated?" ;)
10:57@rhickeydelays are always available
10:57fliebelobligated?
10:57fogus`pregnant?
10:57stuarthallowaynigh?
10:58midscooked?
10:58stuartsierraFYI, org.clojure:data.json:0.1.0 is on its way to Central
10:58clgvfogus`: "pregnant?" would be the wrong time. born? would match ;)
10:58stuarthallowayachieved?
10:59fogus`infused?
10:59chouserI would expect 'realized?' to work on LazySeqs as well
10:59pjstadigfogus`: sounds delicious
11:00@rhickeychouser: that's interesting
11:00fliebelyea, chouser has a point, if we make the name to broad, it'll be expected to do more than it does.
11:00pjstadigattained?
11:00stuarthallowayextant? (courtesy jgehtland)
11:00pjstadigactualized?
11:00chouserfliebel: but I would find a predicate like that to be useful for LazySeqs. I've even written (hacked together) such a beast.
11:01pjstadigconcluded?
11:01fliebelstuarthalloway: You expect people to find that in the function heap?
11:01@rhickeyextant is more like - still around
11:01pjstadigsubstantiated?
11:01fogus`possessed? (I'm going to stop now)
11:01stuarthallowaytoo bad, extant is such a cool word ... could you create a reference type that erodes over time so we can use it?
11:01pjstadigaccrued?
11:02@rhickeyhrm, LazySeq could satisfy this interface...
11:02chouserfinallized? static? immutable?
11:02Chousukestuarthalloway: entity extinction, huh? :P
11:02fliebelvalue?
11:02pjstadigstuarthalloway: technomancy has this idea of entropic memory that decays over time
11:02pjstadigerr enthropic?
11:03stuarthallowayaccomplished?
11:03thickeyobtained?
11:03pjstadigthesaurus.com
11:04@rhickeydelay is the hardest to fit
11:04stuarthallowayI am using a different thesaurus for sure: http://www.thanatosrealms.com/war2/sounds/orcs/basic-orc-voices/work-complete.wav
11:04fliebelrhickey: What is the method on the interface called to do this?
11:04stuartsierraWe talked about "has-value?" a long time ago.
11:05fliebelstuartsierra: Then I like concrete? better
11:05pjstadigrhickey: you're convinced that they can all be unified though?
11:05@rhickeystuartsierra: right, so that idea confined to delay/promise/future
11:06chouserIf lazy-seq implements it, 'realized?' is my favorite.
11:06pjstadigdelay/promise/future done?/delivered?/realized?
11:06fliebelwaiting? (ok, wrong side)
11:06fogus`(inc chouser)
11:07fliebel(inc chouser)
11:07@rhickeychouser: me too, looking at it right now
11:07clgvrealized? for lazy-seqs sounds good :)
11:07pjstadiglazy-seq would be IPendingDeref?
11:07chouserIPendingDeref sounds like the wrong name then, though, since deref isn't used
11:07chouserIPendingValue
11:07@rhickeyIPending
11:08pjstadigsure
11:08pjstadigIPending
11:08jkkramerripe?
11:08chouserjkkramer: nice
11:08pjstadigdo those concepts weigh each other? pending vs. realized?
11:08pjstadigi suppose
11:09pjstadighard problems in computer science!!!!!!1111
11:10stuarthallowayI like IPending, too bad there is not antonym for "pend"
11:10stuarthallowayunpent?
11:10fliebeldepent?
11:10@rhickeystuarthalloway: yeah
11:12fogus`occupied?
11:12Chousukecollapsed? (as in a wave function) :P
11:12@rhickeyrealized? wins, with support for delay/promise/future/lazy-seqs
11:12@rhickeythanks all
11:12fliebelyay!
11:12stuarthallowaythanks for adding this!
11:12clgv:)
11:12stuartsierragotta go. Back this afternoon.
11:13clgvthen I can throw away the current "realized?"-hack for lazy-seqs in my debugging code :)
11:14@rhickeydoc string?
11:15fliebelSo, the first who presents a demonic use of realized? for lazy seqs gets a botsnack. :)
11:16fliebel"are we there yet?"
11:17clgvfliebel: define "demonic"
11:17fliebelrhickey: 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@rhickeyseqs aren't things, they are chains of things. so, first link only
11:19clgvotherwise realized? on an infinite seq wouldnt work^^
11:19fliebelrhickey: So I could do (take-while realized? seq)?
11:20fbru02fliebel: that sounds interesting
11:20@rhickeyfliebel: for what purpose?
11:21TimMcWould that only get the elements that had already been computed?
11:21@rhickeyfliebel: don't forget the predicate is called on the values, not the seqs
11:23Chousuke(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@rhickeythe 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:26fliebelChousuke: Make it implement IDeref :) That would be fun a lazy seq you explicitly have to tear values out.
11:27fogus`rhickey: Would the same people demanding reductions also need maplist?
11:28fogus`hmm, "need" is too strong
11:28fliebelwhat is maplist?
11:29@rhickeyfliebel: calls the function on each successive seq, not value of head
11:29@rhickeyfogus`: in the same family
11:30@rhickeyhttp://www.lispworks.com/documentation/HyperSpec/Body/f_mapc_.htm
11:31fogus`maplist is a bad name IMO
11:32fliebelOh, so it's like the opposite of reductions, kind of.
11:37tsdhIn 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:38fliebeltsdh: Maven version ranges
11:38@rhickeyrealized? - "Returns true if a value has been produced for a promise, delay, future or lazy sequence."
11:38tsdhfliebel: Is [0.1.0,) the right syntax?
11:39fogus`What happens if you do (realized? 42) ?
11:40Chousukean exception?
11:40Chousukethat's what I'd expect :P
11:47fogus`First cut: (defn maplist [f & colls] (apply map f (map #(take (count %) (iterate rest %)) colls)))
11:47@rhickeyhttps://github.com/clojure/clojure/commit/84710838d6996d9144d83c5b659bdeda4c656100
11:49jkkramerfogus`: (defn maplist [f & colls] (apply map f (map #(take-while seq (iterate rest %)) colls))) ; no need for count?
11:51fogus`jkkramer: That seems to work. :-)
11:51chouserI've wanted 'tails' more often than maplist
11:51chouseroh, wait.
11:53fliebelrhickey: "See also - realized?" I think it would be useful to have a metadata key for related functions, but that is another subject entirely.
12:31pjstadigrhickey: 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:45TomsikHi, 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:46TomsikThat 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:47stuarthalloway(into [] your-stuff)
12:48stuarthallowaybut what does "remove" mean in an immutable data structure? :-)
12:49TomsikI'm removing radiobuttons from a buttongroup
12:50Tomsikand 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:50Tomsikand 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:50Tomsikthan* uhh
12:52ohpauleezTomsik: I'd take a look at doseq
12:52ohpauleeznot exactly folding, but you'll get the idea
12:52ohpauleezhttp://clojuredocs.org/clojure_core/clojure.core/doseq
12:53Tomsikhmm
13:00TomsikWith doseq I still have to use this into []
13:01Tomsikoh well, I guess it's manageable :p
13:07devnTomsik: could you give an example of what the data looks like, and what you want it to look like?
13:08devnthat usually is a good way to eek out a few options
13:09TomsikIt was mostly about this:
13:09Tomsik(def odp (JButton. "Odpowiedz"))
13:09Tomsik(def odpsy (ButtonGroup.))
13:09Tomsik(.addActionListener odp (proxy [ActionListener] [] (actionPerformed [e]
13:09Tomsik (doseq [r (into [] (enumeration-seq (.getElements odpsy)))] (.remove panel r) (.revalidate panel) (.repaint panel) (.remove odpsy r)))))
13:09devnTomsik: please gist it in the future if it spans multiple lines
13:10Tomsikwell, it's just four lines
13:11devn*nod* just an etiquette thing on IRC
13:46@rhickeypjstadig: typo fixed - thanks
13:46pjstadigrhickey: awesome!
14:12TimMc,'<symbol>
14:12clojurebot<symbol>
14:13TimMcThe clojure.org docs don't mention < and > as legal characters for symbols.
14:14TimMchttp://clojure.org/reader claims only alphanumerics, *+!-_? , and / and : in certain cases.
14:15technomancyTimMc: just because something works now doesn't mean it's officially supported.
14:15TimMcEep.
14:17jcromartieit has to be officially supported
14:17jcromartiewhat about ->
14:18TimMc'=4
14:18TimMc,'=4
14:18clojurebot=4
14:21nteon,'8==>
14:21clojurebotInvalid number: 8==>
14:22TimMcno, no ,no
14:22nteonwhoops!
14:22jcromartieoh we're talking about the first character
14:22nteon,'<==8
14:22clojurebot<==8
14:23nteonthats better
14:23TimMcThou shalt not name thy variables after ASCII art penises.
14:23jcromartiestop doing awful things to clojurebot
14:23jcromartieTimMc: I'm just glad that the language allows it.
14:23jcromartie'(_y_)
14:23jcromartienope
14:24jcromartienot a symbol...
14:25TimMcParens can't be part of a symbol.
14:25jkkramer,(symbol "foo bar!@#$%^&*()~`{}[]|\\/<>")
14:25clojurebotfoo bar!@#$%^&*()~`{}[]|\/<>
14:25jkkramerwon't be readable though
14:25jcromartiethey won't be *read* as part of a symbol
14:25jcromartieright
14:25TimMcAh, thanks for that distinction.
14:25Chousukethose symbols are illegal anyway
14:25devn,(symbol foo->bar)
14:25clojurebotjava.lang.Exception: Unable to resolve symbol: foo->bar in this context
14:25Chousukethey work, but that's not guaranteed
14:25devn,(symbol "foo->bar")
14:25clojurebotfoo->bar
14:26TimMc,'foo->bar
14:26clojurebotfoo->bar
14:26devni've seen <, >, an | in more than a couple of libraries
14:26jcromartieyeah, < and - etc. are built in anyway
14:26jcromartieof course the reader supports them
14:26devnIIRC it's ill-advised, but not illegal...yet
14:26Chousuke| might not be a good idea but yeah, > and < should be fine.
14:27TimMcphew
14:27jcromartiedevn: how could it be made illegal?
14:27TimMcOh yeah, and aren't there two different pipe chars?
14:27TimMc
14:27devnjcromartie: i don't remember all the details of the discussion but I remember rich saying something about it awhile back in IRC
14:27devnyou can search n01se.net's logs if you're interested
14:28TimMcCan't I use most of unicode for symbols?
14:28jcromartieI'd be OK with it if it didn't include things that were already part of the core namespace
14:28TimMcMy impression is that it's just ASCII that's dangerous territory.
14:28jcromartie+ - < > -> = etc.
14:28jcromartiethey aren't special forms
14:29Chousukeanything that is in core is probably fair game. except /, which is kinda special :P
14:29Chousuke,`/
14:29clojurebotclojure.core//
14:30jcromartiewhy is / special
14:30ChousukeIt's the only symbol that can have two /s
14:30Chousuke,foo/bar/fail
14:30clojurebotjava.lang.Exception: No such namespace: foo/bar
14:30Chousuke,'foo/bar/fail
14:30clojurebotfoo/bar/fail
14:30Chousukehmm
14:30jcromartieno, any symbol with a slash in the middle is considered "qualified"
14:31Chousukeoh well, you can't have a namespace called foo/bar anyway
14:31TimMc,*ns*
14:31clojurebot#<Namespace sandbox>
14:31jcromartieinteresting... if I (def / 1) in user, then I get user//
14:32mecCould 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:32jcromartiebut I can't access it through the qualified name
14:32jcromartieso, yeah, don't use /
14:32jcromartiemec: you mean funnel
14:33jcromartietake-while is lazy
14:33mecwell using it, something like (def fibs (yieldish (loop [a 0 b 1] (yield a) (recur b (+ a b)))))
14:34mecit looks like yield just becomes (.put q a) so shouldnt the loop just keep going?
14:35jcromartieyeah loop is not lazy
14:37jcromartiewhat's with all the funky spacing of this code
14:37jcromartieit is hard to read
14:38jcromartieand the misleading indentation
14:39mechttps://gist.github.com/876598
14:41jcromartiethis is pretty interesting by the way
14:41jcromartieyours?
14:41mecno, im just trying to understand it
14:45jcromartiewhat's bound-fn
14:45mec`(future-call (bound-fn [] ~@body))
14:45mecerr
14:46mecits a builtin, defines a function that the same previous bindings
14:46raekjcromartie: like fn, but it inherits the values of the thread-locally rebound vars from the creating thread
14:47jcromartieoh derp, I didn't read the output when I evaluated bound-fn in the REPL and assumed it said it was not found
14:48jcromartiebut it was "Can't take value of a macro"
14:50TimMcWell, if I can't use < or > at some future date I'll just switch to guillemets: ##'«»
14:50sexpbot⟹ «»
14:53mecah hah! SynchronousQueue is blocking
14:55mecit all makes sense now, except why it would crap out if (count (take 10000 fibs))
15:02jcromartie,'™
15:02clojurebot
15:02jcromartiesweet
15:04jcromartie(defmacro ƒ [& fntail] `(fn ~@fntail))
15:04jcromartiethe ƒ is for ƒancy
15:04TimMchaha
15:04meclol
15:04stuartsierrajcromartie: Some people have their Emacs set up to replace "fn" with ƒ .
15:04stuartsierraDrives me crazy.
15:04TimMc(defn foo™ "Do stuff to bar. Copyright (c) 2011 jcromartie." [bar] (inc bar))
15:04jcromartieouch
15:05mecthat would be neat if it were easy to type
15:05technomancyhttps://github.com/technomancy/emacs-starter-kit/blob/master/starter-kit-lisp.el#L59
15:06jcromartiehah wow
15:06jcromartieI had no idea people did that
15:06jcromartieit's anti social
15:06technomancyjcromartie: it's way more useful in javascript since you save 7 chars instead of 1
15:07jcromartieoh well if Emacs does the replacing
15:07jcromartieyeah
15:07technomancylambda => λ in elisp is nice though
15:07technomancyit's totally a render-time hack
15:07TimMctechnomancy: Doesn't it mess with your ability to keep within 80 columns?
15:08technomancyTimMc: probably would if I still wrote JS these days
15:08jcromartie(defn ± [x y] (+ x (- (rand y) (/ y 2))))
15:09TimMcI probably shouldn't use $ in symbols though, yeah?
15:10TimMcIt seems that processor designers like to use I$ for Instruction Cache, you see.
15:14devnWhen you're writing clojure code do you take a strict approach to writing the docstring before you start on the body?
15:15TimMcdevn: 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:15TimMcSometimes I don't know what the function will do until I write it.
15:16devnTimMc: 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:17devnWhen 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:18mecstart with a comment and after you're done make it a docstring?
15:21TimMcI can see my Fundies prof shaking his head and looking dissapointed when I don't write a docstring first. :-P
15:23klangany Danish mac and users around to give quick advice on how to make emacs give me curly/square brackets?
15:25mecin emacs is there a way to print the exception to the repl instead of starting a stack trace
15:26raekmec: what do you mean by "print the exception to the repl"?
15:27mec##blah
15:28raek##(blah)
15:28sexpbotjava.lang.Exception: Unable to resolve symbol: blah in this context
15:28klangmec .. as in the exception is just printed as a warning and then back to repl mode right away
15:28meclike that, instead of opening a stack trace in another buffer
15:28mecya
15:29raekI don't know. I usually want to look at the stacktrace. (you can press 0 to hide that window)
15:30klangI usually only need the first line to figure out what I did wrong .. I am not doing complicated stuff ..
15:36klangFor 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:39joshua__So no Clojure using organizations were accepted into GSoC ;(?
15:40mecwhich datatype lets you define only some fields from an interface?
15:42stuartsierramec: don't follow there, interfaces don't have fields.
15:43mecerr methods sorry
15:43stuartsierraAs far as I know, deftype, proxy, and reify all allow you to define a subset of methods of the parent interface.
15:44stuartsierraIf a method without a definition is invoked, it will throw AbstractMethodError.
15:44mecOh, i must have just read it wrong, thanks
16:54hiredmandoes nrepl have a jira page?
16:54stuartsierranot yet
16:55hiredmanwhere is the best place to raise an issue?
16:55stuartsierraemail
16:55hiredmanto chas?
16:55stuartsierrayeah, or the dev list.
16:55hiredmanok
17:30Raynesbrehaut: I'm playing with necessary-evil. Also 'officially' deprecated clj-xmlrpc in favor of it.
17:30brehautRaynes: awesome :)
17:31brehautRaynes: did you know that both projects are on the Wikipedia page for xml-rpc?
17:31RaynesSomeone else added mine.
17:31brehautand mine
17:32RaynesWe've got stalkers.
17:32brehautapparently. strange given that theres probably only 4 people in the world using either library tops
17:33brehautRaynes: ive got a breaking change to make for the lib shortly, so its going to get a 2.0.0 release (yay semver)
17:33brehautI need to make the struct type have string keys rather than keyword keys
17:34RaynesI'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:34brehautRaynes: haha yeah its a pretty apocalyptic landscape of APIs
17:40Raynesbrehaut: You should put the marginalia docs on the github pages for necessary-evil.
17:40brehautRaynes: you are quite right. i'll do that ASAP
17:42jcromartiewhy does #() return an/the empty list
17:42jcromartie,(#())
17:42clojurebot()
17:43Chousukeprobably because it expands to (fn [] ())
17:43jcromartieah
17:43jcromartieand you don't have to escape ()
17:44jcromartieI mean quote
17:50brehautRaynes: uberdocs pushed
17:51brehautRaynes: although i realise not as a gh-pages. need to work out how to do that
17:52TimMc,#[]
17:52clojurebotNo dispatch macro for: [
17:56brehautRaynes: http://brehaut.github.com/necessary-evil/
17:56RaynesYay!
17:56brehauti still need to work out how to automate that :P
17:56brehaut(i suck at git)
17:59TimMcbrehaut: You also need to escape your brokets.
17:59brehautmy what now?
18:07semperosbrehaut: Github gives you instructions if you go to your non-existent Github pages URL: http://brehaut.github.com/
18:09brehautsemperos: huh thanks
18:10TimMcbrehaut: things like <method-name> need to be &lt;method-name&gt;
18:11TimMcbrokets = angle brackets, sorry
18:11brehautTimMc: in the marginalia docs?
18:11TimMcOr maybe fogus needs to. :-)
18:12semperosthey're fixed
18:12semperosin a very recent commit
18:12brehauthah maybe yes :P i believe one of the major projects in marginalia is a full blown clojure parser
18:12semperosbc yeah, it wasn't escaping the brackets and some of my marginalia docs looked interesting :)
18:12brehautim running 0.5.0
18:13semperosit's committed to master
18:18tsdhWhere's the difference between adding metadata with ^ or with #^?
18:19TimMctsdh: #^ is deprecated
18:19brehauttsdh: <= 1.1 or >= 1.2
18:19tsdhThanks.
18:37semperosprobably 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:45rata_semperos: I don't really know, but I imagine rhickey
18:51semperoscan't go wrong there, but was hoping to bug someone a little less busy :)
18:51semperosnot a big deal
18:53TimMc$findfn '[a b c] '[[a b] [b c] [c d] [d a]]
18:53sexpbot[]
18:53TimMcHmm, I guess it would be a seq anyway.
18:53TimMcI wrote this function in-channel at some point but I can't remember what it was.
18:54brehaut(doc partition-all)
18:54clojurebot"([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:55brehautnope not quite
18:56brehautTimMc: http://richhickey.github.com/clojure-contrib/combinatorics-api.html
18:57brehautTimMc: also, seems unlikely findfn would find your example because your input has less symbols than your output
18:59rata_&(let [v [1 2 3]] (concat (partition 2 1 v) [[(last v) (first v)]]))
18:59sexpbot⟹ ((1 2) (2 3) [3 1])
18:59rata_TimMc: ^
19:01brehaut&(let [s [1 2 3]] (take (count s) (partition 2 1 (cycle s))))
19:01sexpbot⟹ ((1 2) (2 3) (3 1))
19:03TimMcAh, that might be the one.
19:03brehaut&(let [s [1 2 3]] (map second s (parition 2 1 (cycle s))))
19:03sexpbotjava.lang.Exception: Unable to resolve symbol: parition in this context
19:04brehaut&(let [s [1 2 3]] (map second s (partition 2 1 (cycle s))))
19:04sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: core$second
19:04brehaut&(let [s [1 2 3]] (map #(%2) s (partition 2 1 (cycle s))))
19:04sexpbotjava.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn
19:04brehautfail
19:05brehaut&(let [s [1 2 3]] (map (comp second vector) s (partition 2 1 (cycle s))))
19:05sexpbot⟹ ((1 2) (2 3) (3 1))
19:07brehautTimMc: and the correct solution: (comp (partial apply map (comp second vector)) (juxt identity (comp (partial partition 2 1) cycle)))
19:08TimMcI *thought* you were point-golfing...
19:08brehautTimMc: only as far as it took to get juxt in :P
20:53dnolenGoogle is also interested in logic programming it seems, http://code.google.com/p/or-tools/
21:03TimMcOK... 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:04TimMcSeems like a lazy seq is called for, at the very least.
21:05TimMcreduce would be appropriate for finding a min.
21:05joshua__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:06brehauttimMC: (reduce min (keep computation s))
21:06TimMc(doc keep)
21:06clojurebot"([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:07TimMcAh! The computation could return nil instead of negative results.
21:07brehaut:D
21:07TimMcBut reduce would still reduce the whole sequence, even once it encountered a nil.
21:08TimMcI don't suppose there's a short-circuiting reduce?
21:08brehautnope
21:08brehauthmm
21:08TimMc(first (filter ... (reductions ... ))) ?
21:09brehauthuh i dont think i have seen reductions before
21:09joshua__If you need to compute a number for each element in a sequence why not use map?
21:09TimMcjoshua__: I only need the later values if earlier values are non-neg.
21:10TimMcOh, but map is lazy...
21:10brehautso is keep
21:10joshua__(doc reductions)
21:10clojurebot"([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:12TimMcNo, keep is the wrong thing -- I want to know if there's a nil.
21:13brehautTimMc: perhaps (some nil? …) would be useful?
21:13TimMc(partition 2 1 ...) would let me look ahead.
21:15TimMcI'm going to write this with (some nil? ...) and (reduce min ...) for now.
21:15brehaut i think that is pretty clear
21:16TimMcIt has to walk the sequence twice, which is annoying.
21:16TimMcI'm being quite silly, though -- in this case the seq is always of length 3. :-P
21:16brehauthahaha
21:17brehautTimMc: operands?
21:18TimMcwhat?
21:18clojurebotwhat is exceptions
21:18brehautyour sequences of three ?
21:18TimMcVertices of triangles.
21:18brehautthats not as fun :P
21:18TimMcErr, not vertices...
21:19TimMcThe distances from each edge to a point. I'm testing whether a point is on the triangle.
21:20brehautdid you make progress with your mips parser?
21:20TimMcbrehaut: I wrote it all in regexes.
21:21brehauthaha
21:21brehautfair enough, but yuck :P
21:21TimMcWorks beautifully, and I don't have to muck about with building all the fiddly bits of a full parser.
21:22TimMcI think it turned out rather well, actually.
21:22brehaut…for regexps :P
21:25hiredmanI have concluded nrepls protocol is ridiculous
21:26RaynesI'll alert the men.
21:27TimMcbrehaut: https://gist.github.com/877123 <-- Second file. It's not that bad.
21:28brehautTimMc: i'll give you that
21:29hiredmaneach message from nrepl is prefix with the number of forms, rather than the number of bytes of the message
21:30hiredmanimpossible to deal with unless you scan it a character at a time
21:30hiredmanugh
22:13livingstonunderscore as a namespace for a symbol is special, isn't it?
22:18livingstonnevermind... 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:19hiredmanunderscores in namespaces is a bad idea
22:19clojurebotRoger.
22:19hiredmanclojurebot: botsnack
22:19clojurebotthanks; that was delicious. (nom nom nom)
22:20livingstonwhy is that?
22:22hiredmanlivingston: 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:23livingstonoh I'm just talking about symbols (and their namespaces) I'm using as data
22:24brehautlivingston: its uncommon to use symbols as data in clojure. idiomatically most code uses keywords for that purpose
22:26livingstonbrb - phone
22:41mecIs there a primitive version of mod?
23:01livingstonbrehaut: there are uses for both.
23:02livingstonif you want to logically group a bunch of symbols together, that's exactly what namespace part of a symbol is for.
23:35jlftechnomancy: 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:40jlftranscript at http://paste.lisp.org/display/120649
23:45phenom_anyone know why #1 performs about 5 times faster than #2 here: http://pastie.org/1688494 ?
23:47brehautphenom_: pastie.org doesnt want to respond for me; can you put it somewhere else?
23:50phenom_brehaut: http://pastebin.com/temNwRkP
23:50brehautmuch better
23:52brehautphenom_: you have warn on reflection on?
23:53phenom_yup, nothing in that block comes up
23:53phenom_but i see from stacktraces it's reflecting
23:54brehauti cant compile either without a defintion for MyBuffer
23:55brehautbut 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:55phenom_but buf is type hinted :S
23:56brehautnot in the version i have
23:56brehauti dont know if the compiler infers back from class names