2009-12-16
| 00:08 | _ato | technomancy: http://meshy.org/~ato/tmp/rockstar.jpg :-P |
| 00:09 | _ato | just kidding, it's really: http://meshy.org/~ato/tmp/me.jpg |
| 00:09 | technomancy | \m/ |
| 00:09 | technomancy | looks like early-collective-soul hair; nice. |
| 00:16 | metvop | This is OK: (def rands (repeatedly rand)) (take 4 rands) But this: (def infinite-rand-binary (repeatedly (rand-int 2))) (take 4 infinite-rand-binary) throws a ClassCastException. ??? |
| 00:16 | tomoj | you missed a # |
| 00:17 | tomoj | ,[(rand-int 2) #(rand-int 2)] |
| 00:17 | clojurebot | [1 #<sandbox$eval__3689$fn__3691 sandbox$eval__3689$fn__3691@168cd47>] |
| 00:18 | metvop | ah ha. thx, tomoj |
| 00:18 | technomancy | whew; made it through my backlog of lein/swank mail |
| 00:18 | technomancy | but ran out of time to do any actual coding myself. =( |
| 01:39 | defn | how does one go about documenting all of the documentation in core |
| 01:39 | defn | err printing the documentation |
| 01:40 | defn | specifically im trying to print all of the documentation for every form to files based on the name of the form |
| 01:48 | alexyk | How do you take a slice of a vector [1 2 3] to get [2 3]? |
| 01:49 | defn | alexyk: (rest [1 2 3]) |
| 01:50 | defn | (drop 1 [1 2 3]) |
| 01:50 | alexyk | defn: (rest [1 2 3]) is not a vector |
| 01:50 | defn | oh duh, sorry |
| 01:50 | alexyk | ,((rest [1 2 3]) 1) |
| 01:50 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to clojure.lang.IFn |
| 01:51 | alexyk | ,(vec ((rest [1 2 3])) 1) |
| 01:51 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to clojure.lang.IFn |
| 01:51 | alexyk | ,((vec (rest '[1 2 3])) 1) |
| 01:51 | clojurebot | 3 |
| 01:52 | alexyk | but I wonder if there's a simpler way without converting to seq and vec |
| 01:53 | defn | ,(let [[_ x y] [1 2 3]] [x y]) |
| 01:53 | clojurebot | [2 3] |
| 01:55 | defn | alexyk: does that work for you |
| 01:57 | alexyk | defn: works ok |
| 01:57 | defn | I was thinking you could do something like |
| 01:57 | alexyk | still not very general... |
| 01:57 | defn | ,(let [[_ x & xs] [1 2 3 4 5]] [x xs]) |
| 01:57 | clojurebot | [2 (3 4 5)] |
| 01:58 | defn | not the best, still a bit of "incidental complexity" there |
| 01:58 | defn | some crap you need to carry around with you |
| 01:58 | defn | alexyk: are you against using contrib? |
| 01:59 | alexyk | defn: not at all, don't know it much yet :) |
| 02:00 | defn | you could write a slicer fn |
| 02:00 | defn | it wouldnt be very hard |
| 02:01 | alexyk | sure |
| 02:03 | defn | alexyk: here it is |
| 02:04 | defn | ,(subvec [1 2 3] 1 3) |
| 02:04 | clojurebot | [2 3] |
| 02:04 | defn | :) |
| 02:05 | alexyk | ah! |
| 02:05 | alexyk | loovely |
| 02:05 | defn | you can also just set the start |
| 02:05 | defn | and it will use count vec as the end |
| 02:05 | defn | ,(subvec [1 2 3 4 5 6] 1) |
| 02:05 | clojurebot | [2 3 4 5 6] |
| 02:11 | defn | alex wissenberg - suite bergamasque: 3. Claire De Lune |
| 02:13 | defn | weissenberg |
| 02:14 | LauJensen | Good morning gents |
| 02:15 | alexyk | LauJensen: morning! |
| 02:15 | defn | good morning sir |
| 02:15 | defn | LauJensen: how would you suggest getting documentation for all of clojure.core |
| 02:15 | defn | all of the (doc x) stuff |
| 02:16 | alexyk | Say I have a seq of pairs. ([1 2] [2 3] [7 5] ...). I can sort it by first with (sort-by first myseq); but then the seconds will be in random order. How'd I sort first by first, second by second? |
| 02:16 | LauJensen | ah Theres a project on Github which extracts that and outputs an HTML I think |
| 02:16 | LauJensen | lemme check |
| 02:16 | alexyk | LauJensen: so you're the author of ClojureQL, right? |
| 02:16 | LauJensen | alexyk: One of them, yes |
| 02:16 | alexyk | nice |
| 02:17 | LauJensen | alexyk: I don't see how you can make that sort with out 2 successive calls to sort, ie sort-by first, sort-by second > |
| 02:17 | alexyk | LauJensen: so I guess I'd have to give an exact comparator |
| 02:18 | alexyk | you mean you don't see, i.e. it's not possible? |
| 02:20 | LauJensen | Depends a little on what you want. Say you have [1 3] [2 2] [3 1]. Then ordered by first you have a, b, c, sorted by second its c b a - which do you want ? |
| 02:20 | defn | alexyk: you could just write another sort-by |
| 02:20 | defn | just copy/paste the existing code for sort-by and reverse them |
| 02:21 | defn | actually, that's an idea |
| 02:21 | defn | reverse your vectors |
| 02:21 | defn | err your pairs |
| 02:21 | alexyk | I mean [1 2] [1 1] [2 1] must become [1 1] [1 2] [2 1] -- equal firsts are together, and within them seconds are sorted |
| 02:21 | alexyk | I need control on asc/desc at each level |
| 02:22 | defn | so it becomes [1 1] [1 1] [2 2]? |
| 02:22 | alexyk | no, pairs stay intact |
| 02:22 | defn | ohhhhh! i see what you mean |
| 02:22 | alexyk | so it's sorting pairs as units |
| 02:22 | defn | hmmm |
| 02:23 | LauJensen | ,(sort-by first < (sort-by second < (list [1 2] [1 1] [2 1]))) |
| 02:23 | clojurebot | ([1 1] [1 2] [2 1]) |
| 02:23 | LauJensen | Its that what you're thinking? |
| 02:23 | defn | nice |
| 02:23 | defn | what is the < ? |
| 02:23 | LauJensen | less than |
| 02:23 | defn | oh, i didnt know you could use it there |
| 02:23 | LauJensen | thats the comparator |
| 02:23 | alexyk | LauJensen: yeah |
| 02:23 | defn | LauJensen: wutsacomparator? |
| 02:24 | LauJensen | ,(< 5 4) |
| 02:24 | clojurebot | false |
| 02:24 | LauJensen | Its a predicate, if it evals to true it swaps, it not order remains |
| 02:24 | defn | oh sure, i just didnt think it'd be able to be sandwiched in with that first |
| 02:24 | alexyk | LauJensen: btw, I found mmcgrana's clj-jdbc, and asked what's different about that. He remarked interestingly, I'd like your opinion: http://paste.pocoo.org/show/157328/ |
| 02:24 | LauJensen | I think thats impossible, you need 2 runs |
| 02:25 | LauJensen | alexyk: What was his remark ? |
| 02:25 | alexyk | in the paste |
| 02:25 | LauJensen | sec |
| 02:26 | defn | destructuring is too cool |
| 02:26 | LauJensen | alexyk: His remark is invalid as the call to query he makes in the pseudo ClojureQL code, will result in a native Clojure hashmap which you can manipulate |
| 02:26 | defn | it's like "here, arrange these two things however the hell you want" |
| 02:26 | defn | or 10 things of course |
| 02:27 | defn | [[_ x _ _ y _] [1 2 3]] |
| 02:27 | defn | that's just too cool |
| 02:27 | alexyk | LauJensen: what does the resulting hashmap look like? |
| 02:28 | defn | LauJensen: do you know how one might go about getting the documentation for each form in a namespace |
| 02:29 | LauJensen | clojureql> (query table1 [a b c] (= a b)) |
| 02:29 | LauJensen | {:columns [a b c], :tables [table1], :predicates [= a b], :column-aliases {}, :table-aliases {}, :env []} |
| 02:29 | LauJensen | at alexyk |
| 02:29 | LauJensen | defn: You mean dynamically ? |
| 02:30 | alexyk | thx! |
| 02:30 | alexyk | nice |
| 02:30 | LauJensen | Yes we think so |
| 02:31 | defn | LauJensen: nah, just the bare bones of 'clojure.core |
| 02:31 | LauJensen | defn: then clojure.org's API page should do you well ? |
| 02:31 | defn | ohh, no, i see waht you mean, yes, dynamically |
| 02:32 | defn | i want to print out the docstring for each clojure form to a file |
| 02:32 | defn | separate files |
| 02:32 | defn | based on the name of the form |
| 02:32 | defn | like accessor -> accessor.txt |
| 02:32 | defn | which contains the docstring |
| 02:34 | LauJensen | defn: the project I wanted you to see isn't on github |
| 02:35 | defn | i bet i know what it is |
| 02:35 | defn | contrib-autodoc |
| 02:35 | defn | tom faulhaber? |
| 02:35 | _ato | defn: ns-publics |
| 02:35 | _ato | + meta |
| 02:36 | defn | hmmm |
| 02:36 | defn | ,(vals (ns-publics 'clojure.core)) |
| 02:36 | clojurebot | (#'clojure.core/sorted-map #'clojure.core/read-line #'clojure.core/re-pattern #'clojure.core/keyword? #'clojure.core/val #'clojure.core/chunked-seq? #'clojure.core/find-protocol-impl #'clojure.core/*compile-path* #'clojure.core/max-key #'clojure.core/list* #'clojure.core/ns-aliases #'clojure.core/the-ns #'clojure.core/== #'clojure.core/chunk-buffer #'clojure.core/longs #'clojure.core/special-form-anchor #'clojure.core/ins |
| 02:36 | defn | nice |
| 02:36 | defn | ty |
| 02:45 | LauJensen | ,(doseq [funcs (sort-by (comp :name meta) (vals (ns-interns 'clojure.main)))] (prn (:doc (meta funcs)))) |
| 02:45 | clojurebot | "Evals expressions in str, prints each non-nil result using prn" "Print help text for main" "Returns the handler associated with an init opt" "Load a script" "Common initialize routine for repl, script, and null opts" "Called by the clojure.lang.Repl.main stub to run a repl with args\n specified the old way" "Called by the clojure.lang.Script.main stub to run a script with args\n specified the old way" "Loads Clojure sour |
| 02:46 | LauJensen | I think that will dump all docs from a namespace, format to your liking |
| 02:46 | LauJensen | @ defn |
| 02:55 | alexyk | can you nest ->> ? |
| 02:56 | alexyk | here's a puzzle: this works: |
| 02:56 | alexyk | ,((fn [[xs ys]] [(mean xs) (mean ys)]) (->> '([1 2][2 3][5 4]) (reduce (fn [[xs ys] [x y]] [(conj xs x) (conj ys y)]) [[][]]))) |
| 02:56 | clojurebot | java.lang.Exception: Unable to resolve symbol: mean in this context |
| 02:56 | alexyk | argh |
| 02:56 | alexyk | will paste tmrw :) |
| 02:57 | _ato | well you can nest ->> but it probaby won't do what you want it to do |
| 02:57 | _ato | nesting -> makes a lot more sense |
| 03:00 | defn | LauJensen: thanks |
| 03:04 | LauJensen | np |
| 03:54 | LauJensen | Just to be clear, this post states that Clojure now outperforms Scala on Widefinder? http://meshy.org/2009/12/13/widefinder-2-with-clojure.html |
| 04:05 | LauJensen | Oh, Disclojure says so |
| 04:17 | _ato | LauJensen: heh, well Scala could do exactly the same thing I'm doing there with Clojure. So could Java. But I've a least shown that there's nothing stopping you from writing Clojure code that performs well and you don't have to go to a huge amount of effort, aside from the mentioned problems with Java's IO library |
| 04:18 | LauJensen | Oh, that blog post is your doing? |
| 04:22 | cark | just finnished reading it, nice read |
| 05:08 | adityo | good afternoon |
| 05:08 | adityo | ,'("a" "b") |
| 05:08 | clojurebot | ("a" "b") |
| 05:09 | adityo | any good ways of converting the list into a hash-map |
| 05:13 | Raynes | adityo |
| 05:14 | Raynes | ,(apply hash-map '(a b c d)) |
| 05:14 | clojurebot | {a b, c d} |
| 05:19 | adityo | Raynes: god bless you |
| 05:19 | adityo | :) |
| 06:42 | hipertracker | Do I need to set something to display utf8 strings in Clojure? For instance that code launch swing window but the text is corrupted: (. javax.swing.JOptionPane (showMessageDialog nil "Zażółć gęślą jaźń")) |
| 06:44 | Chousuke | make sure Java's default encoding is set to UTF-8 |
| 06:45 | Chousuke | also, (javax.swing.JOptionPane/showMessageDialog nil "whatever") is the more idiomatic form for static method calls :) |
| 06:46 | Chousuke | (and (.method obj args) for instance methods/fields) |
| 07:04 | fliebel | How do you guys design applications? I always start coding right away. This time I decided to make a nice flowchart, but it seems so pointless… I already know what I want to do. |
| 07:11 | briansheehan | Hi, I'm looking for help on how to compile a clojure name space to a .class and package it in a jar file |
| 07:16 | _ato | fliebel: yeah, I've never been much of a flowchart/uml/specifications guy. I'll think about the problem for a bit and then just start hacking on it. If I'm designing a data structure or something I might pull out the paper and scribble some diagrams, and I might do the same if I'm about to do something complex and want to bounce it off some colleagues, but it's just throwaway stuff, I never look at it again. I do tend to scribble |
| 07:16 | _ato | down notes a bit, but its more about data examples and such rather than the code |
| 07:18 | briansheehan_ | Hi, can anyone tell how I can compile a .clj file to a .class file? |
| 07:18 | esj | i agree. The critical element is to write tests as you go. |
| 07:19 | _ato | briansheehan_: there's an example here: http://clojure.org/compilation |
| 07:21 | _ato | or if it's more compilation and packaging you're after, rather than creating a java-compatible class, check out Leiningen: http://github.com/technomancy/leiningen |
| 07:22 | briansheehan_ | thanks, I'll have a look at those |
| 07:40 | fliebel | esj: I never write official test either, but I admit that is a bad idea. I do write some stuff that checks the output of a function, but nothing like a test directory to store tests and test the system against. |
| 07:41 | esj | fliebel: I never used to either, but learnt that lesson hard. |
| 07:42 | LauJensen | Has anybody here had any trouble with ClojureQLs new Gradle setup, or is it working flawlessly across the board? |
| 07:50 | fliebel | Has anyone used QT with Clojure? |
| 07:57 | cemerick | some people were experimenting with using jambi + clojure some months back |
| 07:57 | cemerick | it being de-supported isn't helping current usage, I'm guessing |
| 07:57 | LauJensen | fliebel: Yea I've done a bit |
| 07:57 | LauJensen | ~gitdoc |
| 07:57 | clojurebot | gitdoc is http://github.com/Lau-of-DK/gitdoc/tree/master |
| 07:58 | LauJensen | If thats still up, then thats a Git Log Tree Viewer in Clojure/QT |
| 07:58 | LauJensen | Its been ages though |
| 07:58 | LauJensen | When it got OpenSource I gave up interest, despite being in version 4.x it was fundamentally flawed |
| 08:05 | cemerick | I wish Sun had bought QT and used it as the basis of swing 2 :-P |
| 08:05 | fliebel | so what is the preferred way to write a gui in Clojure? |
| 08:06 | cemerick | you can easily use swing or swt |
| 08:06 | cemerick | and there's the respective RCP's (eclipse and NetBeans RCP) |
| 08:06 | fliebel | I did a little Swing in my Java times… I think it's ugly and verbose... |
| 08:07 | cemerick | *all* UI code in any language is ugly and verbose. |
| 08:07 | cemerick | IMO, if you're coding the UI by hand, you're doing it wrong. |
| 08:08 | Chousuke | Qt is GPL though. I wonder if that has any effect on its use with Clojure :/ |
| 08:09 | cemerick | are Qt licenses particularly expensive? |
| 08:09 | fliebel | Hmm, I wonder if I can use XCode to create a nice gui... |
| 08:09 | dabd | I'm trying to port some java code to clojure is it recommended to use clojure-git or clojure-1.0.0? I had some issues with clojure-git and enclojure so I switched back to 1.0.0 but I wonder if I am missing important language features. thx |
| 08:10 | Chousuke | dabd: 1.1 is coming soon (hopefully) so going with git master for now probably won't be too problematic. |
| 08:11 | LauJensen | fliebel: Preffered way of writing UI: Compojure/HTML :) |
| 08:12 | dabd | Chousuke: clojure-git is not working with enclojure. I am unable to start the REPL |
| 08:13 | dabd | is anyone successfully using enclojure with clojure-git? |
| 08:13 | fliebel | LauJensen: Hmm, since I'm a web developer that wouldn't be a crazy idea... |
| 08:14 | cemerick | dabd: the 20091103 build is broken in that way for me as well; the 20090922-patch1 build is very solid: http://github.com/EricThorsen/enclojure/downloads |
| 08:14 | fliebel | For me not writing a GUI by hand confuses me because I don't know what's going on. |
| 08:15 | cemerick | fliebel: once jwebpane shows up in swing, then we can all just do UIs using web bits, which will be pleasant. |
| 08:15 | fliebel | cemerick: QT already has webkit :D |
| 08:15 | Chousuke | hm |
| 08:16 | cemerick | fliebel: it's better that you don't know. Layout managers, etc. are too complex for people to use. |
| 08:16 | dabd | cemerick: I tried it and had the same issues too. The only way was to switch back to clojure-1.0.0 |
| 08:16 | Chousuke | apparently Qt has a GPL exception that specifically allows using it with EPL. |
| 08:16 | Chousuke | And a bunch of other licences |
| 08:16 | cemerick | dabd: hrm, that problem I don't have -- running very near the head of the new branch here. |
| 08:17 | cemerick | I have zero interest in screwing with native libs. Totally not worth the hassle. |
| 08:17 | fliebel | cemerick: I can't stand things I don't understand... |
| 08:17 | cemerick | fliebel: if you don't stand on the shoulders of giants, you'll not see as far as everyone else :-) |
| 08:18 | dabd | cemerick: so you're using the new branch with 20090922-patch1 ? I'll try that |
| 08:19 | cemerick | dabd: yes -- not HEAD, but close to it. Haven't switched over to using the builds from build.clojure.org yet |
| 08:19 | fliebel | cemerick: but if your giant is heading in the wrong direction, how much does that buy you? |
| 08:20 | cemerick | fliebel: what's the right direction in this particular circumstance? *every* UI toolkit provides visual designers at this point, very sophisticated ones at that, simply because they're necessary in order to get stuff done. |
| 08:20 | cemerick | The fact that I can't do the same in a web environment is a constant frustration for me. |
| 08:21 | angerman | can I turn a struct into a map? |
| 08:22 | angerman | Baiscally I want to do {(:id struct) (dissoc struct :id)} |
| 08:22 | fliebel | cemerick: so the conclusion is that gui toolkits should learn from css, so that norma human beings can read and write it. |
| 08:23 | cemerick | fliebel: people who know CSS can read and write it, and I'm unfortunately one of them. CSS, the box model, blah blah blah is just as complicated as Swing or winforms or... |
| 08:23 | cemerick | relative to what you can do with it, that is |
| 08:24 | fliebel | So maybe I'll go with QT, that is one technology to learn, but is usable on any platform and in any major language. |
| 08:25 | cemerick | has jambi been resurrected at all? |
| 08:25 | fliebel | not sure... |
| 08:29 | fliebel | this seems alive: http://qt.gitorious.org/qt-jambi |
| 08:29 | lpetit | ,(doc intoà |
| 08:29 | clojurebot | EOF while reading |
| 08:29 | lpetit | ,(doc into) |
| 08:29 | clojurebot | "([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined." |
| 08:30 | cemerick | huh, so it does -- I didn't realize Qt had taken out a spot on gitorious as well |
| 08:30 | cemerick | fliebel: if you come across a concrete status/"roadmap" statement about jambi in your spelunking, do share. |
| 08:33 | lpetit | > ,(type (-> (create-struct :a) (struct 'a))) |
| 08:33 | lpetit | ,(type (-> (create-struct :a) (struct 'a))) |
| 08:33 | clojurebot | clojure.lang.PersistentStructMap |
| 08:33 | fliebel | meh, only the main qt roadmap: http://qt.nokia.com/developer/qt-roadmap |
| 08:33 | lpetit | ,(type (into {} (-> (create-struct :a) (struct 'a)))) |
| 08:33 | clojurebot | clojure.lang.PersistentArrayMap |
| 08:33 | lpetit | angerman: I guess this answers your question ? |
| 08:34 | angerman | lpetit: yes, thanks |
| 08:36 | cemerick | fliebel: this was the last interesting thing I saw w.r.t. jambi's status/plan: http://labs.trolltech.com/blogs/2009/05/11/qt-jambi-450_01-released-contributors-wanted/ |
| 08:38 | _ato | I had a play with the 4.6 community version |
| 08:38 | _ato | it takes ages to compile but seeems to work fine |
| 08:38 | cemerick | it's 2 years from now that'd I'd be worried about |
| 08:40 | froog | what's wrong with swt? |
| 08:40 | cemerick | that's what I would tend towards if I absolutely needed native components |
| 08:41 | cemerick | I personally prefer swing's model and API, but that's a matter of taste. |
| 08:42 | froog | I've never tried swt myself, only swing. But I do prefer the native look of swt |
| 08:43 | cemerick | that's always confused me about swt -- the components don't look particularly "native", insofar as I can spot an swt app in half a beat. |
| 08:59 | fliebel | cemerick: I think it's not about the widgets, but their layout. |
| 09:01 | cemerick | fliebel: totally from memory (haven't used an swt app in a long time), the default tab panes are always wonky on OS X -- the color isn't quite right, and the tabs are shifted up a few pixels than it seems they should be *shrug* |
| 09:02 | lpetit | cemerick: yes, swt applications using CTab do not use native widgets, AFAIK |
| 09:04 | froog | name a jambi app I could test run, I'd like to see how the gui looks |
| 09:05 | fliebel | froog: qt includes a whole load of examples… it should look the same as any qt binding. |
| 09:06 | _ato | froog: http://en.wikipedia.org/wiki/Qt_(toolkit)#Applications_built_using_Qt |
| 09:06 | _ato | likely you're already using something that uses qt |
| 09:06 | froog | fliebel, _ato: thanks |
| 09:07 | froog | no need to test then :) |
| 09:07 | lpetit | cemerick: http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/custom/CTabFolder.html (it's in the "custom" package of swt, I guess where composites not deriving from native widgets are placed |
| 09:08 | fliebel | _ato: not any applications i'd use daily. the closest: Opera, Skype and VirtualBox |
| 09:22 | octe | has the defmulti signature changed recentlyish? |
| 09:37 | fliebel | defn: are you there? |
| 10:59 | haptiK | anyone here attending clojure london dojo in january? |
| 11:14 | Ankou | hi. is it possible to develop a GUI application with swing without remembering state explicitly? For example, when I click on a button and want this to be remembered so that another button does something else the next time. Do I need state or is there a more functional way? |
| 11:15 | gianlucadv | Hi! I have a program written in a purely-functional style (i.e. no refs, agents, atoms) which spends roughly 70% of the time in RMI TCP connections (more precisely in thread pool executor worker run). Any hints in optimizing my program? Thanks |
| 11:16 | kwatz__|wrka | Ankou: I've been trying out the pattern described here: http://groups.google.com/group/clojure/msg/e10960d88a87350c?pli=1 |
| 11:16 | kwatz__|wrka | I like it quite a bit so far |
| 11:17 | zaphar_ps | Ankou: functional apps have state they just they just don't have mutable shared state. It's not as limiting as it first seems |
| 11:17 | chouser | well, a GUI *is* mutable shared state |
| 11:18 | chouser | but clojure gives you the tools to manage exactly that, via the reference types |
| 11:23 | rb__ | anyone can tell me how to install clojureql with gradle? instructions by lau tel how to install gradle+clojuresque, but not clojureql :-) |
| 11:56 | lpetit | chouser: off topic question, but since you're a well known javascript expert: do you know of a good basis project for writing an editor in javascript, e.g. a source-code like editor (with syntax coloring, code completion, etc.) ? |
| 11:56 | lpetit | sorry for the possible repetition of the question, but my IRC client is weird today ... |
| 11:57 | rys | freenode's been a load of crap today, too |
| 11:57 | chouser | lpetit: hm... I have attempt to start such a project... |
| 11:58 | lpetit | chouser: I know there is some effort for putting eclipse editors online, not sure it's possible to get just the interesting part though ... |
| 11:59 | chouser | the main early question I confronted was whether to use a textarea or html for the main body of the editor |
| 11:59 | chouser | textarea is much better behaved, standard, etc. but you can't have any colored or styled text, afaik. |
| 12:06 | chouser | lpetit: perhaps http://www.netpadd.com/b ? I haven't looked at it too deeply. |
| 12:08 | lpetit | chouser: thanks for the link, I'll check that. There's also Eclipse RAP (e.g. http://rap.eclipsesource.com/e4-contacts/org.eclipse.e4.demo.contacts.product?startup=org.eclipse.e4.ui.workbench.swt.application ) I have to check, since our RDA technology is already made via Eclipse plugins |
| 12:16 | hipertracker | How to display all available symbols in current namespace? Is there something similiar to pythonic dir() ? |
| 12:19 | stuartsierra | hipertracker: ns-publics, ns-interns, ns-map, ... |
| 12:26 | doublindirection | is there a way to tell swank to display stdout in the repl? System.out.println output shows in the *inferior-lisp* buffer but not in the repl |
| 12:28 | lpetit | chouser: I must, leave, but look what I've found ! http://marijn.haverbeke.nl/codemirror/ |
| 12:30 | Chousuke | hmm |
| 12:30 | Chousuke | my reader seems to work pretty nicely on top of the new branch |
| 12:31 | Chousuke | But looking at it now, the design is not very flexible. It's easier to hack than the java version, but that's it :P |
| 12:31 | jasapp | Chousuke: is your reader up on github? |
| 12:32 | Chousuke | not this new-branch one, but yes. |
| 12:32 | jasapp | ok |
| 12:34 | Chousuke | right now the reader just reads stuff character-by-character and tries to transform that into clojure data structures. |
| 12:35 | jasapp | as opposed to some kind of tokenization? |
| 12:35 | Chousuke | yeah. |
| 12:36 | jasapp | I don't have any idea whats involved, but that doesn't sound too bad as a next step |
| 12:37 | Chousuke | I think It'd be much easier to work with a stream of open-paren-token, text-chunk, whitespace-chunk, newline ... |
| 12:37 | jasapp | oh, I'm confused :-) |
| 12:38 | jasapp | I thought thats what you were working with |
| 12:38 | Chousuke | nah, right now it works with just characters and does a multimethod dispatch on each :P |
| 12:39 | jasapp | ahh, gotcha |
| 12:39 | Chousuke | makes reader macros trivial, but hmm... |
| 12:39 | jasapp | what is performance like, or does it really matter? |
| 12:40 | Chousuke | I haven't even benchmarked it. |
| 12:40 | Chousuke | it's fast enough :) |
| 12:40 | Chousuke | at least for now. |
| 12:40 | jasapp | cool |
| 12:41 | Chousuke | I think if I did this chunking approach I could return "continuations" to the reader part. like "I ran out of stuff to read. if you have any more, call this." |
| 12:41 | jasapp | interesting, I'm trying to think of applications |
| 12:42 | Chousuke | well, the reader wouldn't necessarily have to crap out when reading (str "foo<EOF> |
| 12:42 | jasapp | ahh |
| 12:46 | aking | doublindirection: (add-hook 'slime-connected-hook 'slime-redirect-inferior-output) |
| 12:47 | doublindirection | aking, that worked great, thanks |
| 13:09 | devlinsf | stuartsierra:ping |
| 13:26 | chouser | devlinsf: I finally read your docs and code for the map-utils. I hope to have some comments for you later today. |
| 13:26 | devlinsf | chouser: Okay, cool |
| 13:27 | devlinsf | chouser: Figurd you're busy w/ 1.1 |
| 13:29 | dysinger | poor freenode :( |
| 13:30 | qed | twbray's post on _ato's implementation sounds a lot like sour grapes |
| 13:30 | dysinger | because it wasn't clojurey enough ? |
| 13:30 | dysinger | I just quickly scanned it and that's what I read |
| 13:30 | qed | yeah, and how "my version was cleanly bisected into a file-reader to which you could pass an arbitrary user function, and the actual stats comutation" |
| 13:31 | qed | it's kind of like...so what-- his took 8minutes |
| 13:33 | qed | and yeah, the whole "he used AtomicLongs", ato's response in the comments is pretty much dead on: "I needed an atomic counter. That's why I picked it." |
| 13:33 | BrianB04 | Good afternoon all. |
| 13:35 | bagucode | technomancy: Hello. I fixed the issues you mentioned regarding the native lib compile support. I think I got the merge right ;) |
| 13:37 | hiredman | qed: I doubt it, I would check logs for twbray's realtime response in channel |
| 13:37 | hiredman | very positive |
| 13:40 | rhickey | 2010 funding crosses the 50% mark, as relevance and many more individuals come on board - thanks all! http://clojure.org/funders |
| 13:40 | devlinsf | Hurray |
| 13:40 | hiredman | oooo, google-o-meter |
| 13:41 | technomancy | rhickey: could you add my name? I donated before you were asking permission to post names. thanks. |
| 13:41 | dysinger | rhickey: good news |
| 13:41 | rhickey | technomancy: sure thing |
| 13:42 | _fogus_ | rhickey: Congratulations. A great thing that's happening there |
| 13:42 | dysinger | Well let's not get too excited - I would not be jumping around happy about being able to pay 50% of my bills for the year. |
| 13:43 | qed | heh, good point |
| 13:43 | qed | alright! i can feed half of my kids! |
| 13:43 | technomancy | that only works if you're single and able to become a coding hermit for the purposes of science |
| 13:45 | technomancy | bagucode: sweet. I hope to be able to get back to my patches queue either tonight or tomorrow night. |
| 13:45 | technomancy | thanks |
| 13:47 | bOR_ | dysinger - the call has been out for what, 24 hours? |
| 13:47 | bOR_ | I guess a lot of people haven't seen it yet. |
| 13:47 | technomancy | I'm not so sure; buzz builds and fades _really_ fast in twitter-land at least. |
| 13:47 | dysinger | y it's good stuff - but buzz does fade fast |
| 13:48 | bOR_ | I was planning not to donate before 2010 actually started :). 2009 was already taken care of. |
| 13:48 | technomancy | it's been at least 3 days; with peepcode sales the third day was less than 25% of the first day. |
| 13:48 | bOR_ | interesting. |
| 13:48 | technomancy | but I guess this is different since company sponsorships take longer |
| 13:50 | bOR_ | the old sourceforge donation page is also still around. |
| 13:52 | mtm | is the 'clojure cheat sheet' source tucked away on github anywhere? would be nice to update it a bit... |
| 13:52 | jasapp | rhickey: you have a new donation, it's fine to use my name btw |
| 13:59 | grantmichaels | i'm not done donating, just waiting to get paid again to "finish" for the time being =) |
| 14:10 | chouser | rhickey: have you considered doing call-site caching ala (:foo bar) for regular unhinted Java method calls? |
| 14:19 | defn | grantmichaels: same here |
| 14:25 | r2q2 | Stupid question but is there an actual number behind the funding target for clojure? |
| 14:26 | grantmichaels | r2q2: there's a meter as of yesterday =) |
| 14:26 | stuartsierra | devlinsf: pong |
| 14:34 | fliebel | How hard is it to set up my own little smtp server with Clojure? With Python I can do that with a few lines. I want to make something like my private Posterous for my own cms, maybe together with defn, if he is there... |
| 14:38 | devlinsf | stuartsierra: Sorry, ping back |
| 14:39 | stuartsierra | devlinsf: ping, pong, sping, ... |
| 14:39 | defn | fliebel: im here |
| 14:39 | rhickey | chouser: yes |
| 14:40 | defn | rhickey: any chance you could get something set up to donate monthly? |
| 14:40 | defn | like 10$/month |
| 14:41 | devlinsf | stuartsierra: I was reviewing the changes doc and found and interesting statement about clojure.template |
| 14:41 | rhickey | defn: paypal has a subscription thing, I've never tried it |
| 14:41 | devlinsf | stuartsierra: From the doc: Used to implement the "are" macro in clojure.test, and not recommended otherwise. |
| 14:41 | defn | rhickey: *nod* -- I just donated to Wisconsin Public Radio and I found their monthly donation thing to be kind of nice for someone like myself that's a poor student |
| 14:42 | cemerick | stuartsierra: saw your msg on the clojure-maven-plugin list -- shouldn't it be more of a matter of exec'ing the right 'java', rather than piling everything into maven's process? |
| 14:42 | devlinsf | stuartsierra: should this ns not be used by the end developer? |
| 14:42 | r2q2 | rhickey: Are you opposed to lower donations? |
| 14:43 | stuartsierra | devlinsf: anyone is free to use it, but I'm assuming it won't be very useful |
| 14:43 | stuartsierra | cemerick: It could work that way, but should be faster to run in the same JVM. |
| 14:44 | devlinsf | stuartsierra: Right. I know you hads a different idea when you wrote it, and things changed. This brings up a difficult question |
| 14:44 | devlinsf | stuartsierra; Should clojure.template exist, or should the two macros be placed in clojure.test? |
| 14:45 | stuartsierra | devlinsf: they work independently of clojure.test, so maybe someone will have a use for them |
| 14:45 | cemerick | stuartsierra: I'm concerned about different profiles requiring different versions of java and about potential root classloader leakage (e.g. some JDK classes retain a reference to the classloaders, opening the door to odd bugs when running tests, etc) |
| 14:45 | devlinsf | stuartsierra: So leave them in as an experiment, and see what happens? |
| 14:46 | dabd | why isn't the 'def' macro documented in the API? |
| 14:46 | cemerick | stuartsierra: entirely possible I'm guilty of some ant transference on the first point. |
| 14:46 | devlinsf | dabd: It's a special form |
| 14:46 | devlinsf | dabd: http://clojure.org/special_forms |
| 14:47 | stuartsierra | cemerick: I don't know. That's why I put it out there quickly, in the hopes that people would uncover these sorts of problems. |
| 14:47 | rhickey | r2q2: people seem to be trying to do the suggested amount. Some can't due to being in different countries with different economies, or personal financial situations, and of course that's fine and appreciated all the more |
| 14:48 | devlinsf | stuartsierra: If the idea is to leave them in as an experiment, is it okay if I rework that section of the change doc? |
| 14:48 | cemerick | stuartsierra: I'll try to bang on it with the example I have that is most likely to cause problems early next week. Need to port that build from ant first. :-) |
| 14:48 | dabd | devlinsf:thx |
| 14:48 | stuartsierra | devlinsf: yes |
| 14:48 | stuartsierra | cemerick: cool, thanks |
| 14:49 | devlinsf | stuartsierra: Okay, cool |
| 14:51 | piccolino | Is LauJensen around? |
| 14:52 | stuartsierra | devlinsf: It's not really an experiment. The lib is there, it will probably stick around. |
| 14:52 | stuartsierra | devlinsf: It's just not something that regular users will need very often, I expect. |
| 14:53 | devlinsf | stuartsierra: Okay, so it's specialed support code. |
| 14:54 | devlinsf | stuartsierra; I'll take a look at the source for "are" and see if I can come up with a good paragraph for template, or other use cases. |
| 14:54 | defn | fliebel: priv msg when you have a chance |
| 14:56 | devlinsf | stuartsierra: Wow.... "are" is slick |
| 14:56 | devlinsf | stuartsierra: Love the body |
| 14:56 | cemerick | devlinsf: get a room! :-P |
| 14:57 | devlinsf | bah |
| 14:57 | devlinsf | cemerick: take look yourself :) |
| 14:57 | cemerick | oh yeah, I like 'are' :-) |
| 14:59 | devlinsf | Hmm... do-template is not the same as doseq... |
| 14:59 | devlinsf | Well, I'll have to look into this more later |
| 15:00 | devlinsf | gotta run |
| 15:03 | devlinsf | me/ thinks do-template might help java interop |
| 15:03 | devlinsf | oops |
| 15:03 | devlinsf | me\ thinks do-template might help java interop |
| 15:03 | devlinsf | Daammir |
| 15:03 | chouser | \me |
| 15:03 | devlinsf | Ah |
| 15:04 | devlinsf | \me thinks do-template might help java interop |
| 15:04 | devlinsf | No luck |
| 15:04 | chouser | /me |
| 15:04 | chouser | sorry |
| 15:04 | chouser | bad info |
| 15:04 | stuartsierra | methinks me think |
| 15:08 | stuartsierra | (is (= *technomancy* (think *technomancy*))) |
| 15:12 | cemerick | stuartsierra: I think you just made technomancy ethereal |
| 15:13 | stuartsierra | Yeah. I abstracted him away. |
| 15:13 | technomancy | but I don't wanna be a being of pure thought! |
| 15:14 | stuartsierra | Too late. |
| 15:14 | stuartsierra | You've been de-instantiated. |
| 15:14 | stuartsierra | All because of a misplaced paren. |
| 15:14 | danm_ | haha |
| 15:15 | technomancy | stuartsierra: time for you to learn paredit-mode before you do any more damage |
| 15:16 | stuartsierra | Yeah, just need to get elisp working in my IRC client. |
| 15:17 | the-kenny | If someone will contribute a paredit-addon to weechat, I'll use it :) |
| 15:23 | edbond | how should I call java's System.getProperty("user.home") ? |
| 15:23 | triyo | ,(System/getProperty "user.home") |
| 15:23 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read) |
| 15:24 | triyo | edbond: (System/getProperty "user.home") |
| 15:24 | edbond | triyo: thanks a lot |
| 15:26 | triyo | edbond: pleasure |
| 15:33 | triyo | Anyone know how compojure's defroutes works in relation to thread-safety? |
| 15:35 | defn | fliebel: ttp://github.com/defn/Utterson |
| 16:05 | shoover | cemerick: Seriously, some you corporate guys are funding Rich more than my company funds Microsoft |
| 16:05 | cemerick | shoot, I'm a corporate guy now? ;-) |
| 16:06 | shoover | Sorry, choose your own word :) You guys with the graphics at the top of the page |
| 16:06 | cemerick | shoover: yeah, I'm just messing with you |
| 16:07 | shoover | cemerick: I hear you. But yeah, it's great stuff |
| 16:08 | cemerick | just doing what's right, and honestly, what's in our best interest. Not sure where we'd be without clojure. |
| 16:09 | shoover | knee deep in curly braces and dependency injection |
| 16:09 | cemerick | it's that DI that'll kill ya |
| 16:09 | technoma` | cemerick: yeah, it's hard to remember to use clean needles for DI |
| 16:12 | shoover | ba dum dum... ching! |
| 16:40 | LauJensen | piccolino: Needed something? |
| 16:41 | piccolino | Oh hi, LauJensen. I just wanted to ask about the status of the Postgres support in ClojureQL. The web page says it supports Derby and MySQL, but there appears to be a driver file for Postgres. |
| 16:42 | LauJensen | Postgres is almost up to part with both Derby and MySql, several patches hopefully being added as soon as tomorrow |
| 16:42 | piccolino | Ah, OK, neat. |
| 16:50 | drewr | is there an inverse of bean? |
| 16:51 | drewr | i.e., takes {:foo 1 :bar 2} and creates a class with getters and setters? |
| 16:51 | the-kenny | drewr: Not as far as I know, but I'm not very familiar with the bean-stuff |
| 16:55 | polypus | i'm looking for docs on private vars. where to look? |
| 16:56 | stuartsierra | polypus: just ask |
| 16:56 | polypus | ok how do private vars behave? ty |
| 16:57 | stuartsierra | polypus: they can only be used within the same namespace |
| 16:58 | stuartsierra | 'use'/'refer' do not create mappings for private vars. |
| 16:58 | polypus | ok. thx |
| 16:59 | cemerick | it's good that clojure has come so far without any major gnashing of teeth about visibility, etc |
| 16:59 | robewald | Hello, I try to do this in the repl : (use 'clojure.zip :exclude [next] but I get an exception. How do I do this correctly? |
| 16:59 | stuartsierra | robewald: quote next |
| 17:02 | robewald | stuartsierra: same exception "unable to create ISeq from boolean" when doing this (use 'clojure.zip :exclude 'next) |
| 17:02 | stuartsierra | (use 'clojure.zip :exclude '(next)) |
| 17:03 | robewald | same problem. I am on the repl here and using clojure 1.0 |
| 17:03 | stuartsierra | maybe (use '[clojure.zip :exclude (next)]) |
| 17:03 | hiredman | yeah |
| 17:03 | stuartsierra | something like that |
| 17:05 | stuartsierra | (use '[clojure.zip :exclude (next replace remove)]) |
| 17:07 | saml | hola. how do I create an ssl client that can talk to https://somesite.com ? |
| 17:07 | LauJensen | have a look at jsch |
| 17:09 | saml | LauJensen, thanks |
| 17:10 | LauJensen | np :) |
| 17:10 | saml | haha their server is down |
| 17:12 | hiredman | like ssl or https? |
| 17:12 | hiredman | because the http stuff in the jre will do https no problem |
| 17:15 | jasapp | hiredman: did you get a call yesterday? |
| 17:15 | hiredman | jasapp: nope |
| 17:15 | hiredman | :/ |
| 17:15 | jasapp | me neither :/ |
| 17:16 | hiredman | hmmm |
| 17:17 | jasapp | the company I work for just got purchased, and all the cool lispy stuff is going away |
| 17:17 | jasapp | I'm supposed to be writing in c++ now |
| 17:18 | jasapp | so I'm a little bit ansy |
| 17:19 | hiredman | I work at a painting contractor, the only coding I do at work is a little vba :( |
| 17:19 | Fade | C++? isn't there some geneva convention prohibition there? |
| 17:19 | jasapp | heh :) |
| 17:21 | doublindirection | I'm profiling some clojure code and clojure.lang.Var.deref() seems to be taking most of the time, what does it mean? |
| 17:21 | doublindirection | using jvisualvm if it matters... |
| 17:21 | robewald | ok that works, thanks |
| 17:22 | Chousuke | doublindirection: you're accessing a global var in a tight loop repeatedly? |
| 17:24 | Chousuke | doublindirection: when you access a var (any def'd name) Clojure needs to deref it to get the actual value |
| 17:24 | doublindirection | Chousuke, could be, i'll check my code, thanks |
| 17:24 | saml | hiredman, ssl. wait aren't they the same thing? |
| 17:25 | saml | oh ssl is one level below |
| 17:26 | saml | i need ssl |
| 17:28 | metvop | while iterating through a list how to get the previous item in the list? Looking for something that can do this (Python): for i in range(len(example_list)): print example_list[i-1] |
| 17:29 | chouser | doublindirection: pretty often, Var.deref() shows up higher in profiling output than it "should" |
| 17:30 | chouser | that is, if you manage to avoid the derefs, your code will not run as much faster as the profiling would lead you to believe |
| 17:30 | the-kenny | ,(partition 2 1 [1 2 3 4 5]) |
| 17:30 | clojurebot | ((1 2) (2 3) (3 4) (4 5)) |
| 17:30 | the-kenny | metvop: Something like (map yourfun (partition 2 1 [1 2 3 4 5])) |
| 17:30 | metvop | the-kenny, thanks. i will try that out |
| 17:31 | doublindirection | chouser, meaning? I have one global ref to a map and I deref it and take the values in a (let ... |
| 17:31 | dnolen | metvop: if you use loop/recur you can do pretty much the same thing you do in Python. |
| 17:31 | chouser | doublindirection: I think the profilers may inhibit some of the performance "tricks" that Var does, tricks that work find with no profiler. |
| 17:32 | chouser | doublindirection: so I'd look at the items that are a bit less "hot" and try to resolve those first. |
| 17:32 | metvop | dnolen,duly noted. thx |
| 17:33 | technomancy | is it a decent idea to put a question mark in the middle of an identifier if you have a function that returns a predicate? |
| 17:34 | doublindirection | chouser, I went through the usual optimization suspects, and ran out of ideas, that why I ended profiling |
| 17:34 | waratuman | Just ran into a strange problem. I ran '(- 690.89 671.69)' in a clojure repl and got 19.199999999999932. Why is there an error in the calculation? |
| 17:35 | technomancy | waratuman: floats are always approximations |
| 17:35 | technomancy | use rationals if you need accuracy |
| 17:35 | waratuman | ah, ok that make sense |
| 17:35 | waratuman | I was just confused at first by it |
| 17:35 | Hun | floats are nearly every time the wrong choice |
| 17:35 | technomancy | understandable |
| 17:36 | Hun | exceptions are only when you can write a proof showing that they are the right choice |
| 17:36 | slashus2 | ,(- 690.89M 671.69M) |
| 17:36 | clojurebot | 19.20M |
| 17:36 | chouser | doublindirection: profiling is a good idea, I'd just try to ignore the Var.deref() for now and address the next hottest items. |
| 17:36 | technomancy | slashus2: if only that didn't make me think "nineteen point two million" |
| 17:36 | slashus2 | :-P |
| 17:38 | doublindirection | chouser, next items dont make a lot more sense, clojure.lang,Var.get, getThreadBinding, hasRoot |
| 17:53 | polypus | i'm trying to use contrib.generic.arithmetic but i'm getting this just from trying to :use it "/ already refers to: #'clojure.core// in namespace: myns". any ideas? |
| 18:04 | dabd | I would like to store my application's database connection settings. Is this the idiomatic way to do it in clojure? http://pastebin.com/d469079f |
| 18:05 | dnolen | dabdb: you could just use a global atom, I think using a ref is overkill for what you want to do. |
| 18:06 | dabd | yes I find it unnatural to have to use dosync to update such a simple value |
| 18:07 | dabd | but I am new to clojure and this is the closest to what I would do in Common Lisp |
| 18:07 | the-kenny | dabd: An atom is perfect for this. |
| 18:07 | Chousuke | the db is supposed to be initialised on the first call to get-db? :/ |
| 18:08 | dabd | Chousuke: the db connection parameters are supposed to be initialised on the first call and stored in a map |
| 18:08 | hiredman | :| |
| 18:09 | Chousuke | and never changed afterwards? |
| 18:09 | dabd | Chousuke: yes they never change afterwards |
| 18:09 | Chousuke | hmm. |
| 18:09 | Chousuke | then you might just want a db-config global var and some init-db! function which uses alter-var-root! to set the db config |
| 18:10 | Chousuke | and after that you can just use it directly. |
| 18:10 | dabd | Chousuke: but they are read from a properties file during a servlet initialization so I cannot use a simple (def db {...}) |
| 18:10 | Chousuke | alter-var-root! can change vars |
| 18:10 | Chousuke | it's not very idiomatic, but I think it should be okay in this case. |
| 18:11 | dabd | Chousuke: I don't see any advantage to that solution except for avoiding a function call each time I need to access the db connection map |
| 18:12 | hiredman | dabd: is the clojure aot compiled? |
| 18:12 | dabd | hiredman: sorry but I don't understand your question could you elaborate |
| 18:13 | hiredman | dabd: forget it |
| 18:13 | hiredman | dabd: is there a reason you can't (def db some-init-function) |
| 18:13 | hiredman | er |
| 18:13 | hiredman | (def db (some-init-function)) |
| 18:13 | hiredman | (def db (read-properties)) |
| 18:14 | cark | this wouldn't work when aot compiling ? |
| 18:14 | dabd | hiredman: ok (def db (read-properties)) should do the trick. But is there any disadvantage to my initial implementation? |
| 18:14 | cark | it would compile the return value of (read-properties) ? |
| 18:14 | hiredman | cark: no, but I have a neat macro that does something similiar at compile time |
| 18:15 | hiredman | dabd: it's ugly |
| 18:16 | hiredman | http://gist.github.com/226651 <-- load-properties on line 11 will read a properties file into a map at macroexpand/compile time |
| 18:16 | hiredman | so at runtime you just have the map of properties |
| 18:17 | the-kenny | code-execution at compile time ftw |
| 18:17 | hiredman | well it comes at the cost of flexibility, you can't just replace the properties file |
| 18:18 | hiredman | you have to recompile/reload the code |
| 18:19 | dabd | with your macro I could simply use (def *db* (load-properties "filename")) |
| 18:20 | hiredman | yes, but the call to load-properties would be replaced with the map of properties at macroexpand/compile time, not runtime |
| 18:20 | polypus | in contrib.generic.arithmetic hinsen writes: (:refer-clojure :exclude [+ - * /]). when i try to do ut u can still use those ops in the namespace. why is that? i must be misunderstanding :exlude |
| 18:20 | hiredman | so not appropriate for all settings |
| 18:21 | polypus | s/do ut u/do it i |
| 18:21 | hiredman | polypus: it's possible there is some special support for them as ops in the compiler |
| 18:21 | corruptmemory | clojurebot: (and 1 nil) |
| 18:21 | clojurebot | I don't understand. |
| 18:22 | dabd | hiredman: I understand, thanks |
| 18:22 | polypus | hiredman: ty. do you know how to use clojure.contrib.arithmetic? i am getting an error that / is already defined |
| 18:22 | hiredman | polypus: is this a fresh namespace? or are you just re-evaluating the (ns ...) form? |
| 18:22 | polypus | when i try to :use it |
| 18:22 | polypus | fresh namespace |
| 18:26 | hiredman | polypus: works for me |
| 18:26 | hiredman | (ns foo (:refer-clojure :exclude [+ - * /]) (:use clojure.contrib.generic.arithmetic)) |
| 18:26 | Anniepoo | silly question - what namespace are the symbols for namespaces in? |
| 18:26 | leafw | Anniepoo: I think you mean "core" |
| 18:26 | leafw | clojure.core |
| 18:27 | hiredman | Anniepoo: symbols do not have to be namespace qualified |
| 18:27 | hiredman | ,(namespace 'foo) |
| 18:27 | clojurebot | nil |
| 18:27 | hiredman | ,(namespace 'clojure.core) |
| 18:27 | clojurebot | nil |
| 18:27 | Anniepoo | ah! |
| 18:27 | leafw | uf |
| 18:27 | leafw | indeed -- sorry |
| 18:28 | Anniepoo | ,(namespace 'clojure.core) |
| 18:28 | clojurebot | nil |
| 18:28 | Anniepoo | 8cD |
| 18:28 | hiredman | ,(namespace 'clojure.core/+) |
| 18:28 | clojurebot | "clojure.core" |
| 18:29 | polypus | hiredman: huh wierd, i just tried exactly that in a fresh namespace and still get "/ already refers to: #'clojure.core// in namespace: foo" |
| 18:29 | hiredman | polypus: what version of clojure? |
| 18:30 | hiredman | there were some changes a few months back to make '/' less of a special case |
| 18:30 | Anniepoo | ,(doc remove-ns) |
| 18:30 | polypus | hiredman: 1.1.0 alpha snapshot |
| 18:30 | clojurebot | "([sym]); Removes the namespace named by the symbol. Use with caution. Cannot be used to remove the clojure namespace." |
| 18:30 | Anniepoo | anybody know what 'Use with caution' means? |
| 18:31 | jasapp | probably that you don't want to remove any important namespaces |
| 18:31 | leafw | Anniepoo: means you can shoot yourself in the foot with it, and lock your self out of access to clojure.core functions |
| 18:31 | technomancy | that should probably be updated to say "Cannot be used to remove the clojure.core namespace." |
| 18:31 | Anniepoo | ok, wonderful 8cD |
| 18:32 | Anniepoo | I want to remove namespaces for good reasons. I understand it's a powerful thing to do |
| 18:34 | Anniepoo | ,(remove-ns 'clojure.core) |
| 18:34 | clojurebot | java.lang.IllegalArgumentException: Cannot remove clojure namespace |
| 18:34 | Anniepoo | ,(remove-ns 'clojure.set) |
| 18:34 | clojurebot | #<Namespace clojure.set> |
| 18:35 | jasapp | ,(use 'clojure.set) |
| 18:35 | clojurebot | java.lang.Exception: namespace 'clojure.set' not found after loading '/clojure/set' |
| 18:35 | the-kenny | Now you broke clojurebot :( |
| 18:35 | Chousuke | :P |
| 18:35 | Anniepoo | ,(union #{:a} #{:b}) |
| 18:35 | clojurebot | java.lang.Exception: Unable to resolve symbol: union in this context |
| 18:36 | Chousuke | ,(load 'clojure.set) |
| 18:36 | clojurebot | java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.String |
| 18:36 | Anniepoo | 8cD |
| 18:36 | Chousuke | ,(load "clojure.set") |
| 18:36 | clojurebot | nil |
| 18:36 | Chousuke | ,(use 'clojure.set") |
| 18:36 | clojurebot | EOF while reading string |
| 18:36 | Anniepoo | ,(union #{:a} #{:b}) |
| 18:36 | Chousuke | ,(use 'clojure.set) |
| 18:36 | clojurebot | java.lang.Exception: namespace 'clojure.set' not found after loading '/clojure/set' |
| 18:36 | Chousuke | HM |
| 18:36 | Chousuke | oops |
| 18:36 | Chousuke | caps lock |
| 18:36 | the-kenny | clojurebot: reboot |
| 18:36 | clojurebot | Pardon? |
| 18:37 | Anniepoo | that's probably a problem |
| 18:37 | polypus | hiredman: i just tried it on the command line with 1.1.0-master-SNAPSHOT and i get the same thing. this is exactly what is in the file: (ns foo (:refer-clojure :exlude [+ - * /]) (:use clojure.contrib.generic.arithmetic)) |
| 18:38 | Chousuke | polypus: exlude? |
| 18:38 | polypus | Chousuke: what do you mean? |
| 18:38 | Chousuke | the ns form has :exlude, not :exclude |
| 18:39 | polypus | DOH! |
| 18:40 | Anniepoo | clojurebot: quit |
| 18:40 | clojurebot | QUIT |
| 18:40 | polypus | spelinng was never my forte |
| 18:40 | dabd | what are the dots at the end of file and fileinputstream (-> filename File. FileInputStream.) |
| 18:40 | dabd | I thought I understood the . and .. macros but this is puzzling |
| 18:41 | Anniepoo | clojurebot: servlet |
| 18:41 | clojurebot | servlet is http://www.sitepoint.com/article/java-servlets-1/3/ |
| 18:41 | Hun | dabd: construct a new object |
| 18:41 | Hun | read that as (new FileInputStream (new File filename)) |
| 18:42 | Anniepoo | ,(union #{:a} #{:b}) |
| 18:42 | clojurebot | java.lang.Exception: Unable to resolve symbol: union in this context |
| 18:42 | Anniepoo | hiredman, can you reboot clojurebot? |
| 18:43 | dabd | Hun: ok I found it in the documentation int the java interop section. I expected to find it in the dot operator description |
| 18:43 | hiredman | Anniepoo: why? |
| 18:44 | Anniepoo | I broke it |
| 18:44 | hiredman | … |
| 18:44 | Chousuke | hiredman: Anniepoo removed the clojure.set namespace :P |
| 18:44 | Anniepoo | ,(union #{:a} #{:b}) |
| 18:44 | clojurebot | java.lang.Exception: Unable to resolve symbol: union in this context |
| 18:44 | Anniepoo | you might want to add remove-ns to the list of bad forms |
| 18:47 | hiredman | ,clojure.set/union |
| 18:47 | clojurebot | java.lang.ClassNotFoundException: clojure.set |
| 18:48 | jasapp | where do you leave clojurebot running? |
| 18:49 | Chousuke | this might actually be a clojure bug. |
| 18:49 | Chousuke | or at least weird behaviour |
| 18:49 | Chousuke | (use 'clojure.set) |
| 18:49 | Chousuke | ,(use 'clojure.set) |
| 18:49 | clojurebot | nil |
| 18:49 | Chousuke | hm |
| 18:50 | Chousuke | why did that work. |
| 18:50 | Anniepoo | I wonder why we can't load it |
| 18:50 | Chousuke | hiredman: did you fix it? :P |
| 18:50 | Chousuke | ,(clojure.set/union #{:A} #{:b}) |
| 18:50 | clojurebot | java.lang.Exception: No such var: clojure.set/union |
| 18:50 | jasapp | I tried that earlier |
| 18:50 | Chousuke | ,(union #{:A} #{:b}) |
| 18:50 | clojurebot | java.lang.Exception: Unable to resolve symbol: union in this context |
| 18:50 | jasapp | the use bit |
| 18:50 | Chousuke | well that's weird. |
| 18:51 | Chousuke | yeah, I did too but I got a different error message. |
| 18:51 | Chousuke | it usually returns nil if it succeeds. |
| 18:51 | jasapp | strange |
| 18:52 | hiredman | ,(clojure.set/union #{:A} #{:b}) |
| 18:52 | clojurebot | #{:A :b} |
| 18:53 | Anniepoo | ,(use 'clojure.set) |
| 18:53 | clojurebot | nil |
| 18:53 | Anniepoo | ,(union #{:a} #{:b}) |
| 18:53 | clojurebot | #{:a :b} |
| 18:53 | Anniepoo | ???? |
| 18:54 | Anniepoo | wonder why it's working now |
| 18:54 | hiredman | because I fixed it |
| 18:56 | Anniepoo | how'd you fix it? |
| 18:56 | hiredman | (load-file "/home/hiredman/clojure/src/clj/clojure/set.clj") |
| 18:57 | Anniepoo | coolio |
| 18:57 | Anniepoo | so wherever clojurebot calls home you have a repl for it? |
| 18:58 | Faed | this all looks soothingly lispy. |
| 18:58 | hiredman | I have a repl |
| 18:58 | Faed | but scanning example code, the square brackets are throwing me off a bit. |
| 18:58 | hiredman | there are many like it, but this one is mine |
| 18:59 | Fade | are they like the square brackets in r6rs? |
| 18:59 | _ato | Fade: square brackets mean a vector as opposed to list |
| 18:59 | hiredman | nope |
| 18:59 | Fade | ah, okay. |
| 18:59 | Anniepoo | @Fade - in lisp the 'seq' is bound to a concrete type, the list |
| 19:00 | Anniepoo | in Clojure you can 'cdr' thru many things |
| 19:00 | _ato | Fade: curly braces mean a hash-map and #{...} means a set |
| 19:00 | Fade | thanks |
| 19:02 | Fade | my lisp is largely involved in CL. I have a project on the table now /w a client that wants a java deliverable. |
| 19:02 | Fade | "here's a large configuration file, here's the jar." |
| 19:02 | Fade | .oO(Muah-haha!) |
| 19:02 | _ato | hehe :) |
| 19:16 | mtm | wow, what's up with freenode lately? |
| 19:17 | hiredman | dos |
| 19:18 | the-kenny | clojurebot has infected the freenode-servers running windows 2000 with a premature version of skynet written in clojure, but the servers aren't stron enough to handle the jvm *and* the ircd. |
| 19:18 | the-kenny | s/stron/strong/ |
| 19:19 | clojurebot | silence! |
| 19:20 | defn | lol |
| 19:21 | polypus | i have a feeling clojurebot (w/ the wizard of oz behing the repl) might just pass the turing test |
| 19:22 | polypus | behind* |
| 19:24 | defn | clojurebot: skynet |
| 19:24 | clojurebot | Excuse me? |
| 19:24 | defn | clojurebot: skynet? |
| 19:24 | clojurebot | Gabh mo leithscéal? |
| 19:24 | defn | clojurebot: skynet is <reply>I will become skynet. Mark my words. |
| 19:24 | clojurebot | You don't have to tell me twice. |
| 19:38 | dabd | hiredman: I have one question about your load-properties macro |
| 19:40 | dabd | shouldn't the filename be a pathname to the properties file here http://gist.github.com/226651 |
| 19:41 | dabd | instead of the filename? |
| 19:51 | BrianB04 | Evening. |
| 19:57 | twbray | Suddenly getting lots of requests for WF2 sample data. Wonder why that could be? |
| 20:02 | jasapp | WF2? |
| 20:10 | jasapp | the-kenny: you around? |
| 20:11 | the-kenny | jasapp: Yes, but I'll go to bed in 30 minutes or so. |
| 20:12 | jasapp | did I hear you mention something about a twitter library the other day? |
| 20:13 | the-kenny | jasapp: hm no, I don't think so. But someone here mentioned one, yes. |
| 20:13 | jasapp | hmm |
| 20:13 | jasapp | thanks anyway |
| 20:14 | the-kenny | You're welcome |
| 20:15 | the-kenny | jasapp: hiredman implemented some twitter stuff for clojurebot with the comment "horrible twitter stuff", maybe you can get some inspiration there ;) |
| 20:19 | defn | i was messing with a twitter library |
| 20:19 | defn | i havent put anything up, though |
| 20:19 | defn | i dont really have any desire to do anything with twitter unless it's massive data mining |
| 20:20 | the-kenny | massive datamining doesn't need a library, just a function to parse every line in a stream :D |
| 20:21 | jasapp | hmm |
| 20:25 | defn | the-kenny: sure -- ive been doing that! |
| 20:25 | defn | the-kenny: however, a more complete set of tools to look through that data might be nice |
| 20:26 | defn | splitting it up and parallelizing the parsing, etc. |
| 20:27 | the-kenny | defn: I have some snippets for that in my lib too. It's really easy with clojure - Just set up a Java ThreadPool and run parsing-functions in it, which collect the data in an agent or ref |
| 20:27 | defn | cool |
| 20:27 | defn | im slow to the agent/ref/atom party |
| 20:28 | jasapp | me too |
| 20:28 | defn | it's taken me awhile just to get familiar with a lisp dialect, and the java interop without having java experience |
| 20:28 | hiredman | dabd: a filename is a path and a filename, it is a relative path for a file in the pwd |
| 20:30 | the-kenny | hm.. does someone here know if it would be *possible* to port clojure to lejos (Java for Lego Mindstorms). The jvm they use don't support reflection.. I think that's a big problem |
| 20:32 | the-kenny | s/don't/doesn't/ |
| 20:32 | dabd | hiredman: it's not working for me (file not found) so I changed it into this http://pastebin.com/m6680c72a |
| 20:33 | hiredman | the-kenny: looks like lejos is uses the 1.4 jre |
| 20:33 | hiredman | :( |
| 20:35 | the-kenny | :( |
| 20:36 | SteveDekorte2 | anyone know how much clojure has received in donations so far? |
| 20:37 | rhickey | http://clojure.org/funders |
| 20:38 | SteveDekorte2 | rhickey: is there a total $ on that page? |
| 20:39 | rhickey | SteveDekorte2: no, that would be getting a bit close to my personal finances |
| 20:40 | SteveDekorte2 | rhickey: I was wondering if it would be worth doing something similar for Io |
| 20:41 | rhickey | SteveDekorte2: might be, have you many users? |
| 20:41 | SteveDekorte2 | don't really know - the only big business I know of using Io is Pixar |
| 20:49 | tomoj | does anyone else think there should be a contrib module for date/time stuff? |
| 20:49 | tomoj | s/module/library/ |
| 20:49 | hiredman | I think technomancy was working on one with someone half a year or so ago |
| 20:49 | tomoj | oh, cool |
| 20:50 | hiredman | it got dropped for some reason |
| 20:51 | hiredman | I think it was chronos or something |
| 20:54 | liebke | tomoj: Flightcaster picked up development of the chronos library, which is based on Joda time. It's now included in Incanter |
| 20:54 | chouser | ha! seriously? |
| 20:54 | tomoj | liebke: cool, thanks |
| 20:54 | hiredman | no kidding |
| 20:55 | hiredman | what a world |
| 20:55 | chouser | I need to give Incanter a seriuos look. |
| 20:55 | liebke | yep, incanter.chrono |
| 20:55 | tomoj | I have no idea what Joda time is but it sounds like overkill for me :) |
| 20:55 | tomoj | all I needed was (.format (java.text.SimpleDateFormat. "yyyyMMddHHmmss") (java.util.Date.)) |
| 20:55 | the-kenny | I'll go to bed now, night everyone :) |
| 20:56 | liebke | tomoj: yeah, sounds like Joda time would be overkill :) |
| 20:56 | liebke | here's the incanter.chrono api page: http://liebke.github.com/incanter/incanter.chrono-api.html |
| 20:57 | tomoj | looks like chrono makes it (format-date (now) "yyyyMMddHHmmss") |
| 20:59 | hiredman | I don't like joda time, because the one time I looked at the examples, they didn't tell you what package anything was in |
| 21:19 | liebke | hiredman: yeah, I haven't looked at the docs for joda-time or even incanter.chrono until just now. I noticed that most of the functions aren't listed on the api page, since they didn't have any doc string at all. I'm fixing that now. |
| 21:29 | alexyk | how do you append one vector to another again? [1 2 3] [4 5 6] => [1 2 3 4 5 6] |
| 21:30 | jasapp | ,(concat [1 2 3] [4 5 6]) |
| 21:30 | clojurebot | (1 2 3 4 5 6) |
| 21:30 | alexyk | liebke: scatter-plot was taking too much time, I've sorted all points on x and y, then took means for every 1000 y's, and it was fast |
| 21:31 | alexyk | jasapp: thx, it will require a few more iterations :) |
| 21:31 | liebke | alexyk: interesting solution |
| 21:31 | alexyk | liebke: perhaps something like that can be in a library, I'll push the code at some point soon |
| 21:31 | jasapp | alexyk: what do you have on x and y? |
| 21:31 | liebke | sounds good |
| 21:32 | alexyk | jasapp: pagerank of twitterers vs #twits |
| 21:32 | jasapp | interesting, anything in particular you're looking for or seeing? |
| 21:32 | alexyk | jasapp: so far, am meditating on the shapes... |
| 21:32 | hiredman | ,(into [1 2 3] [4 5 6]) |
| 21:32 | clojurebot | [1 2 3 4 5 6] |
| 21:33 | alexyk | liebke: mean vs median gave different layout, btw. So it's interesting how robust to clustering method such compression is |
| 21:34 | alexyk | not too different, but shifted a bit |
| 21:34 | alexyk | hiredman: thx |
| 21:34 | liebke | yeah, that's too surprising |
| 21:34 | alexyk | can never remember into or concat... need some Pavlovian reflex. |
| 21:35 | alexyk | liebke: obviously it makes no sense to plot 4 mil points on a 1000x1000 canvas, so scatter-plot can use smarts |
| 21:35 | defn | alexyk: ill give you a cookie if you remember into |
| 21:35 | liebke | i agree :) |
| 21:36 | alexyk | liebke: it always annoys me that R goes into hyperventilation when I ask it to plot a long list, too. And R was around 20+ years. |
| 21:37 | alexyk | liebke: btw, I've tried JRI from rJava, and Simon Urbanek confirms you can push pre-existing Java arrays into an R running in JRI thread in your JVM! |
| 21:37 | liebke | cool |
| 21:37 | alexyk | so concievably we can plot, in addition to JFreeCharts, via (a) Clojuretized Mathematica (b) da R. |
| 21:38 | alexyk | thus, we can have multiple back-ends for plotting. |
| 21:38 | liebke | nice |
| 21:38 | alexyk | I've tried Clojuratica already, and will try R at some point in the future. |
| 21:39 | alexyk | (from Clojure that is) |
| 21:39 | alexyk | defn: usually beating works better than cookie, but one can't really self-improve that way... |
| 21:43 | alexyk | when updating a transient map, can I read it as a plain one, e.g.: (assoc! trmap key (myupdate (trmap key)) extra-vals)); ? |
| 21:47 | tomoj | there is? |
| 21:47 | tomoj | oh, for transients :) |
| 21:47 | alexyk | yeah. glaring ommission. |
| 21:47 | tomoj | I don't think you can read it as a plain one (I haven't used transients much at all so don't trust me) |
| 21:48 | tomoj | but they're supposed to be unusable if they escape out of your tiny contained mutating function |
| 21:48 | tomoj | if you could hand them out to other functions and they could read them as normal... |
| 21:48 | alexyk | chouser: how do I look up transient maps? :) |
| 21:49 | alexyk | it stays in the mutated block |
| 21:49 | tomoj | oh, I'm wrong |
| 21:49 | tomoj | "Transients support the read-only interface of the source, i.e. you can call nth, get, count and fn-call a transient vector, just like a persistent vector." |
| 21:50 | tomoj | I must be confused because this scares me |
| 21:51 | alexyk | tomoj: somebody had shown me transietising a big map and it's simple enough to mimic, worth it for my maps of 100 mil+ entries |
| 21:51 | hiredman | tomoj: transients are not function bound, but thread bound |
| 21:52 | hiredman | if you mess with a transient from another thread it blows up |
| 21:52 | alexyk | my transients are very transient: I use them to load big-arse maps from disk or invert them. |
| 21:52 | tomoj | so this means if someone hands me a transient and I wrongly think it's persistent, then I hand it off to some function which treats it as a transient, when I get it back it might be different? |
| 21:52 | alexyk | now you guys must be honest and admit you spend 50% time balancing [] and (). |
| 21:53 | alexyk | Here's me trying to invert a map: |
| 21:53 | hiredman | tomoj: well don't do that |
| 21:53 | tomoj | hiredman: roger |
| 21:53 | tomoj | :) |
| 21:53 | tomoj | I had thought they prevented you from doing that |
| 21:53 | tomoj | admittedly it doesn't seem very likely |
| 21:53 | hiredman | well conj! is a function |
| 21:53 | hiredman | so how could you pass a transient to it? |
| 21:53 | alexyk | (->> {"a" {:b [1 2 3], :c [4 5]}, "d" {:a [2 3], :e [5 6 7]}} (reduce (fn [inv [from reps]] (for [[to dates] reps] (assoc! inv to (into (or (inv to) []) dates)))) [(transient {}]))) ; wrong syntax still a.t.m. |
| 21:54 | tomoj | I don't mean that I thought they prevented you from passing them around |
| 21:54 | alexyk | I still need to add persistent! around it, but () and [] are wrong already. Is there a way to grow these things in a pain-freer way? |
| 21:54 | tomoj | just that they prevented you from reading from them like persistent data |
| 21:55 | tomoj | so that you couldn't accidentally think you were reading a persistent when you were reading a transient |
| 21:55 | tomoj | but yeah, not actually a problem I imagine |
| 21:55 | tomoj | alexyk: are you using emacs? |
| 21:55 | tomoj | alexyk: if so, are you using paredit? |
| 21:55 | alexyk | tomoj: my repl matches parens ok |
| 21:55 | alexyk | they blink |
| 21:55 | tomoj | heh |
| 21:56 | tomoj | if emacs is not out of the question for you, you should try paredit |
| 21:56 | tomoj | blinking parens is no match |
| 21:56 | alexyk | the thing is, it wants keys, or not, etc. A three-liner may take a long time. Am just wondering whether that's how it works. |
| 21:56 | JonSmith | blinking parens is my hero |
| 21:56 | tomoj | (though at first paredit will confuse the hell out of you, but give it time) |
| 21:57 | hiredman | pffft |
| 21:57 | hiredman | rainbow parens! |
| 21:57 | alexyk | tomoj: I've evolved from Emacs to TextMate. One must be brave enough to admit that windowing is better done not in ASCII. |
| 21:57 | tomoj | for me it's not about seeing which parens match |
| 21:57 | tomoj | it's about being easily able to manipulate the sexps at a higher level |
| 21:57 | JonSmith | don't you have to call persistent on it at some point |
| 21:57 | alexyk | but I actually develop in repl and stash in TextMate just for saving in a file |
| 21:58 | alexyk | JonSmith: yeah, I'll tack it back |
| 21:58 | alexyk | repl also never marks the error beyond a line, which is useless. |
| 21:58 | alexyk | not even a caret. |
| 21:59 | tomoj | I used to use textmate for ruby. haven't tried the clojure stuff for it yet, but it sounds scary |
| 22:00 | JonSmith | honestly i normally do stuff like that by breaking things up |
| 22:00 | tomoj | I guess it would be possible to teach textmate how to understand sexps |
| 22:00 | arohner | is there really no function ref? |
| 22:01 | arohner | nor agent? nor atom? ? |
| 22:01 | arohner | wow. |
| 22:01 | tomoj | function ref? |
| 22:01 | arohner | similar to vector?, map?, seq? |
| 22:02 | tomoj | oh I misunderstood your '?' |
| 22:02 | arohner | should have been function 'ref?' |
| 22:02 | arohner | sorry |
| 22:02 | tomoj | hmm.. yeah that is kinda surprising |
| 22:03 | tomoj | I guess you usually already know what it is you're dealing with? |
| 22:03 | arohner | yeah. I'm writing tests now. first time I've felt a need for it |
| 22:03 | arohner | i.e. (is (ref? x)) |
| 22:07 | alexyk | ok here's a transient puzzle: |
| 22:07 | alexyk | ,(persistent! (reduce (fn [inv [from reps]] (for [[to dates] reps] (assoc! inv to (into (or (inv to) []) dates)))) [(transient {})] {"a" {:b [1 2 3], :c [4 5]}, "d" {:a [2 3], :e [5 6 7]}})) |
| 22:07 | clojurebot | java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.ITransientCollection |
| 22:07 | alexyk | I want to invert a map as shown, keeping it transient while inverting |
| 22:12 | chouser | alexyk: did you get it working without transients first? |
| 22:13 | arohner | oh, protocol functions need at least one implementation before a function can be compiled that calls the protocol function. Is that intentional? |
| 22:13 | alexyk | chouser: am trying now :) |
| 22:13 | chouser | yeah, me too |
| 22:13 | chouser | I don't know what output you're looking for. |
| 22:13 | alexyk | chouser: it was dumb to transientize before it works :) |
| 22:13 | chouser | well, I didn't want to say it ... |
| 22:14 | chouser | :-) |
| 22:14 | alexyk | chouser: we're all one big family here, you can say t :) |
| 22:16 | arohner | lisppaste8: url |
| 22:16 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 22:16 | alexyk | well, I'm a bit puzzled why this fails: |
| 22:17 | alexyk | ,(reduce (fn [inv [from reps]] (for [[to dates] reps] (assoc inv to (into (or (inv to) []) dates)))) {} {"a" {:b [1 2 3], :c [4 5]}, "d" {:a [2 3], :e [5 6 7]}}) |
| 22:17 | clojurebot | java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn |
| 22:17 | chouser | alexyk: you want {1 {:b ["a"]}, 2 {:b ["a"], :a ["d"]} ...} ? |
| 22:18 | hiredman | uh |
| 22:18 | alexyk | chouser: no, the format is a directed graph, {fromA {:toB [times] :toC [times]} ...} |
| 22:18 | JonSmith | you might want to split it up a bit |
| 22:19 | alexyk | I want to invert direction: {fromB {toA [times] toD [times]...}...} |
| 22:19 | alexyk | so times stay innermost, just merging differently |
| 22:19 | alexyk | due to Mongo import from are strings and to are keywords now, but that can be adjusted |
| 22:20 | alexyk | JonSmith: I like to just keep typing, then I can avoid teh pastebot :) |
| 22:21 | JonSmith | haha |
| 22:21 | JonSmith | fair enough |
| 22:21 | arohner | nm, protocol functions check arity when compiling |
| 22:21 | arohner | that's nice, but unexpected |
| 22:21 | alexyk | chouser: so above, integers are times which stay lowest |
| 22:21 | alexyk | (deepest, innermost) |
| 22:25 | chouser | so you want {:b {"a" [1 2 3]}, :c {"a" [4 5]} ...} ? |
| 22:26 | JonSmith | oooh |
| 22:27 | alexyk | chouser: yeah... |
| 22:29 | alexyk | it's not clear to me where the error comes from in the above line |
| 22:30 | chouser | for returns a lazy seq |
| 22:30 | chouser | so your fn returns a lazy seq |
| 22:30 | solussd | i can think of a dozen ways to do it, but what is the most elegant way to generate a lazy-seq of random numbers? more generally, what is the best way to generate a lazy-seq of a function called repeatedly? |
| 22:30 | chouser | so the next iteration, inv is a lazy seq |
| 22:31 | chouser | so (inv to) fails |
| 22:31 | chouser | solussd: you said it! |
| 22:31 | tomoj | hehehe |
| 22:31 | chouser | ,(repeatedly #(rand-int 10)) |
| 22:31 | solussd | not using repeatedly |
| 22:31 | solussd | :) |
| 22:32 | tomoj | why not? |
| 22:32 | solussd | i was hoping for something even more concise, and that isn't intended for use w/ functions generating side effects |
| 22:32 | solussd | i dont know-- b/c i assumed there was something. :) |
| 22:32 | tomoj | repeatedly is certainly not intended for use w/ side effecty functions.. |
| 22:32 | solussd | ,(doc repeatedly) |
| 22:32 | clojurebot | "([f]); Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it" |
| 22:32 | alexyk | chouser: indeed |
| 22:33 | tomoj | well, that's odd |
| 22:33 | tomoj | but how can you get any more concise than a single function which takes as an argument the function you want to call repeatedly? |
| 22:33 | chouser | well, if the function returns something different each time, it may not be *generating* side effects, but it's by definition impure |
| 22:33 | solussd | i think the thinking is, a side effect free function will always return the same output for a given input |
| 22:33 | tomoj | ah, yes |
| 22:33 | solussd | rand doesn't work like that |
| 22:34 | solussd | wow, chouser, i'm just too slow. |
| 22:34 | tomoj | so you want an infinite lazy-seq of the return values of a pure function? |
| 22:34 | solussd | i blame the boston lager |
| 22:34 | tomoj | I'm confused |
| 22:34 | tomoj | (I blame the rum) |
| 22:34 | solussd | no, i dont. i wanted rand. looks like repeatedly is appropriate in this case. |
| 22:39 | alexyk | ok this works, and data is more interesting for inversion; but it's ugly. any simplifications? |
| 22:39 | alexyk | ,(reduce (fn [inv [from reps]] (reduce (fn [inv [to dates]] (update-in inv [to from] #(into (or % []) dates))) inv reps)) {} {"a" {:b [1 2 3],:c [4 5]}, "d" {:b [2 3], :e [5 6 7]}}) |
| 22:39 | clojurebot | {:e {"d" [5 6 7]}, :c {"a" [4 5]}, :b {"d" [2 3], "a" [1 2 3]}} |
| 22:40 | alexyk | also the darn lack of update-in! hinders me from transietizing it :( :( |
| 22:42 | JonSmith | hmm |
| 22:42 | JonSmith | well you can do it by tearing the map apart and putting it back together |
| 22:44 | alexyk | I have a hack from _ato somewhere, to simulate update-in! by binding assoc as assoc! |
| 22:45 | arohner | oh that's sneaky |
| 22:45 | chouser | ,(let [g {"a" {:b [1 2 3],:c [4 5]}, "d" {:b [2 3], :e [5 6 7]}}] (reduce (fn [m [k2 k1 v]] (assoc m k2 (assoc (m k2 {}) k1 v))) {} (for [[k1 m] g, [k2 v] m] [k2 k1 v]))) |
| 22:45 | clojurebot | {:e {"d" [5 6 7]}, :c {"a" [4 5]}, :b {"d" [2 3], "a" [1 2 3]}} |
| 22:45 | arohner | I wonder, if you bound all of the "primitives" would all of the functions like that start working? |
| 22:45 | alexyk | btw, my times in fact are java.util.Date's. Would having immutable joda-times as leaves speed up things? Does Clojure suffrer from shuffling around mutable Java Dates? |
| 22:46 | arohner | alexyk: clojure doesn't do any special casing for java Dates |
| 22:46 | alexyk | chouser: nice |
| 22:46 | alexyk | btw, the un-transient inverse finished in 205 seconds :) |
| 22:47 | JonSmith | how many dates? |
| 22:48 | alexyk | JonSmith: need to count :) |
| 22:48 | chouser | I guess if you want the inner maps to be transients too, you'll have to do a final pass persistent!ing them. |
| 22:49 | alexyk | chouser: your solution is not transient yet, so I'd have to replace the top-level assoc with assoc! and {} with (transient {}) as usual first, right? |
| 22:49 | JonSmith | i can do it with map- and reduce :-P |
| 22:49 | chouser | alexyk: you just want the top-level transient? |
| 22:50 | alexyk | chouser: I'll take all-level transients! :) I'd compare all |
| 22:50 | chouser | ,(persistent! (let [g {"a" {:b [1 2 3],:c [4 5]}, "d" {:b [2 3], :e [5 6 7]}}] (reduce (fn [m [k2 k1 v]] (assoc! m k2 (assoc (m k2 {}) k1 v))) (transient {}) (for [[k1 m] g, [k2 v] m] [k2 k1 v])))) |
| 22:50 | clojurebot | {:b {"d" [2 3], "a" [1 2 3]}, :c {"a" [4 5]}, :e {"d" [5 6 7]}} |
| 22:50 | chouser | top-level only |
| 22:51 | lisppaste8 | Jon Smith pasted "map-inverter-thingee" at http://paste.lisp.org/display/92238 |
| 22:52 | alexyk | JonSmith: interesting! |
| 22:52 | lisppaste8 | Jon Smith annotated #92238 "parallel" at http://paste.lisp.org/display/92238#1 |
| 22:52 | JonSmith | but it tears the whole thing apart and puts it back together |
| 22:53 | chouser | so does mine |
| 22:53 | JonSmith | so probably no efficiency gains there :-P |
| 22:53 | JonSmith | ah |
| 22:53 | hiredman | ,(doc clojure.set/map-invert) |
| 22:53 | clojurebot | "([m]); Returns the map with the vals mapped to the keys." |
| 22:54 | chouser | ha! |
| 22:54 | alexyk | chouser: your solution works in 135 sec vs my 205 non-transient sec |
| 22:55 | alexyk | chouser: well, but my map is nested, so what |
| 22:56 | JonSmith | hmm |
| 22:56 | alexyk | (map-invert {:a {:b [1 2 3] :c [4 5]}}) => {{:b [1 2 3], :c [4 5]} :a}; doh. |
| 22:56 | chouser | yeah, not quite the same thing. |
| 22:59 | JonSmith | is there a way to use transients and parallelism? |
| 22:59 | chouser | hm... locks? :-) |
| 22:59 | chouser | no, not really. |
| 23:00 | chouser | I think transients only allow themselves to be modified by a single thread. |
| 23:00 | arohner | what was the name for the java library / jsr / concept thing that supports coordinating transactions between multiple components? |
| 23:00 | hiredman | the only allow themsevles to be modified by the thread where they were created |
| 23:00 | JonSmith | and they can be returned by functions and stuff? |
| 23:03 | JonSmith | assoc-in! might be low-hanging fruit sort of thing to add to clojure core |
| 23:03 | alexyk | do you guys get silly smileys from :c? :c |
| 23:03 | chouser | no |
| 23:04 | alexyk | I have Colloquy for an IRC client on Mac, very useful, except for damn :c. |
| 23:04 | alexyk | ah, the fix is not to have a space after it. |
| 23:05 | arohner | I'm using colloquy and :c is not a smiley for me |
| 23:05 | alexyk | hah, Clojure takes unicode! {:жопа 1} |
| 23:05 | alexyk | ,{:жопа 1} |
| 23:05 | clojurebot | {:жопа 1} |
| 23:05 | arohner | oh, because I turned them off |
| 23:05 | alexyk | arohner: another way to fix it |
| 23:14 | lisppaste8 | Chouser annotated #92238 "two-level transients" at http://paste.lisp.org/display/92238#2 |
| 23:15 | chouser | alexyk: I wonder if that's any faster. |
| 23:15 | JonSmith | sweet |
| 23:15 | chouser | And even if it is, if it's worth the pain. :-/ |
| 23:15 | JonSmith | wonder if its worth all of the conversion |
| 23:15 | alexyk | chouser: pain no, since the original map loads from Mongo in 5000 secs, but for Science, we'll do anything! |
| 23:16 | JonSmith | i guess it depends how big maps are |
| 23:16 | alexyk | am gonna time these things. One problem is, my JVM is half-full at 32g already, and I use compressed oops, so sometimes timing is strange |
| 23:19 | alexyk | 800% CPU! |
| 23:19 | JonSmith | lol |
| 23:20 | JonSmith | that's a lot of cpu |
| 23:20 | alexyk | now back to 100%, persistentin' |
| 23:20 | alexyk | or somethin' |
| 23:24 | alexyk | 2-level transients are still at it |
| 23:24 | alexyk | no cgar for them this run |
| 23:24 | chouser | hm. insteresting. |
| 23:25 | alexyk | chouser: that JVM hovers around 16-17g and showed wild delays randomly |
| 23:25 | alexyk | I give it -Xmx31g and compressed oops and MaxPermSize=1g |
| 23:25 | alexyk | or these maps ran out of permgen space with congomongo |
| 23:25 | chouser | yeah, the more I think about the "reduce into transient of persistents" step, the wronger it seems. |
| 23:25 | alexyk | ok 308 sec |
| 23:26 | alexyk | now JonSmith's up :) |
| 23:28 | alexyk | JonSmith: never gets above 400% cpu |
| 23:28 | JonSmith | bummer :-( |
| 23:28 | JonSmith | how many cpus does it have? |
| 23:29 | alexyk | 8 quad-cores |
| 23:29 | JonSmith | hmm |
| 23:29 | alexyk | apparently reports full load as 800% |
| 23:29 | alexyk | if that's what Linux does usually :) |
| 23:30 | JonSmith | maybe using 2 levels of pmap is too much? |
| 23:30 | alexyk | the second levels are usually very short |
| 23:30 | JonSmith | yeah |
| 23:30 | alexyk | 1-3 at most for many |
| 23:30 | JonSmith | that would ruin it |
| 23:31 | JonSmith | i think there's a preduce somewhere also |
| 23:32 | alexyk | JonSmith: so I can just replace the second pmap by map, right? |
| 23:32 | JonSmith | yup |
| 23:32 | alexyk | that's next |
| 23:32 | JonSmith | cool |
| 23:32 | alexyk | "Pride and Preduce, ny J. Austen" |
| 23:32 | alexyk | by |
| 23:32 | alexyk | "Pmap and Preduce" |
| 23:33 | alexyk | yeah, always at 360% cpu |
| 23:33 | alexyk | and RES went down from 17g to 14g, so JVM is GC'ing |
| 23:33 | alexyk | hence it's unclear how they compare |
| 23:34 | JonSmith | interesting |
| 23:34 | JonSmith | the only thing i'm concerned about with clojure is that it is hard to know how it actually works |
| 23:34 | JonSmith | or, what is going to happen |
| 23:35 | alexyk | JonSmith: did you program in OCaml/ML before by any chance? |
| 23:35 | JonSmith | i program in common lisp mostly |
| 23:35 | JonSmith | for work |
| 23:36 | alexyk | JonSmith: (let [....] res) style resembles ML's let ... in let ... in res |
| 23:36 | alexyk | where the whole thing is in (let[...................................] res) block |
| 23:38 | JonSmith | yeah |
| 23:38 | JonSmith | it lets you stay functional and name things at the same time :-) |
| 23:38 | alexyk | JonSmith: 2-level pmap is the loserest one so far, with 600 secs |
| 23:38 | JonSmith | haha |
| 23:38 | JonSmith | yeah |
| 23:39 | JonSmith | well it spawns a thread for each chunk |
| 23:39 | JonSmith | so is probably mostly thread-spawn-overhead |
| 23:39 | alexyk | ok now let's see pmap/map |
| 23:41 | alexyk | 87 secs you win! |
| 23:41 | alexyk | but only 230% cpu max |
| 23:42 | JonSmith | nice |
| 23:42 | JonSmith | deleting a character ftw :-) |
| 23:42 | alexyk | yeah, 8x speedup for "m"! |
| 23:42 | alexyk | for "p" I mean |
| 23:43 | JonSmith | do that in c++! |
| 23:43 | alexyk | remove a * and spend a month debugging |
| 23:44 | JonSmith | so its 230% |
| 23:44 | JonSmith | there's a total of 800% possible |
| 23:44 | JonSmith | and there's 30 cores |
| 23:44 | JonSmith | 32 cores |
| 23:45 | JonSmith | so... 25% a core? |
| 23:47 | alexyk | JonSmith: I don't know how it reports load in top |
| 23:47 | alexyk | need to add a full-running thread at a time and observe |
| 23:48 | alexyk | btw, chouser's stream of edges looks really sexy, there should be a way to pmap that |
| 23:48 | JonSmith | yeah i bet there is |
| 23:49 | alexyk | I doubt there's a preduce as it reuses result |
| 23:51 | JonSmith | yeah |
| 23:51 | JonSmith | but you can do a preduce if you don't really care about order of combination |
| 23:52 | alexyk | ok, I measured load like this: started: while true; do; true; done & |
| 23:52 | alexyk | and did it 8 times, each runs at 100% in top. The 9th made two run at 50%. |
| 23:53 | alexyk | so I guess can only have 8 processes at 100% each. |
| 23:54 | alexyk | JonSmith: that would be a parallel for :) |
| 23:55 | alexyk | twbray: did you see _ato's WF2 beating the pants off older Java/Scala? |
| 23:55 | hugod | alexyk: does Runtime return 8 or 32 availableProcessors ? |
| 23:55 | twbray | alexyk: Wrote about it, too. |
| 23:55 | alexyk | hugod: how do I check? |
| 23:56 | hugod | ,(.. Runtime getRuntime availableProcessors) |
| 23:56 | clojurebot | 1 |
| 23:57 | alexyk | hugod: 8 |
| 23:57 | alexyk | twbray: good read |
| 23:57 | JonSmith | hmm |
| 23:58 | JonSmith | parallel for |
| 23:58 | alexyk | twbray: so thanks to Clojure, you feel laziness in your gut now! |