#clojure logs

2009-06-21

00:11durka42has anyone seen this while compiling clojure?
00:11durka42 [java] Compiling clojure.inspector to /Users/alex/Programming/clojure/classes
00:11durka42 [java] java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)
00:46slashus2durka42: Are you running it inside of a sandbox?
00:54durka42slashus2: no, just did a git pull
02:35stuhoodit's hard to run in a sandbox. or on a beach
02:36slashus2stuhood: The sand kind of gives when you run.
04:46samuelsstuhood: are you stewart holloway
04:46stuhoodsamuels: sorry, no: his nick is stuarthalloway i believe
04:46stuhood~seen stuarthalloway
04:46clojurebotstuarthalloway was last seen quiting IRC, 2134 minutes ago
04:47stuhoodyea, that's him.
04:47samuels~2134/60
04:47clojurebotNo entiendo
04:48samuels~(/ 2134 60)
04:48clojurebotExcuse me?
04:48stuhoodsamuels: close
04:48stuhood,(/ 2134 60)
04:48clojurebot1067/30
04:48samuels...
04:48samuels,(/ 2134 60.0)
04:48clojurebot35.56666666666667
04:48samuelsah ok
04:48samuelsthx
04:48stuhoodsamuels: ratios =)
04:49samuelsthat's a weird aspect to clojure dont you agree
04:49samuelsi mean wtf needs ratios?
04:49samuels(the wtf in the preceding sentence meaning 'who the f*ck' not 'what the f*ck' )
04:50stuhoodsamuels: not me, heh... but floating point can be difficult to get right, so anytime you can avoid it, you're better off
04:50stuhoodwrt accuracy
04:50samuelsyeah
04:50samuelsstuhood: do you know if clojure will be getting compile time type checking any time soon?
04:51kotarakmaybe people needing exact numbers, eg. currency or so?
04:51samuelsand do you konw of any lisp flavours that currently support it?
04:51kotarak1) probably not, 2) Qi
04:52stuhoodsamuels: what he said... but people (Chouser?) are doing work in the area of types, to basically do automatic type hinting based on your imports
04:53stuhoodso it seems like a logical next step would be to think about enforcement
04:53samuelsyeah
04:54samuelsstuhood: what editor do you use for your clojur code?
04:55stuhoodsamuels: vim, with an old version of VimClojure
04:55samuelsoh ok
04:55samuelsstuhood: do you know if SLIME works with clojure?
04:55samuelsand if it's easy enough to setup?
04:56stuhoodi believe so
04:56samuelsgreat
04:56stuhoodhttp://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Emacs_.2F_Slime_.2F_Clojure_on_Ubuntu_-_Tutorial
05:02samuelsthanks
05:02samuelsstuhood: you dont like emacs?
05:03stuhoodheh... never tried it
05:03samuelsit's pretty c00l man
05:03samuelspr3tty*
05:08stuhoodi probably haven't switched because i'm dumb enough to be up at 5am
05:08stuhoodg'night! =)
05:09samuelsnight man!!
10:10Chousukehmm, nobody has bothered to move old issues from contrib to assembla I see
10:10Chousukewonder if it's worth it. :/
10:14durka42i got another permissions exception trying to compile contrib.zip-filter.xml
10:25durka42so the problem is, clojure and contrib now require java 6 to compile!
10:29durka42does anyone know of a good rss reader that can give me a threaded view of the clojure-dev messages?
10:37Chousukehm
10:59lenstjava version "1.5.0_19" works for me
11:13durka42lenst: interesting, that was the one that threw exceptions for me. what OS?
11:41krumholtwhat is the most used ide with clojure?
11:44Chouserkrumholt: my guess would be emacs, but I'm not sure. I don't use any.
11:47rysNetbeans seems pretty popular from the mailing list
11:47hoeckkrumholt: I would say emacs + slime, because many of the early clojure adopters had some lisp background
11:53krumholtok thanks
12:17Chouserrhickey: can we have a milestore or something for 1.0-bugfix?
12:33durka42are any of the ticket comments going to be transferred from GC to Assembla?
12:34Chousukenot as comments
12:34Chousukethey are included in the description
12:35Chousukebut I wonder if someone's going to bother moving contrib issues :P
12:35Chousukeshould be okay to ignore the closed ones.
12:36durka42there is only one then :)
12:36durka42~ticket #3
12:36Chousukeyeah.
12:36clojurebot{:url http://tinyurl.com/mewy4h, :summary "Test ticket", :status :invalid, :priority :normal, :created-on "2009-06-16T19:25:19+00:00"}
12:37durka42just for fun
12:39Chousukedurka42: you'd have to parse google's web pages to do it :P
12:39durka42well, maybe
12:39durka42http://code.google.com/p/clojure-contrib/issues/csv?can=1&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary
12:40Chousukedurka42: you'd still need to manually get the comments and patches though :/
12:40durka42yeah, that could be a problem :p
12:45kotarakDo we now have a Core team?
12:46durka42kotarak: bug report for you :)
12:46kotarakdurka42: I hear.
12:46kotarakeh... I read....
12:46durka42*1 is broken
12:48kotarakdurka42: I see. In the bleeding-edge branch right?
12:49durka42yes
12:49durka42*1, *2, and *3 are all the symbol 'user
12:49kotarakIt's actually the namespace.
12:49kotarakTry (ns foo.bar)
12:49durka42hmm, i see
12:49durka42i do like the namespace display at the repl prompt though
12:49kotarakI know, what the problem is.
13:21arasoftSorry, but I am at the end of Google's wit:
13:21arasoftWhat do I have to do to get this to work properly at the REPL
13:21arasoft(. "ä" toUpperCase ) (the String contains a lowercase "a umlaut")
13:21arasoftI have tried with different (and none at all) settings for file.encoding and console.encoding, but to no avail.
13:21arasoftPlatform is WinXP with German keyboard.
13:21gnuvince_,(.toUpperCase "àé")
13:21clojurebot"ÀÉ"
13:22gnuvince_,(.toUpperCase "ä")
13:22clojurebot"Ä"
13:22gnuvince_Works fine
13:22arasoftNot on my machine...
13:22durka42Chousuke: http://code.google.com/p/support/issues/detail?id=148
13:23gnuvince_arasoft: which OS?
13:24arasoftWinXP English with German keyboard
13:24gnuvince_arasoft: does cmd.exe input in unicode?
13:29arasoftI don't think so, therefore I tried -Dfile.encoding=ISO8859_1 -Dconsole.encoding=Cp1252 and others, but no luck. Even when calling a Java method that returns a hard-coded string with non-ANSI characters, the result is garbage (the specific garbage depends on the specified encodings).
13:29arasoftI looked at http://groups.google.com/group/clojure/browse_thread/thread/1ebe3c8f342f3abe/d0497724d342e27f and similar, but there seems to be no complete solution.
13:32prospero_if I want to define a function with a name defined in a string, is there a standard way to do that?
13:33prospero_I've seen an implementation that relies on "new clojure.lang.MultiFn" and defmethod, but it seems like there must be a better way
13:33arohnerprospero_: you mean you want the name of the function to come from a string?
13:33prospero_yes
13:34arohnerone sec
13:34maxthimusfrom the book programming clojure:
13:34maxthimus(defn make-greeter [greeting-prefix] (fn [name] (str greeting-prefix ", " name)))
13:35maxthimus(def hello-greeting (make-greeter "Hello"))
13:35maxthimus(hello-greeting "world")
13:35arohnerhrm, this works, but it uses eval
13:36arohner(eval `(defn (symbol "foo") [x] (* x x))
13:36prospero_arohner: eval is ok, I think
13:36prospero_that's what I was looking for, thanks
13:36Chousukeyou should use a macro. :/
13:37arohneryeah, you can write a macro that does the same thing
13:37Chousuke(defmacro fn-string [name & the-rest] `(defn ~(symbol name) ~@the-rest)
13:37arohnerChousuke: you beat me to it
13:38arohnerthat's a better solution
13:38prospero_arohner, Chousuke: thanks
13:39arohnerhmm. macros are a controlled use of eval. that's interesting.
13:39arohnerI never thought of it that way
13:40Chousukewell, kind of.
13:42Chousukemacros are special in that I don't think there's any other way to run code at macroexpansion (compile) time.
13:43arohnerif I do (def foo expr...), expr gets run at compile time, right?
13:44Chousukeno, it's runtime.
13:44Chousukeotherwise, something like (def foo (+ x 1)) would not work :/
13:45prospero_so as a followup question, I was looking at this code here: http://github.com/ChickenProp/cloggle/blob/97270c0146a41dc7389a864d333cdaad7986c41b/src/net/philh/cloggle.clj
13:45prospero_which reflects over the opengl libraries, and defines wrapper functions that invoke them
13:46prospero_is he using that method for performance reasons?
13:46prospero_I'm specifically referring to line 72
13:47arohnerprospero_: it's probably for readability/ to get other features
13:47Chousukethat seems a bit hackish
13:49prospero_it doesn't seem particularly readable, but ok
13:49ChousukeI'm pretty sure what he's doing there should be possible with macros too
13:49arohnerprospero_: I mean that the functions he creates are more readable than (.invoke foo opengl-context (to-array args))
13:50ChousukeDepends on whether it's possible to use reflection in macros.
13:51arohnerwhy wouldn't it be possible?
13:51arohnerreflection is just a java method you call
13:51prospero_arohner: certainly, but why the 1-to-1 MultiFn/defmethod approach?
13:51prospero_is that functionally different than a defn somehow?
13:53arohnerno, aside from 1) there is a dispatch fn on multifns, and 2) you can add to the multifn later
13:53arohnerbut yeah, I don't see that happening here
13:53prospero_ok, extensibility seems like a fair reason
13:55arohnerhrm, this would be easier to read in my ide
13:55arohneroh, I get it
13:55ChousukeThere's probably a better way to do what cloggle does but I can't say it's obvious :/
13:55arohnerhe either gets the existing multi-fn, or creates it if it doesn't exist
13:56arohnerso if that gl-methods returns the same name with different arities, it will create two different methods
13:56prospero_hmmm
13:56prospero_that's weird, since as far as I know all opengl functions are suffixed with their parameters
13:57prospero_glVertex3f, glVertex2i, etc.
13:57Chousukeperhaps not for the java bindings?
13:57arohnerstep 1 in fixing this would be to get rid of def-ev
13:57prospero_I'm no expert, but based on my cursory look at JOGL the names of the functions are unchanged
13:59arohnerthe dispatch function is also interesting
13:59prospero_in an ideal world, "vertex" would dispatch to whichever function is appropriate, based on type and arity
13:59prospero_maybe he's building towards that point
14:07emacsenI'm redoing my clojure setup and I'n having some (what I'm guessing are) java issues
14:07emacsenI have my clojure jar and I have it on my classpath.
14:08emacsenbut when I try to compile contribs, ant says it can't find clojure.jar
14:08arohneremacsen: does it work if you do ant -Dclojure.jar=... ?
14:09emacsenarohner, yes
14:10arohnerhow are you defining your classpath?
14:11emacsenexport CLASSPATH=~/local/jars/*
14:11arohnerthe contrib build.xml appears to only pay attention to the -D flag
14:11emacsenokay, so that's fine, but then problem 2
14:11kotarakIf I remember correctly, ant doesn't pay attention to CLASSPATH.
14:12emacsenI run clojure thusly: java -cp $PATH_TO_CLOJURE_JAR:$PATH_TO_CONTRIB_JAR clojure.lang.Repl
14:12emacsenfor the repl, obviously
14:12emacsenbut: user=> (:use clojure.contrib.shell-out)
14:12emacsenjava.lang.ClassNotFoundException: clojure.contrib.shell-out (NO_SOURCE_FILE:1)
14:12clojurebot
14:13emacsencontrib fail
14:14arohnerhrm, shell-out isn't in my build.xml
14:14emacsenthe keyboard cat is coming to watch me :)
14:15emacsenah, lemme check mine
14:15arohnerin that big list of arg value="clojure.contrib.foo", around line 100
14:15arohnertry adding it and recompiling
14:16emacsenit's in mine
14:16emacsenin the <sysproperty key="clojure.compile.path" value="${build}"/>
14:16arohneryeah
14:17emacsenyeah it's there already
14:18arohnerdid you type (:use clojure.contrib.shell-out) at the repl, or was it part of an ns declaration?
14:18emacsenin the repl
14:18arohnerah, yeah that won't work
14:18arohner(use 'clojure.contrib.shell-out)
14:18arohneror (ns my.package (:use clojure.contrib.shell-out))
14:18arohnerthat's kind of confusing
14:19emacsenuser=> (use 'clojure.contrib.shell-out)
14:19emacsenjava.lang.NoSuchMethodError: clojure.lang.Namespace.importClass(Ljava/lang/Class;)Ljava/lang/Class; (NO_SOURCE_FILE:0)
14:20arohnerhrm, that works for me
14:23arohnerI don't know how to recreate that error message
14:23emacsen:-/
14:23emacsenI don't know how not to ;)
14:23emacsenwhat's your clojure java command line?
14:24arohnerI just copied what you did. java -cp jars/clojure.jar:jars/clojure-contrib.jar clojure.lang.Repl
14:25arohnerjava -cp jars/clojure.jar:jars/clojure-contrib.jar clojure.lang.Repl
14:25arohnerClojure 1.1.0-alpha-SNAPSHOT
14:25arohneruser=> (use 'clojure.contrib.shell-out)
14:25arohnernil
14:25arohneruser=> (sh "hostname")
14:25arohner"kjata.earthlink.net\n"
14:26emacsenit fails for me
14:26clojurebotfor is not a loop
14:26emacsen*sigh*
14:27arohnerwhat version of clojure are you using?
14:27emacsen1.0.0
14:27arohnerso you downloaded the tarball, as opposed to svn or git?
14:27emacsenI forget
14:28emacsensvn
14:28arohnerand where did you get contrib from?
14:28emacsensvn
14:29emacsenhttp://clojure-contrib.googlecode.com/svn
14:30arohnerI would get the latest version of both from git, and make sure the clojure.jar you compile against is the same one you use at runtime
14:30arohnerclojurebot: git
14:30clojurebotgit is http://www.github.com
14:30arohnerthat's not useful, clojurebot
14:31arohnerhttp://github.com/richhickey/clojure/tree/master
14:31arohnerhttp://github.com/richhickey/clojure-contrib/tree/master
14:31emacsenI found the git version of clojure to be unstable
14:32arohnerunstable how?
14:32emacsendoes git clojure-contrib track git clojure
14:32emacsenI forget
14:32emacsenbut it broke for me one time
14:32arohneryes, they track
14:50Lau_of_DKQuestion - Ive got a plain-text file on my system, (count (slurp file)) = 1064, (.length (File. file)) = 1078 - Why ?
14:50ChousukeLau_of_DK: maybe its length as characters is not the same as its length in bytes?
14:51opqdonutwhich would be the case with for example UTF-8 encoding
14:51Lau_of_DKHow could thei differ when its plain text ?
14:51ChousukeLau_of_DK: for example, if you have double-byte characters in it.
14:51opqdonuts/would/might/
14:51Lau_of_DKs/thei/they
14:51ChousukeLau_of_DK: well, any non-ascii might be double-byte
14:51Lau_of_DKalright - I didnt think that occured with plain text files, but I understand that it would naturally be the cause of the problem
15:20arohnerLau_of_DK: are you on windows?
15:28Lau_of_DKOf course not :)
15:28arohnernot everyone is so enlightened. :-) I was wondering if \r\n's accounted for your discrepancy
15:30Lau_of_DKThat might actually be it, I got this from a windows system, and FTP downloaded it, in that process they migt have been stripped
15:30Lau_of_DKI think its 1 bytes per linie
17:03arohnerdanlarkin: how do you get clojure-json to print a json symbol?
17:03arohneri.e. prototype requires "new Ajax.Request(url, {method: 'get',..."
17:04arohnerand if I try to use clojure-json, I end up with {"method":"get" rather than {method:"get"
17:07Lau_of_DKI have a clojure program which downloads a couple of files and then parses them. when I run it from the repl, this is a 1 second job, when I run it from command line like "java -cp clojure.jar clojure.lang.Script dl.clj" it takes forever... Its coming up on 5 minutes now and still now result...?
17:10Chouserdo you use agents or pmap?
17:13Lau_of_DKSingle threaded
17:15ChouserLau_of_DK: I guess I'd either attach a debugger and break it after a couple seconds to see where it's spending it's time, or...
17:15Chousersprinkle some println's around to see how far its getting.
17:16Lau_of_DKI've already wrapped the calls in a debug macro, and it gets a list of filenames from the server which works fine, then those names are mapped to download-file, and that doesnt even begin
17:17Lau_of_DK(map #(do
17:17Lau_of_DK (debug "Download message" "OK" (download-message %)) %)
17:17Lau_of_DK (debug "Retrieving list of messages" "OK" (get-messages))))
17:17Lau_of_DKSun Jun 21 23:18:10 CEST 2009: Retrieving list of messages
17:17Lau_of_DKSun Jun 21 23:18:10 CEST 2009: OK
17:18prospero_a few hours ago I asked about defining a function whose name was passed in as a string
17:18prospero_and was told that the best solution was (defmacro fn-string [name & rest] `(defn ~(symbol name) ~@rest))
17:18Lau_of_DKIts interesting, that when run from the REPL, the "Retrieving list of messages" message is never printed, the "Downloading message" is however....?!
17:18prospero_which is great if I try (fn-string "square" [x] (* x x))
17:18Lau_of_DK(and the opposite is true when run from commandline)
17:18prospero_but if I try (def sqr "square")
17:19prospero_and then (fn-string sqr [x] (* x x))
17:19prospero_it will create a function called sqr rather than "square"
17:19prospero_I'm assuming there's something kind of basic about macros I'm missing here
17:19prospero_but have no idea what it is
17:20opqdonutyou need to eval the first arg
17:21Chousukeprospero_: macros can't depend on runtime arguments.
17:21opqdonutthat is, name
17:21opqdonutah, yeah, in case of def the name needs to be known beforehand
17:21prospero_Chousuke: so would eval be the only way to accomplish what I'm trying to do?
17:22Chousukeyou want to def functions based on some strings you read at runtime?
17:22prospero_basically
17:22Chousukeare you sure you need global defs? :/
17:23Chousukecouldn't you just generate a bunch of functions in a map or something?
17:23Lau_of_DKBefore we drift too far off (my) topic - Can anybody enlighten me as do why clojure.lang.Repl and clojure.lang.Script seemingly executed clj's differently ?
17:23prospero_would that lend itself to a better solution?
17:24prospero_oh, by creating anonymous functions
17:24prospero_right
17:24Chousukeyeah, in a map of strings to functions
17:24prospero_well, I could do that
17:25prospero_mostly I just wanted to mess around with opengl and cloggle seemed a bit creaky
17:25Chousukethe problem with generating global definitions is that you can't use them anyway unless you know that they're going to be there.
17:26prospero_right
17:26prospero_I don't know if it's the best solution
17:27prospero_I'm mostly doing this because I'm trying to learn about macros and reflection in java
17:27Chousukecloggle generates bindings, which I guess is one legit reason to generate global defs at runtime, but, you should be able to accomplish the same thing if you do the reflection in a macro and generate the necessary code based on the info you get from the reflection
17:27Chousukeit'll be a complex macro though
17:27prospero_but I think there's some merit to having named functions that are bindings to the java libs
17:28prospero_wouldn't it just be more straightforward to do an eval, then?
17:28Chousukewell, that's basically emulating what the macro would do anyway
17:29prospero_but the eval can depend on runtime arguments, correct?
17:29prospero_or are they both limited in that respect
17:29Chousukeeval works with runtime stuff, yes.
17:30Chousukebut if you're just generating bindings, you might not need them
17:30Chousukereflection should be available during macro expansion time
17:30prospero_hmm
17:31Chousukemacros are basically functions of a lisp form to clojure code. As long as you return valid clojure code, you can do pretty much anything you want.
17:31prospero_so I'd pass the macro a class, and it would do all the reflection inside
17:31prospero_that could be interesting
17:31Chousukeyou can't pass it the class itself, but you can pass it the name of a class.
17:32Chousukeand inside the macro, you can look up the class object using that name with reflection
17:32Chousukeat least, in theory. I haven't tried. :/
17:32prospero_fair enough
17:33prospero_is there a really good reason to do the more complicated macro approach instead of what seems like a simpler eval approach?
17:33Chousukewell, if you manage to pull it off with a macro, I think at the end you would know all you need to know about creating macros :)
17:34prospero_ha
17:34prospero_ok, I'll give it a shot
17:34prospero_thanks
17:34kotarakprospero_: How do you call the function w/o knowing its name in advance?
17:34Lau_of_DKI've figured it out - The REPL (or SLIME) forces evaluation in places where Clojure doesnt
17:34Chousukebesides that, I'm not convinced eval is much easier than the macro system
17:35kotarak~eval
17:35clojureboteval is sometimes useful - but only sometimes
17:35kotarak-.-
17:35prospero_kotarak: I'm playing around with creating bindings to the java opengl libraries
17:35prospero_so I know there's a function called "glVertex3f", for instance
17:36prospero_I'm just trying to skip over some of the indirection necessary to call it, using auto-generated functions
17:36opqdonutyou can make a macro (export glVertex3f) that expands into (def glVertex3f (something "glVertex3f"))
17:36opqdonutby using name etc
17:36kotarakprospero_: when you know the name in advance you can convert it to a symbol in advance.
17:37Lau_of_DKprospero_: Check out SofiaBA on Github, it seems to me some of the work youre doing, has been done
17:38prospero_Lau_of_DK: will do, thanks
17:39prospero_kotarak: you're totally right, I was mostly just looking at cloggle, which does what I'm describing, and thinking that there must be a more elegant way to do it
17:42ChouserI'd recommend doing the namespace interning at runtime, rather than trying to force evalueation at compile time.
17:44Chousukeprospero_: http://gist.github.com/133660 maybe this'll get you started
17:44Chousukeyou'll need to do much more complicated reflection to get something useful but it looks like it's possible.
17:45prospero_Chousuke: thanks
17:49Lau_of_DKWhen my clojure.lang.Script script has finished, the process lingers for 5 minutes - do you guys forcefully terminate your scripts somehow?
17:51ChouserLau_of_DK: you're absolutely sure you're not starting a an agent somewhere? using future or something?
17:51Lau_of_DK100%
17:51Lau_of_DKIts a very straight forward program
17:52Lau_of_DKHmm - There is connection though, which is opened in a global var (kludge) , that qualifies?
17:52ChouserScript has only ever lingered for me if one of the agent pools gets going.
17:52Chouseroh, a socket connection? hm... maybe make sure it gets closed?
17:52Lau_of_DKlemme try
17:53Lau_of_DKThat did it :)
18:05Jetienhi kotarak! do you have 5 mins? i've got problems with vimclojure...
18:06kotaraksure
18:06Jetientwo problems. first: when i try to load a clojure file which has a (ns ..) form in it i get errors
18:07kotarakJetien: must be on the CLASSPATH
18:07kotarak.. of the server
18:08Jetienhm..okay
18:09Jetiensecond problem: I'm trying to get the snake example to run from within vim: http://java.ociweb.com/mark/clojure/ClojureSnake.html
18:09kotarakJetien: this is a limitation of the dynamic part: it uses Clojure's introspection, which only works, when the file can loaded without problems.
18:10Jetieni see
18:11kotarakWhat is the problem with the Snake?
18:11Jetienthe example works fine when i manually start a repl fromt the console, but not from within the repl from the server. i would to sth like (load-file "snake.clj") and then (com.ociweb.snake/main) and nothing happens
18:11Jetienno errors, nothing
18:12Jetienit's not so much about getting the example to work, but knowing why it isn't working
18:12kotarakDoes Vim freeze?
18:12Jetienno
18:12kotarakHmm...
18:13Jetien..whoops.
18:13kotarakwhoops?
18:13Jetieni accidently lef the channel, nevermind.
18:15kotarakJetien: I must confess, I don't know, why the snake doesn't work.
18:16kotarakI would suspect Vim to freeze, since it waits for input from the server process. But this shouldn't happen until main returns.
18:17Jetienhave you tried to run the file, too? maybe the error is on my side
18:20kotarakdoesn't work for me neither...
18:33gunnarahlbergwhat web framework are you guys using? i'm a noob, exploring
18:37arohnergunnarahlberg: I'm using compojure
18:38gunnarahlbergnice it seems
18:39arohneryeah, it works well
18:39arohnerit's a little low-level compared to rails, but what it does, it does well
18:39arohnerand we're building in that direction
18:39gunnarahlbergand the deps and install seem really reasonable
21:37grrrthi room! is anyone in to help me with filtering a map to weed out nil values?
21:37grrrtI came up with (reduce (fn [m [k v]] (if (nil? v) m (assoc m k v))) {} {:a 1 :b nil :c 3})
21:38grrrtbut I don't know if that's the most Clojure-y way of doing it?
21:38Chousernot shabby at all.
21:38grrrtheh thanks!
21:39Chouserhave you looked at 'into'?
21:39grrrthm no.
21:40grrrt(doing (doc into) right now)
21:41Chouserwhat you'd got has nice use of destructuring and reduce.
21:41grrrtAh I see. had a look at the source, it's more readable with recur
21:41grrrt(source for 'into')
21:42Chouserdo you specifically want only non-nils, or is filtering out false ok too?
21:43grrrtin this case I need non-nils, but it's easy to generalise I suppose (defn map-filter or something)
21:44grrrtwith false or nil you could do 'if v' instead of 'if (nil? v)' right?
21:47albinowindow 13
21:51grrrthang on... this weed-out-nils is shorter: '(filter (fn [[k v]] (not (nil? v))) {:a 1 :b nil :c 3})'
21:55danlarkinarohner: ping
21:57Chousergrrrt: yeah, that's why I was asking -- unless you specifically mean to differentiate between nil and false, it's more idiomatic you just say 'if v'
21:59grrrtyou're right, thanks.
22:00grrrtActually this was slightly tangential to what I actually wanted to do:
22:00grrrtgiven maps m1 and m2, return a map with all elements of m2 with keys that exist in m1
22:01grrrtsolution is similar: '(filter (fn [[k v]] (contains? m1 k) m2)'
22:17holmakgrrrt: Check out select-keys
22:18grrrtholmak: ah thanks! I suspected there'd be a function for this, it's just a matter of finding the right one :)
22:18holmakI just stumbled across it today by accident.
22:19holmakI've found it's a good habit to read a half-dozen surrounding functions on the Clojure web site for every one you mean to look up.
22:19holmakIt has really paid off for me!
22:20grrrtI have the clojure sources permanently open in an editor. The things you learn when you're randomly browsing them!
23:17bpattisonso why does (str-join "abc" "") return "" -- shouldn't it produce "abc"
23:17hiredman,(doc str-join)
23:17clojurebot"clojure.contrib.str-utils/str-join;[[separator sequence]]; Returns a string of all elements in 'sequence', separated by 'separator'. Like Perl's 'join'."
23:18hiredman,(seq "")
23:18clojurebotnil
23:18hiredmanmakes sense to me
23:20bpattisonI must be confused as to what it does
23:20bpattisonI'm looking for a method that concat to strings together
23:21Chouser,(str "abc" "123")
23:21hiredman,(doc str)
23:21clojurebot"abc123"
23:21clojurebot"([] [x] [x & ys]); With no args, returns the empty string. With one arg x, returns x.toString(). (str nil) returns the empty string. With more than one arg, returns the concatenation of the str values of the args."
23:21hiredmanbpattison: function
23:21hiredmannot methods
23:22bpattisonlol -- okay thanks -- yep str does what I want -- duh I knew that