2009-03-26
| 00:09 | Puzzler | So I'm writing a long piece of code, and I'm starting to get annoyed with the need to either forward declare functions, or relocate things in a less readable order. I recall a discussion about a way to alter this behavior. Anyone remember how to do that? |
| 00:38 | cconstantine | Is there anyway to iterate over a map and create a new map... something like (map ...) that returns another map instead of a list |
| 00:41 | durka42 | there's a function i wrote :) |
| 00:41 | cconstantine | :P |
| 00:43 | lisppaste8 | durka42 pasted "mapmap" at http://paste.lisp.org/display/77618 |
| 00:44 | durka42 | Clojure=> (mapmap str + {"a" 1 "b" 2} {"c" 0.5 "d" 0.1}) |
| 00:44 | durka42 | {"bd" 2.1, "ac" 1.5} |
| 00:48 | durka42 | Clojure=> (mapmap (comp keyword (partial apply str) #(map name [%1 %2])) + {:a 1 :b 2} {:c 0.5 :d 0.1}) |
| 00:48 | durka42 | {:bd 2.1, :ac 1.5} |
| 00:48 | durka42 | :) |
| 00:50 | cconstantine | I'm gonna have to spend some time understanding that |
| 00:51 | durka42 | comp is like nesting the functions ((comp a b c) ...) => (a (b (c ...))) |
| 00:51 | cconstantine | you didnt use comp |
| 00:51 | cconstantine | oh, your use of it |
| 00:52 | cconstantine | not that, the actual defn of mapmap |
| 00:52 | durka42 | oh you meant the function itself |
| 00:52 | cconstantine | it creates a list of keys, values then zips it... ok |
| 00:52 | durka42 | imagining that kf == vf == identity might help trace through it |
| 00:53 | cconstantine | yeah, I got it |
| 01:17 | nascent16 | is there a non-lazy form of concat? |
| 01:19 | nascent16 | nevermind, the lazy one works fine :) |
| 01:21 | cconstantine | lazy is generally good. if you need to force it to evaluate you can always (last ...) it |
| 01:22 | nascent16 | yeah, my question is actually a bit more naive |
| 01:22 | cconstantine | no probs |
| 01:22 | nascent16 | ,(+ (concat [3, 4] [5,6])) |
| 01:22 | clojurebot | java.lang.ClassCastException |
| 01:23 | nascent16 | i want to use the concatenation of the vectors as the argument to + |
| 01:23 | cconstantine | Is there anyway to give multiple argument list to defmacro like you can to defn? I want to make a macro that accepts one argument (the expression to evaluate), and an optional identifier (if one isn't specified I can just use the string version of the unevaluated expression) |
| 01:23 | cconstantine | what do you want that to return? |
| 01:24 | nascent16 | (+ 3 4 5 6) |
| 01:24 | clojurebot | *suffusion of yellow* |
| 01:24 | nascent16 | ,(+ 3 4 5 6) |
| 01:24 | clojurebot | 18 |
| 01:24 | cconstantine | ,(reduce + [3 4] [5 6]) |
| 01:24 | clojurebot | java.lang.ClassCastException: clojure.lang.LazilyPersistentVector cannot be cast to java.lang.Number |
| 01:24 | cmvkk | cconstantine, you can use multiple arities in defmacro just like in defn. |
| 01:25 | cconstantine | ,(reduce + (concat [3 4 ] [5 6])) |
| 01:25 | clojurebot | 18 |
| 01:25 | nascent16 | cmvkk: I've had trouble doing that in the past, is it exactly the same? |
| 01:25 | nascent16 | nice |
| 01:25 | nascent16 | thank cconstantine |
| 01:25 | nascent16 | *thanks |
| 01:25 | cconstantine | cmvkk: I had problems with that a few minutes ago |
| 01:25 | cmvkk | i think defmacro is really just a defn that also alters some metadata. |
| 01:25 | cmvkk | so it should be exactly the same. |
| 01:25 | cconstantine | nascent16: :) |
| 01:26 | cconstantine | cmvkk: it works like that now |
| 01:26 | replaca | durka42: how is mapmap useful if you don't know a priori the order of keys? |
| 01:26 | cconstantine | so, yeah |
| 01:26 | cmvkk | also, this is the second time i've seen someone suggest using 'last' to force eval a lazy sequence. |
| 01:26 | cmvkk | isn't that what doall is for? |
| 01:27 | cmvkk | or is it different in some way? |
| 01:27 | nascent16 | ,(doc doall) |
| 01:27 | clojurebot | "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time." |
| 01:27 | cconstantine | yup, doall sounds better than last |
| 01:27 | cmvkk | also |
| 01:27 | cmvkk | ,(doc dorun) |
| 01:27 | clojurebot | "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil." |
| 01:28 | durka42 | replaca: i suppose it's useful for the same reason as map -- if you need to do something to each element, like increment or build a database query, or whatever |
| 01:28 | nascent16 | so i lied a little bit, my example was too simple and i don't think reduce will work for what i'm actually doing |
| 01:28 | nascent16 | i have two lists of agents, and i want to (await) all of them |
| 01:29 | replaca | durka42: but you're examples were combing elements from each map, does this make sense? |
| 01:29 | cconstantine | I used mapmap (well, extracted part of it) to convert a (ref {k (ref v) k2 (ref v2)) structure into a {k v k2 v2} structure |
| 01:29 | nascent16 | so i want to append the lists and pass the appended list as the arguments to await |
| 01:29 | durka42 | oh, i see what you mean |
| 01:30 | replaca | cconstantine: yeah, that usage makes sense to me (though I've just used a lambda with map for that) |
| 01:30 | durka42 | i guess it is more useful with maps that come from sorted-map |
| 01:30 | durka42 | ,(sorted-map :a 1 :b 2) |
| 01:30 | clojurebot | {:a 1, :b 2} |
| 01:30 | durka42 | ,(= {:a 1 :b 2} (sorted-map :a 1 :b 2)) |
| 01:30 | clojurebot | true |
| 01:31 | durka42 | ,(= {:b 2 :a 1} (sorted-map :a 1 :b 2)) |
| 01:31 | clojurebot | true |
| 01:31 | durka42 | interesting |
| 01:31 | nascent16 | maps are sorted by default? |
| 01:31 | durka42 | no |
| 01:31 | cconstantine | replaca: I did a (zipmap (keys the-map) (vals ...)) (wel, something similar |
| 01:31 | durka42 | ,(sorted? {:a 1 :b 2}) |
| 01:31 | clojurebot | false |
| 01:31 | nascent16 | hm |
| 01:31 | replaca | no, I think = just checks to see if they have the same elements |
| 01:31 | durka42 | http://clojure.org/data_structures#toc17 |
| 01:31 | cconstantine | I noticed unsorted maps produce keys and values with keys/vals in a random order, but the keys and vals were in the same order |
| 01:31 | durka42 | that paragraph is kind of dense |
| 01:32 | replaca | that is for map a and map b, is (= (count a) (count b)) and foreach element in a is it also in b |
| 01:32 | replaca | yeah, small maps are order by insertion order |
| 01:32 | replaca | ,(class {:a 1}) |
| 01:32 | clojurebot | clojure.lang.PersistentArrayMap |
| 01:32 | replaca | that's it: array maps! |
| 01:33 | cconstantine | so, should (zip-map (keys the-map) (vals the-map)) produce a map that is equal to the-map? |
| 01:33 | replaca | I think so |
| 01:34 | durka42 | ,(let [m (apply hash-map (interleave (range 1000) (range 1000 2000)))] (= m (zipmap (keys m) (vals m)))) |
| 01:34 | clojurebot | true |
| 01:35 | cconstantine | fantastic |
| 01:35 | durka42 | clojurebot fourths it |
| 01:35 | cconstantine | it's true once so it shall always be true |
| 01:35 | durka42 | computer science be damned |
| 01:35 | cconstantine | hehe |
| 01:36 | cconstantine | (defn multiple [x y] (+ x y)) ; works for (multiple 2 2), therefore it's good to go |
| 01:36 | durka42 | CS: if we can find a test case that doesn't work, it is incorrect. software engineering: if it passes the unit tests, it's correct! |
| 01:37 | durka42 | ;) |
| 01:37 | cconstantine | :0 |
| 01:37 | cmvkk | good enough for government work, as they say. |
| 01:37 | cconstantine | indeed |
| 01:38 | nascent16 | ok, this argument expansion thing is confusing me |
| 01:38 | durka42 | well, now i really am |
| 01:41 | durka42 | but i can't leave without the obligatory xkcd... http://xkcd.org/221/ |
| 01:43 | nascent16 | ah! |
| 01:43 | nascent16 | ,(doc apply) |
| 01:43 | clojurebot | "([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq." |
| 01:43 | nascent16 | exactly what i'm looking for |
| 02:12 | hiredman | ~def c.l.Compiler |
| 02:14 | hiredman | ~def load-file |
| 06:30 | AWizzArd | clojurebot: max people |
| 06:31 | clojurebot | max people is 164 |
| 06:55 | djpowell | what is the #_ macro for exactly? |
| 06:59 | Cark | ,(do (print "hello") #_(print "djpowel")) |
| 06:59 | clojurebot | hello |
| 06:59 | Cark | it "comments" the next form |
| 06:59 | Cark | ,(do (print "hello") (print "djpowel")) |
| 06:59 | clojurebot | hellodjpowel |
| 07:09 | djpowell | Hmm, why would you want to do that though? |
| 07:10 | Cark | maybe you want to disable some functionality in a function you're testing |
| 07:10 | Cark | like logging or whatever |
| 07:19 | antifuchs | or binary search for bugs using a structure editor like paredit. M-<number> M-(, #_ - and you've commented out <number> forms following point. useful sometimes |
| 07:23 | AWizzArd | djpowell: the (comment ...) macro can get you into trouble, because it returns nil. So the #_ is nice, because it removes what follows, as if it never were there. Although I think it first reads the following form, so that should not contain something which the reader doesn't like. |
| 07:23 | AWizzArd | ,(+ 1 2 (comment 3)) |
| 07:23 | clojurebot | java.lang.NullPointerException |
| 07:23 | AWizzArd | ,(+ 1 2 #_3) |
| 07:23 | clojurebot | 3 |
| 07:38 | lepassive | Hi, I know python, learned scheme before and I do Haskell, what does Clojure have to offer ? |
| 07:40 | durka42 | you might read http://clojure.org/rationale and some of the other things along the sidebar there |
| 07:42 | antifuchs | btw, the wikispaces guy I talked to said they're working on nicer reload behavior. they plan to update it in a week or so. |
| 07:42 | Cark | antifuchs : great news ! |
| 07:42 | lepassive | durka42, Yes thanks i checked it before asking. just wondering about its benefits for me maybe migrating to coljure in the firm stuff like that |
| 07:43 | durka42 | antifuchs: as in faster? |
| 07:43 | antifuchs | durka42: well, hopefully (: |
| 07:44 | Cark | lepassive : with clojure you get comprehensive persistent data structures, agents and STM right of the box |
| 07:45 | Cark | and all the java libraries |
| 07:46 | lepassive | Cark, Hmmmmm okay what about concurrency ? compared to Haskell or Erlang ? |
| 07:46 | Cark | you have agents which are sort of like but not quite like erlang |
| 07:46 | Cark | and STM for shared state |
| 07:46 | durka42 | there is very good support for fast immutable data structures |
| 07:46 | durka42 | which help |
| 07:47 | lepassive | Cark, yes I'm familiar with STM from Haskell, the thing is i learned scheme before, and clojure seems not to have that much of docs all over? |
| 07:48 | Cark | you have the doc and find-doc commands, then the web site has it all |
| 07:49 | lepassive | Okay Cark thanks for your patience I'll give clojure a shot :) |
| 07:49 | Cark | you will love it =) |
| 07:50 | lepassive | Cark, I'm sure i'll :) |
| 07:58 | Cark | what's the rationale behind the fact that agent send is not queued before the current agent returns ? |
| 08:01 | rhickey | Cark: it's the only way an agent can know the receiver of the action it sends will see its new state - you can use release-pending-sends to force them out prior to end-of-action |
| 08:02 | Cark | ,(doc release-pending-sends) |
| 08:02 | clojurebot | "([]); Normally, actions sent directly or indirectly during another action are held until the action completes (changes the agent's state). This function can be used to dispatch any pending sent actions immediately. This has no impact on actions sent during a transaction, which are still held until commit. If no action is occurring, does nothing. Returns the number of actions dispatched." |
| 08:03 | Cark | rhickey : that makes sense, thanks ! |
| 08:08 | Cark | ~def release-ending-sends |
| 08:08 | Cark | ~def clojure.lang.Agent |
| 08:47 | antifuchs | this is odd. I can't connect to different ports in the same emacs session using swank-clojure |
| 08:47 | antifuchs | (that's with a slime updated from CVS yesterday) |
| 08:48 | antifuchs | connecting to clojure and an sbcl works fine. just connecting to two clojure instances doesn't. hangs emacs inside slime-accept-process-output. |
| 08:48 | antifuchs | anyone else see that before? |
| 08:49 | antifuchs | I don't see anything conspicuous inside swank-clojure.el; think this might be on the clojure swank side? |
| 08:52 | antifuchs | oops. something is sending something called swank::*load-path* across; this is causing an exception and aborts the repl creation. odd. |
| 08:57 | antifuchs | ok, so that was redshank. note to self: try with a clean environment first (-: |
| 08:58 | AWizzArd | antifuchs: you are making good progress :) |
| 08:58 | antifuchs | AWizzArd: yes, I'm pretty amazed myself (: |
| 09:00 | antifuchs | btw, my na�ve swank plugin to art of illusion is here: http://github.com/antifuchs/aoi-swank-plugin/tree/master - in case anyone feels the urgent need to track my progress ((: |
| 09:16 | AWizzArd | good |
| 09:22 | AWizzArd | When I want to use a debugger to step line by line through clojure code, and I want it to be able to also jump into the code of Clojure itself, should I then point to the src/ folder, or is the clojure-sources.jar enough? |
| 09:24 | antifuchs | hmm. what is the preferred way to indent cond clauses? |
| 09:24 | antifuchs | it seems that the condition and consequent should be on the same line, but that sometimes results in too-long lines. any alternatives? |
| 09:27 | AWizzArd | I usually try to make this consistent. An option could be (condition 1)\n(form )\n(condition 2)\(form 2)\... |
| 09:27 | AWizzArd | uhm \ ==> \n |
| 09:28 | Chouser | I sometimes indent the consequents one extra level |
| 09:29 | AWizzArd | In principle it would make sense if the editor/ide would do this automatically. |
| 09:31 | antifuchs | yeah. I initially thought cond would take a [condition consequent] vector for each one |
| 11:21 | antifuchs | st3fan: that's the one that bill clementson's tutorials and scripts use, so it's what I have been using |
| 11:24 | cconstantine | ~def defn |
| 11:28 | cconstantine | is tehre anyway to have named optional arguments? if so, how? |
| 11:28 | st3fan | ok i got slime working too now |
| 11:28 | st3fan | good good |
| 11:29 | cconstantine | or not even optional.. but named so they can go in any order |
| 11:29 | st3fan | slime integration is not as nice as sblc yet it seems, but it will do the trick |
| 11:29 | Cark | (let [hello (fn [{:keys [name]}] (println "hello, " name))] (hello {:name constantine})) |
| 11:29 | Cark | ,(let [hello (fn [{:keys [name]}] (println "hello, " name))] (hello {:name constantine})) |
| 11:29 | clojurebot | java.lang.Exception: Unable to resolve symbol: constantine in this context |
| 11:29 | Cark | ,(let [hello (fn [{:keys [name]}] (println "hello, " name))] (hello {:name "constantine"})) |
| 11:29 | clojurebot | hello, constantine |
| 11:30 | cconstantine | fantastic :) |
| 11:30 | cconstantine | so, not really but it can look a lot like it |
| 11:30 | Cark | right |
| 11:31 | Cark | there is syntax for default value too |
| 11:32 | cconstantine | how does that look? |
| 11:32 | Cark | ,(let [hello (fn [{:keys [name] :or {:name "unknown person"}}] (println "hello, " name))] (hello {:name "constantine"})) |
| 11:32 | clojurebot | hello, constantine |
| 11:32 | Cark | ,(let [hello (fn [{:keys [name] :or {:name "unknown person"}}] (println "hello, " name))] (hello {})) |
| 11:32 | clojurebot | hello, nil |
| 11:32 | Cark | hum |
| 11:33 | Cark | ,(let [hello (fn [{name :name :or {name "unknown person"}}] (println "hello, " name))] (hello {})) |
| 11:33 | clojurebot | hello, unknown person |
| 11:34 | cconstantine | that looks kinda ugly in the arg-listing... but nice and clean in the function body and calling |
| 11:35 | cconstantine | and I'm not really sure how I'd make it more clean in the arg-listing |
| 11:35 | Cark | right, you may just define your function like this : (fn [the-map] ... then do the destructuring in a let form |
| 11:35 | Cark | that's the same syntax |
| 11:35 | cconstantine | that's all that is right, destructuring binding in the argument list |
| 11:37 | Cark | it's nice to have the destructuring in the arg list, that way slime shows what is required when you use the function |
| 11:37 | cconstantine | yeah |
| 11:38 | Cark | but yeah it's a bit ugly ! |
| 11:38 | cconstantine | i'm not saying it's a bad thing, it's a neat reuse of a feature |
| 13:37 | fyuryu | pimp my programming language: http://dl.getdropbox.com/u/820389/clj02.png |
| 14:08 | antifuchs | ok, so I am really happy with what clojure has let me do so far |
| 14:08 | antifuchs | rhickey: thanks for making this (-: |
| 14:08 | rhickey | antifuchs: you're welcome! |
| 14:08 | antifuchs | and to all the other contributors, of course (-: |
| 14:12 | durka42 | and looks strangely at the backwards smiley |
| 14:24 | cemerick | Chouser: Titanium PR3 came out today. Ironically, applets have been disabled. :-( |
| 14:26 | Chouser_ | cemerick: hmph |
| 14:27 | cemerick | yeah. As I was reminded when I mentioned it, "these are just preview releases". I guess it's gonna need another 6 months in the oven. |
| 14:28 | cemerick | Chouser_: it was very nice to meet you, BTW. Good to put a face to the handle :-) |
| 14:30 | Chouser_ | cemerick: you too! really, it was all far more fun than I'd like to admit. |
| 14:30 | cemerick | indeed |
| 14:30 | Chouser_ | you need applets to get at the liveconnect that you need to drive it from clojure? |
| 14:30 | rhickey | great seeing both of you guys and the (many) other Clojure users there |
| 14:31 | cemerick | well, I'm just trying to replace swing, which doesn't look likely in the very near future now. |
| 14:31 | cemerick | rhickey: likewise. |
| 14:31 | Chouser_ | rhickey: thanks for taking the time to hang out with us. I had a blast. |
| 14:32 | cemerick | Nothing beats getting to know people face-to-face. |
| 14:32 | Chouser_ | cemerick: jna + cocoa? |
| 14:33 | cemerick | Chouser_: need to be on windows :-[ |
| 14:33 | rhickey | cemerick: why not just Safari? |
| 14:33 | cemerick | it's odd to me that the ILC is only every other year. I'd think they wouldn't have any trouble getting similar attendance every year. |
| 14:33 | Chouser_ | jna + gtk? :-) |
| 14:33 | cemerick | Chouser_: ha-ha ;-) |
| 14:35 | cemerick | rhickey: ...or Firefox. Yeah, I've thought of it. That's a lot of bailing wire and duct tape, tho -- at least, in order to get to the degree of UX I'd like. |
| 14:35 | cemerick | Swing sucks, but it's still just java, so the deployment story is really easy. |
| 14:36 | cemerick | so, I guess my 'swing sucks' line is really hyperbolic. |
| 14:36 | Chouser_ | cemerick: do you have a link for titanium? Google's confused by the synonyms. |
| 14:37 | Chouser_ | swing is the worst ui toolkit, except for all the others? |
| 14:37 | cemerick | Chouser_: exactly! |
| 14:37 | cemerick | http://titaniumapp.com/ |
| 14:37 | cemerick | Looks like they've pulled PR3, though. |
| 14:37 | hiredman | #java spent an hour or so panning AWT a few days ago |
| 14:38 | cemerick | chatter of some last minute win32 bugs in the titanium irc causing them to pull the release. |
| 14:39 | cemerick | rhickey: I checked around on jwebpane this morning -- looks like the code's done, they're just waiting for "marketing" to allow them to release it (http://weblogs.java.net/blog/alex2d/archive/2008/12/jwebpane_projec_1.html) |
| 14:40 | rhickey | cemerick: yeah, that's the last I'd seen |
| 14:40 | cemerick | of course, that's been the line for 6 months now |
| 14:40 | Chouser_ | titanium + jetty? |
| 14:42 | cemerick | Chouser_: already semi-supported, apparently: http://appcelerator.org/ |
| 14:42 | Chouser_ | I guess you'd need something to run the async connection from the "client" side. Hm... |
| 14:42 | cemerick | not really appropriate for our use case, but I can imagine it being very useful elsewhere |
| 14:42 | cemerick | rhickey: agreed. |
| 14:43 | Chouser_ | Qt comes with a webkit widget -- plug in jambi and I bet you've got something. |
| 14:43 | Chouser_ | Even if jambi withers, whatever webkit thing is available later may be similar enough to allow for easy migration. |
| 14:44 | Chouser_ | the pull of already functioning code is strong for me. |
| 14:46 | walters | there's also SWT |
| 14:48 | cemerick | walters: ugh. no-go on 64-bit still, right? |
| 14:48 | sohail | Chouser, jambi is going to be discontinued I think |
| 14:48 | walters | cemerick: i'm running eclipse on a 64 bit fedora install right now, but if you're talking about OS X or windows, i have no idea |
| 14:50 | Chouser_ | jambi will no longer be supported by trolltech, as cemerick reminds me frequently. But I brought it up anyway because the APIs of webkit itself vs. what jambi would expose to Clojure would by very similar. |
| 14:50 | walters | well... |
| 14:50 | cemerick | walters: I think it's more related to 64-bit java -- I have an swt app here that I need to explicitly launch with java 1.5 32-bit, or it crashes. |
| 14:50 | Chouser_ | ...such that when something else became available, migrating from jambi to the new thing might be pretty straightforward. |
| 14:51 | cemerick | looks like 64-bit swt on OS X is now in 'early access' |
| 14:51 | walters | Chouser_: depends what you want to do i guess; if you just want a toplevel window with webkit taking the whole thing maybe you can use it without a toolkit, but you really want a "normal" toolkit like Qt/GTK/SWT containing it i think |
| 14:51 | cemerick | hrm, I guess I get a little pedantic on the jambi support issue ;-) |
| 14:51 | walters | cemerick: on OS X? |
| 14:52 | cemerick | walters: yeah; FWIW: http://download.eclipse.org/eclipse/downloads/drops/S-3.5M4-200812111908/eclipse-news-M4.html |
| 14:53 | cemerick | I suppose I should consider swt in general given the ibm/sun snit |
| 15:07 | Lau_of_DK | Good evening gents |
| 15:08 | durka42 | hi lau |
| 15:15 | hiredman | how can I create a namespace qualified keyword? |
| 15:15 | rhickey | :foo/bar |
| 15:15 | cmvkk | :foo/bar |
| 15:15 | hiredman | how can I programatically create a namespace qualified keyword? |
| 15:16 | hiredman | :P |
| 15:16 | rhickey | (keyword "foo" "bar") |
| 15:17 | durka42 | (in-ns foo) ::bar |
| 15:17 | durka42 | ' |
| 15:18 | hiredman | well, that makes sense |
| 15:55 | clojurebot | http://groups.google.com/group/clojure/browse_thread/thread/bba604cee3b232d9/28837d55525306d8?lnk=gst&q=recursive+macroexpand#28837d55525306d8 |
| 15:56 | stuhood | is clojurebot thinking for himself? |
| 15:56 | durka42 | clojurebot: are you sentient now? |
| 15:56 | clojurebot | excusez-moi |
| 15:58 | stuhood | of course he'd play dumb: he doesn't want us to know he's aware |
| 15:59 | brianh2 | speaking of keywords, I noticed that the destructuring with :keys doesn't work with ns qualified keywords. Is that intentional? |
| 16:01 | clojurebot | shuffle is http://groups.google.com/group/clojure/msg/a2816f1b51d99b79 |
| 16:01 | hiredman | hmmm |
| 16:01 | Carke | hiredman : btw i've been trying to talk to clojurebot in a query connection, but he continues talking in the main channel |
| 16:02 | Carke | maybe that's what you get here |
| 16:03 | brianh2 | i got kicked. anyone respond to my question? |
| 16:03 | hiredman | Carke: I just privmsg'ed him and he responded in a privmsg |
| 16:04 | Carke | yes he does but look at this |
| 16:04 | Carke | see ? |
| 16:04 | hiredman | what? |
| 16:04 | cconstantine | ~def time |
| 16:05 | hiredman | Carke: I see nothing |
| 16:05 | Carke | well i've been privately asking him ~def str |
| 16:05 | Carke | i was hoping not to spam the clojure channel with my queries |
| 16:05 | hiredman | uh |
| 16:06 | hiredman | clojurebot responds to ~def stuff with a NOTICE |
| 16:06 | hiredman | which, if you are in a privmsg,, should still go to you only |
| 16:06 | hiredman | (which it does here) |
| 16:06 | Carke | ok so you didn't see my ~def str notice ? |
| 16:07 | hiredman | nope |
| 16:07 | brianh2 | ,((fn [{:keys [x y]}] (prn x y)) {:x 5 :y 6}) |
| 16:07 | clojurebot | 5 6 |
| 16:08 | brianh2 | ,((fn [{:keys [x y]}] (prn x y)) {::x 5 ::y 6}) |
| 16:08 | clojurebot | nil nil |
| 16:08 | Carke | good ! must be my irc client showing it in the clojure channel, sorry about that |
| 16:08 | hiredman | ,::x |
| 16:08 | clojurebot | :sandbox/x |
| 16:08 | kotarak | brianh2: how would you do that? you cannot fully qualify the symbol, which is used for the destructuring, since it refers another namespace. And you cannot just use the name part. What happens in this case: {:x 5 ::x 6}? |
| 16:09 | brianh2 | kotorak: not sure |
| 16:11 | brianh2 | but i was hoping to not pollute the global keyword space with some maps i was creating & then tried to use :keys |
| 16:12 | Chouser_ | warms the heart: http://twitter.com/csebold/statuses/1396317051 |
| 16:12 | cemerick | global keyword space? |
| 16:12 | hiredman | (ha ha horatio) |
| 16:13 | brianh2 | cemerick: k. i'm not sure where :x keywords are placed... |
| 16:13 | hiredman | why would they be placed anywhere? |
| 16:14 | cemerick | I suppose there might be some interning going on somewhere, but that won't affect anything you need to worry about. |
| 16:15 | hiredman | keywords are not symbols, they don't have associated storage |
| 16:15 | cemerick | there we go, then |
| 16:15 | Chouser_ | clojure.lang.Keyword.table is where all keywords are interned |
| 16:16 | cemerick | hiredman: you've led me astray! ;-) |
| 16:16 | hiredman | even if you have :x twice, they cannot conflict unless it is in the same hashtable |
| 16:16 | hiredman | cemerick: I did not mean keywords are not stored somewhere |
| 16:16 | brianh2 | hmmm.... so there's no need to use :: |
| 16:16 | cemerick | are there any real reason for namespaced keywords at the moment, aside from multimethod hierarchies? |
| 16:16 | kotarak | brianh2: there is no such thing as a "keyword namespace", but what maybe fits your intention: {:spaceA/foo 5 :spaceB/foo 6}. So spaceA and spaceB can add stuff to the map, without interferring with each other. |
| 16:16 | hiredman | I mean values are not stored "in" keywords |
| 16:17 | hiredman | keywords are just, you know, like ?? |
| 17:27 | slashus2 | Why is hash-map and hash-set overloaded to take no arguments, but sorted-map isn't? It seems that just calling (. clojure.lang.PersistentHashSet (create '())) returns #{} just fine. |
| 17:27 | slashus2 | ,(. clojure.lang.PersistentHashMap (create '())) |
| 17:27 | clojurebot | java.lang.IllegalArgumentException: No value supplied for key: null |
| 17:27 | slashus2 | hm |
| 17:36 | slashus2 | I wonder if it would be helpful to implement hash-map, sorted-map, etc. to take in a map of another kind, not just key value pairs. (sorted-map {:a 5 :b 6}) will return a sorted map. May be useful in translating larger maps into sorted maps. In that case, it may have been useful to start with a sorted-map to begin with. (into (sorted-map) {:a 5 :b 6}) works I guess. |
| 17:39 | hiredman | ,(clojure.lang.PersistentHashMap. {:a 1 :b 2}) |
| 17:39 | clojurebot | java.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.PersistentHashMap |
| 17:39 | hiredman | ~def c.l.PersistentHashMap |
| 17:40 | slashus2 | That way It would have the effect of coercion. |
| 17:40 | slashus2 | As well as initialization. |
| 17:41 | hiredman | ,(. clojure.lang.PersistentHashMap (create {:a 1 :b 2})) |
| 17:41 | clojurebot | {:a 1, :b 2} |
| 17:42 | slashus2 | ,(. clojure.lang.PersistentTreeMap (create {:b 1 :a 2})) |
| 17:42 | clojurebot | {:a 2, :b 1} |
| 17:42 | slashus2 | :-) |
| 17:42 | durka42 | ,(sorted? (clojure.lang.PersistentTreeMap/create {:a 1 :b 2})) |
| 17:42 | clojurebot | true |
| 17:43 | slashus2 | It is just how the sorted-map is implemented in the core. |
| 17:44 | durka42 | in the core it is |
| 17:44 | durka42 | ,(clojure.lang.PersistentTreeMap/create '(:b 2 :a 1)) |
| 17:44 | clojurebot | {:a 1, :b 2} |
| 17:45 | slashus2 | right |
| 17:49 | cemerick | Chouser: who came up with "Member of the Technical Staff"? |
| 18:18 | kefka | I have a question about the interning of keywords... Won't processing of an arbitrary collection of keyworkds cause a memory leak? |
| 18:24 | cconstantine | why do you think it would? |
| 18:25 | brianh2 | kefka: crossed my mind too. doesn't look like weakhashmap would work in it's place due to == use. was also wondering about how String.intern() works under the covers since that's where all symbols go to live |
| 18:26 | hiredman | ~jdoc String |
| 18:30 | slashus2 | brianh2: The private string pool? |
| 18:38 | kefka | cconstantine: SBCL has this problem. Every symbol you use (even if just for language/comparison) gets interned. |
| 18:38 | kefka | So you have to be careful not to generate a bunch of junk symbols in production code. |
| 18:40 | slashus2 | kefka: Do you notice a leak in your applications? |
| 18:41 | hiredman | ~def c.l.Symbol |
| 18:41 | kefka | slashus2: No, but I'm about to build something for production that uses a lot of keywords. |
| 18:46 | slashus2 | Looks like the way Symbol is implemented, it keeps a pool of symbols in String? |
| 18:46 | clojurebot | http://clojure.org/data_structures#toc10 |
| 18:50 | hiredman | btw there is now a 1 in 20 chance clojurebot will respond to something even if it is not addressed to it |
| 18:50 | slashus2 | hiredman: I noticed :-) |
| 18:51 | Chousuke | Interesting :P |
| 18:55 | duderdo | Hi |
| 18:56 | duderdo | Quick question, how do I join two sets? Conj puts on in the other. |
| 18:56 | Chousuke | clojure.set/join I think |
| 18:56 | Chousuke | (doc join) |
| 18:56 | clojurebot | Titim gan �ir� ort. |
| 18:56 | duderdo | Thanks. |
| 18:56 | Chousuke | hm, I guess clojurebot doesn't import the namespace :p |
| 18:57 | duderdo | hehe |
| 18:57 | duderdo | You sure are johnny on the spot in this chatroom chousuke |
| 18:57 | duderdo | Much appreciated |
| 19:20 | antifuchs | kefka: little addendum: all common lisps, as specified have that problem. the general advice is that if you're worried that interning strings will take up memory later on, don't intern strings (or unintern them once you don't need them anymore) |
| 19:20 | clojurebot | No entiendo |
| 19:21 | hiredman | maybe 1 in 20 is too low |
| 19:21 | dreish | Maybe it should keep quiet instead of giving the "I don't understand" answers, in the random case. |
| 20:13 | slashus2 | Is there a tutorial somewhere that will help in understanding how to use zippers to create something like a binary tree, red-black tree, etc. |
| 20:37 | danlarkin | Evening clojurecrats! |
| 21:20 | cmvkk | 'clojurecrats' |
| 21:20 | cmvkk | well i'm glad someone came up with a term |
| 21:22 | jhawk28 | term for what? |
| 21:24 | durka42 | for those who believe the clojure is the Way? |
| 21:24 | durka42 | or the Language, anyway |
| 21:24 | jhawk28 | I thought that was everyone ;) |
| 21:30 | danlarkin | haha a few months ago on the mailing list there was a 'what should we call users of clojure' thread |
| 21:30 | danlarkin | no conclusion was reached |
| 21:31 | cmvkk | by mailing list do you mean google group, or is there also a mailing list |
| 21:31 | durka42 | i like clojurians myself |
| 21:31 | danlarkin | mailing list == google group |
| 21:31 | jhawk28 | clojurites |
| 21:31 | cmvkk | clojurians sounds like we're from another planet |
| 21:32 | danlarkin | my favorites are pythonistas and djangonauts |
| 21:32 | slashus2 | Brazilians? |
| 21:32 | slashus2 | are from another planet? |
| 21:38 | jhawk28 | what about clabangos? |
| 21:39 | slashus2 | lol |
| 21:58 | danlarkin | hahah -1 to clabangos |
| 22:46 | chessguy | hi |
| 22:46 | Chouser | hi |
| 22:47 | chessguy | new to clojure here. seems like it has some interesting ideas to it |
| 22:49 | Chouser | chessguy: preaching. choir. :-) |
| 22:50 | chessguy | haha, fair enough. i was mainly not being the guy that comes in and says "hi. your language sucks" |
| 22:50 | Chouser | well, that's appreciated. |
| 22:50 | chessguy | is there a collection of clojure libraries/programs somewhere? |
| 22:50 | cmvkk | has anyone done that yet? |
| 22:50 | Chouser | cmvkk: yeah, but not often. |
| 22:51 | chessguy | cmvkk, it's a revered internet pasttime |
| 22:51 | chessguy | well, maybe not revered |
| 22:51 | Chouser | chessguy: http://code.google.com/p/clojure-contrib/source/checkout |
| 22:51 | cmvkk | also see sites like github |
| 22:51 | chessguy | oh nice |
| 22:58 | chessguy | hm, i'm trying to decide how i want to go about learning clojure |
| 23:00 | Chouser | pick a project, write it in clojure? |
| 23:01 | chessguy | yeah, thinking of doing a chess engine. could be fun. just...not very introductory :) |
| 23:02 | Chouser | projecteuler.net has nice introductory puzzles |
| 23:02 | cmvkk | speaking of learning stuff, |
| 23:03 | chessguy | yeah, euler stuff tends to be a little too mathy for me though |
| 23:03 | cmvkk | i feel like i should learn the basics of Java to get a better grip on clojure...is there a good java book or resource for people who already know how to program? |
| 23:04 | chessguy | cmvkk, i personally like Dietel & Dietel for the exercises |
| 23:04 | chessguy | and i greatly DIS-like Eckel's books |
| 23:05 | cmvkk | heh. |
| 23:05 | cmvkk | i have a deitel perl book and it seemed pretty good so that might not be a bad idea |
| 23:05 | clojurebot | book is http://www.pragprog.com/titles/shcloj/programming-clojure |
| 23:05 | chessguy | deitel perl? interesting |
| 23:05 | chessguy | haven't seen that one |
| 23:05 | cmvkk | i think anyway...i didn't actually read it. i had to buy it for a class but i already knew perl |
| 23:06 | chessguy | wow, there's a programming clojure book already? i thought clojure was very new |
| 23:06 | cmvkk | this is cutting edge man...you should have seen how the guy had to keep changing the book in order to keep up with new features during its production |
| 23:08 | chessguy | pretty impressive considering that haskell just finally got its first serious book |
| 23:28 | chessguy | wow, the reference section on clojure.org is pretty hard-core |