#clojure logs

2011-07-04

00:00hugodnext release of pallet will have image downloading for vbox built in
00:00hugodno, pallet has its own interface to vbox api
00:00technomancycool
00:00technomancyI've got to say, the features of vagrant have really won me over the past few weeks
00:01hugodwe have a computeservice abstraction that gets used to talk to jclouds, vbox, or a node list
00:01technomancyhaving your VM environment be just another file that's checked in is a big win for repeatability
00:01ihodesxiaolongxia: i think you'd be able to show him some practical applications using racket pretty quickly-they've got some great stuff going on. otherwise, i'd point him to stewart's Programming Clojure, and keep an eye on things that are out of date. i still think that's the best book for a beginner.
00:01hugodtechnomancy: yes, definitely
00:02cemericktechnomancy: see, here I was idly thinking of creating yet another build tool, and you're out there showing me why that's just not a healthy life choice ;-)
00:02ihodesbuilding is horrible. horrible. horrible. (still emotional over a week of time spent recovering from usign SVN 1.4, an insane ant build, and a 3mil line codebase) :(
00:05technomancycemerick: yeah, I, uh... I try to lead by example.
00:05technomancy"eat your veggies, boys, or you will turn out like technomancy"
00:07hugodcemerick: any particular features you were idly planning?
00:07cemerickIt's a cautionary tale, to be sure. I've mostly tried to stay away from bikeshed domains, just to avoid the mental anguish it would seem to entail.
00:10cemerickhugod: I've just been taking notes here and there about things various tools get right, and others different tools get wrong, etc. I'm wondering if it's worth trying to find a global maxima, at least for my fanbase.
00:10cemerickThat population being me, of course.
00:10cemerick:-P
00:10amalloyhugod: https://github.com/pallet/ritz links to a 404 version of slime.el
00:10hugodamalloy oops, thanks
00:12cemerickihodes: sorry, missed your msg; 3m LOC?
00:12cemerickMy condolences.
00:13hugodamalloy: should be fixed
00:15amalloyhugod: thanks. apparently i had to completely rip apart my emacs config to start using marmalade so i could have a crack at ritz. it's an adventure so far
00:15hugodamalloy: I try and put of the faint of heart in the readme
00:15technomancyamalloy: fwiw emacs 24 is fairly painless
00:15technomancyplus you can write elisp with lexical scope!
00:16technomancywhich I know you've always wanted
00:16amalloytechnomancy: i switched my office machine from 24 to 23 a week or so ago
00:16technomancyoy
00:16amalloyi *could not* figure out how to get 24 to stop creating new windows and frames of ridiculous sizes every time something wanted to open in a different window
00:17technomancyweird
00:17technomancythe only things I know that try to create new frames are ediff and speedbar
00:17technomancythe former which is easy to disable, the latter which is best avoided
00:17amalloytechnomancy: i was getting new frames for completion buffers
00:18amalloyall i got from #emacs was the usual "bleeding edge is your problem"
00:18technomancywow, crazy
00:18technomancyin cocoa?
00:18amalloylucid
00:19technomancymadness
00:19amalloyactually natty, i guess
00:24amalloyhugod: you mention cake in the Install section, implying it's supported, but i don't see how to launch ritz with cake
00:26technomancyis resolve supposed to work with nested classes?
00:26amalloytechnomancy: eh?
00:27technomancy(resolve 'org.apache.lucene.util.Version/LUCENE_30) ; => nil
00:27amalloytechnomancy: try $ instead of /?
00:27hiredman^-
00:27technomancyerr... I guess it's a field
00:27technomancynever mind
00:28technomancyhow do you dynamically determine whether a class has a given field?
00:28hiredmanhaving resolve work on fields is an interesting idea
00:28hiredmanreflection
00:29hiredmanI can lend you my java reflection in action book
00:29technomancyhiredman: right, because I don't care about the difference
00:29technomancy(def *version* (try (eval 'org.apache.lucene.util.Version/LUCENE_30)
00:29technomancy (catch Exception _
00:29technomancy org.apache.lucene.util.Version/LUCENE_29)))
00:29technomancydang it
00:30technomancymispaste, but you get the idea. it's icky.
00:30amalloy&(-> String .getFields seq)
00:30sexpbot⟹ (#<Field public static final java.util.Comparator java.lang.String.CASE_INSENSITIVE_ORDER>)
00:30amalloytechnomancy: there's a named .getField, i'm fairly sure
00:31hiredmanthere is a wallhack-field function somewhere in contrib
00:31amalloybut all you need should be available in the javadoc for java.lang.Class
00:31technomancyamalloy: that's perfect; thanks.
00:31hiredmanhttp://richhickey.github.com/clojure-contrib/java-utils-api.html#clojure.contrib.java-utils/wall-hack-field
00:31hiredmanfor static fields you use nil for obj
00:32hugodamalloy: add ritz as a dev dependency, and cake ritz
00:33hugodcemerick: commiserations, just been doing that for my ritz maven plugin
00:33amalloyhugod: no good, but that might be because i'm on an unstable version of cake
00:33hugodmm, my version of cake seems very broken
00:34cemerickhugod: ritz? I'm behind the times :-(
00:34amalloycemerick: swank-clj's new name
00:34cemerickAnnotations in Clojure are mostly *bleh*. It's JAX-RS that's absolutely dead-nuts infuriating.
00:34cemerickah, ok
00:34cemericknice
00:34amalloyyeah, i like the name
00:35amalloyone day, far in the future, when i've resurrected my computer, i hope to like the tool too
00:35cemerickIt's amazing to me that that's what's considered the web services hotness in Java-land these days.
00:35hiredmanalso the clojure tests fail in annotations tests when run on openjdk7 on osx
00:37cemerickI think it's the only place in the book where we have a "don't use this stuff, really" warning.
00:54hugodamalloy: I'll have a look at the cake plugin tomorrow when I get cake to run again
00:55amalloyhugod: thanks. in the meantime i'll just use lein; cake seems to have a lot of headaches
00:58amalloyhugod: actually it doesn't work with lein either: Exception in thread "main" java.lang.ClassNotFoundException: com.sun.jdi.VirtualMachine (jdi.clj:1)
00:58amalloyi imagine this is because i have openjdk rather than sun/oracle
06:03lnostdal-laptopring seems to mess around with stdout (*out* ?) or something .. debug output using println doesn't show up in slime here
06:04lnostdal-laptop..and exceptions end up in the terminal; where i started `lein swank'
06:04lnostdal-laptop..is there some way of fixing this? .. i.e. println output should end up in slime, and exceptions also
06:05hoecklnostdal-laptop: the server code runs in a different thread than the slime repl, and slime only redirects stdout of its own repl thread
06:06lnostdal-laptopah, i remember this being an issue with SBCL also .. there was a fix for it though .. hmm
06:07lnostdal-laptop(setf swank:*globally-redirect-io* t) ;; fixed it for SBCL
06:08hoeckfor exceptions, you could wrap your handler bodies in (try (do ) catch Exception e (swap! *server-exceptions* conj e)) and then manually throw the last exception or so from the slime repl
06:08hoeckor mess with the default exception handler of the thread the ring handler is invoked in, probably by modifying some server config
06:11hoecklnostdal-laptop: maybe (System/setOut *out*) works
06:15lnostdal-laptop(let [*out* *out*] (defn handler [req] (binding [*out* *out*] ...)))
06:15lnostdal-laptopseems to work
06:16lnostdal-laptop..with regards to output and stuff
06:18halfprogrammerlnostdal-laptop: the stacktrace middleware prints the exception in *err* stream
06:18halfprogrammerthat is why you see exception in lein repl
06:23lnostdal-laptopok
06:24lnostdal-laptopi'm not using that middleware though
06:24halfprogrammeroh
06:25lnostdal-laptop(..should i? .. i'm not sure what that middleware does; i thought it was used to display the stacktrace on the web page; which is not what i'm after..)
06:28lnostdal-laptopis there a `break' ..for triggering an exception?
06:29halfprogrammerlnostdal-laptop: as far as I remember it displays the stacktrace both on the web page and on the *err* stream.
06:30halfprogrammerI am not getting what you mean by `break
06:31lnostdal-laptoplike http://www.lispworks.com/documentation/HyperSpec/Body/f_break.htm
06:32halfprogrammerif you want to insert breakpoints you can use swank.core/break.
06:33lnostdal-laptopusing this Javaish thing seems to work: (throw (Exception. "I got here"))
06:33lnostdal-laptopah
06:33halfprogrammer:)
07:45peteriserinsI want to create a macro that serves as with-connection-to-my-database (with known credentials)
07:46peteriserins(defmacro with-connection-to-mydb [db-spec & body] (let [credentials ..] (with-connection ~db-spec ~@body)))
07:46peteriserinstried unquoting the let and it didn't work
07:46peteriserins*backquoting
07:52rlbpeteriserins: what are you trying to do? i.e. when should credentials be computed?
07:52peteriserinsrlb: compile time
07:52rlbSo what didn't work?
07:53peteriserinsfor starters, I need to have db-spec as a symbol
07:53peteriserinsand I cannot find how to do that
07:55rlbDo you have an example of a form the expansion you'd like?
07:56peteriserins(with-c-mydb db (print "Credentials: " db))
07:59peteriserinsrlb: I actually see now that the db parameter is redundant
07:59peteriserinsrlb: it should just be [& body]
08:00rlbOK.
08:01peteriserinsrlb: OK, it works now
08:01peteriserinsrlb: I surrounded everything with #
08:50gfrlogif I have a long (millions) seq of numbers, (apply + coll) and (reduce + coll) ought to perform equivalently, right?
09:02halfprogrammergfrlog: should it necessarily be the same?
09:03gfrlogwell I can't think of why it ought to be different. I only ask because it feels weird to call a function with millions of args.
09:03halfprogrammerwont reduce take more time?
09:04gfrlogyou think + is optimized for lots of args?
09:04Chousukeapply + calls reduce so no
09:04gfrlogah yeah, I see that in the source now
09:04halfprogrammerhmmm
09:04gfrlog([x y & more] (reduce + (+ x y) more))
09:04Chousukein some cases apply is faster though
09:04Chousukelike apply str
09:05gfrlogStringBuilder
09:05halfprogrammerhmm
09:05gfrlogChousuke: interesting, thanks
09:06Chousukein general, if you expect that a function can do something smart if it controls what to do with more than two args, then use apply.
09:06Chousukeotherwise, reduce is fine
09:30archaic`hi. anyone out there?, how come in compojure/ring? a route (GET "/" [] (println "foo")) will print foo twice whenever i refresh the browser at uri / ?
10:30msapplerhi
10:30msappleri want to share the source code of a clojure game I developed on google code ... what licence is appropriate?
10:49gfrlogarchaic`: you could use CURL to check if the repetition happens in the app or the browser
11:19msapplerokay I open sourced my game under MIT: http://resatori.com/open-sourcing-cyber-dungeon-quest
11:33ejacksonmsappler: congrats !
11:35cemerickmsappler: looks pretty fun — reminds me of gauntlet from my C64 days :-D
11:36cemerickyou should put a new video up on the google code page — I had to hunt around for the one you did in March
11:37msapplerthanks ... just have to find out how to put videos pictures on google code
11:37cemerickOr, just a permalink to it on your blog or something *shrug*
11:40msapplerput the old video there :) https://code.google.com/p/clojure-rpg/
11:42cemericknice; I'll tweet tomorrow when more people are around
12:08matthias__,(doc replicate)
12:08clojurebot"([n x]); Returns a lazy seq of n xs."
12:14pcavsWhat's the best way to test reading from standard input with clojure + leiningen?
12:37matthias__someone should add a list of the most popular clojars to clojars.org
12:55fliebelWhat is "the best" was of serializing Clojure data structures? Just print and read, or is there something more advanced?
12:55fliebel*way
13:06rlbfliebel: if you're just going to/from clojure, I'd think read/write unless you have special needs.
13:06rlbfliebel: (for clojure s/write/pr/)
13:22fliebelrlb: Okay, fine :)
13:26midsand if you need performance / compatibility probably thrift or protocol buffers
13:26fliebelmids: But then you'd need to specify the format beforehand, right? Or can you just say (thrift ["aa" 3])
13:28midsyes
13:28midserr, yeah you need to specify the format beforehand
13:28fliebelI that case I'd rather use... the ztellman thing.
13:29fliebelgloss
13:30rlband if you need to speak to python, etc., perhaps json...
13:31midsor XML :P
13:41babilentechnomancy: ping
13:47ilyakThing I don't like about Clojure:
13:48ilyakSometimes it treats java collections as first-class collections. Sometimes it doesn't.
13:48ilyakIt's not mentioned in docs and it's painful
13:48ilyakI guess I'll have to roll out some my own collection functions
13:48ilyak,(contains? (Collections/singleton 1) 1)
13:48clojurebotfalse
13:49ilyakThis sucks
13:53gfrlogthat's funny it returns anything
13:53gfrlog,(contains? :foo :bar)
13:53clojurebotfalse
13:53gfrlogweerd.
14:25agumonkeyhi all
14:29agumonkeyanybody knows why jline fails when moving cursor or deleting/backspacing ?
16:45amalloy&(java.util.Collections/singleton 1)
16:45sexpbot⟹ #<SingletonSet [1]>
16:45amalloy&(java.util.Collections/singleton (into-array [1]))
16:45sexpbot⟹ #<SingletonSet [[Ljava.lang.Integer;@72fd0e]>
16:45amalloyhm. well duh, of course that's not variadic. never mind :P
17:03pcavsHow does one support default values in a idiomatic, succinct way? Does one have to use multimethods and then pass the default value to the expanded version of the function?
17:06amalloypcavs: your suggested solution doesn't make any sense as far as i can tell. by "multimethod" do you mean "function with multiple arities/bodies"?
17:06pcavsyes, sorry
17:06amalloyif so, that's one common way to do it
17:06pcavsalrighty, what's the other?
17:06amalloyanother is to use a map and destructure it with the :or key
17:07amalloy&((fn [& {:keys [a b] :or {b 10}}] [a b]) :a 9)
17:07sexpbot⟹ [9 10]
17:23amalloymatthias__: btw, i've never used replicate. these days repeat does the same thing in fewer characters; i think replicate was probably written when repeat didn't take an N argument?
17:23davekongI am getting the error: Wrong number of args (1) passed to ... for a function that always takes one argument, any ideas what could be going on? I tested it in the repl and I don't get an error but within my program I do
17:24matthias__,(doc repeat)
17:24clojurebot"([x] [n x]); Returns a lazy (infinite!, or length n if supplied) sequence of xs."
17:24amalloydavekong: is it a macro?
17:24davekongamalloy: no
17:26gfrlogdavekong: is it a function you defined?
17:26davekonggfrlog: yes
17:27davekongThe argument I am passing is a map if that is of significance
17:28gfrlogshouldn't be. For lack of any other ideas, could you show us the function definition and call?
17:28davekongsure
17:31davekonghttp://codepad.org/h2RwYCif gfrlog , the call is on the line with the CALLE HERE comment, with-client-socket is a macro
17:38SomelauwHas cake, leininingen, emacs or anything an interactive mode? Does clojure-jack-in have a manual which possibly explains it?
17:38amalloyemacs is one giant interactive mode
17:39amalloydavekong: fwiw, the (((game :rules) :max-raises) (betting-round game)) construct is confusing to me
17:40amalloyi'd probably write it as a get-in
17:41davekongamalloy: okay thanks, I'm I still pretty new to clojure
17:43amalloydavekong: i'm not sure if it's a common thing or just my personal preference, but (:foo m) feels a lot more natural to me than (m :foo), though the first only works for keywords
17:43ibdknoxamalloy: I'm the same way
17:43amalloybut i'm afraid i don't see anything in your code that would throw the exception you're seeing
17:43Somelauwamalloy: what manual page of emacs should I read to learn about interactive mode?
17:44amalloySomelauw: if you have a version of clojure-mode that has jack-in, you should just be able to call it and it will start up a repl buffer. but ask technomancy, if that doesn't seem to work
17:46Somelauwamalloy: that already works. But I have a file with code and want to test the code in that file.
17:46amalloyC-c C-k compiles/runs the current file
17:46SomelauwSo I want to make the functions in that file accesible from the repl.
17:47amalloyC-c C-c compiles the top-level form you're currently pointing at; C-x C-e evaluates the form (not necessarily top-level) immediately before point
17:47amalloythere's http://www.pchristensen.com/slimecommands.pdf for a slime cheat sheet - clojure's swank doesn't support all of these yet, but you can try something and hope
17:48SomelauwWell thanks. C-k, C-k seems to work. Any good tutorial or reference since I want to learn more?
17:49SomelauwOkay, thanks for slime-commands.
17:49amalloyi bet technomancy's screencast covers this sort of thing
17:52SomelauwWhich screencast do you mean?
17:55amalloyhttp://technomancy.us/120 i think. i haven't watched it
17:56Somelauwokay, thanks, I will take a look at it
18:05davekongamalloy: I figured it out, the wrong number of args was to #(= \r) not the function itself.. that should be #(= \r) or using partial
18:06amalloydavekong: good lesson. always paste the stacktrace
18:06amalloywhich would be pretty clear in your case
18:07amalloywrong number of arguments (1) passed to my.game$legal-actions$fn__5786 or something
18:07amalloyrather than: wrong number of arguments (1) passed to my.game$legal-actions
18:07davekongamalloy: http://codepad.org/X1iawnyY
18:10davekonghopefully now that I understand the stack a little better I won't need to ask next time
18:10davekongstack trace
18:10amalloydavekong: in this case the thing that's useful is knowing how clojure creates classnames for functions
18:11amalloyactually i'm not sure why there's no numbers after the $fn in your example. but basically, each closure is named <enclosing-function-name>$fn__nnnn
18:12amalloyeg, ##(class (partial + 5))
18:12sexpbot⟹ clojure.core$partial$fn__3678
18:12davekong##(class #(+ 5))
18:12sexpbot⟹ sandbox10545$eval13084$fn__13085
18:13davekong##(class #(= \r))
18:13sexpbot⟹ sandbox10545$eval13093$fn__13094
18:13davekonghmm
18:14amalloydavekong: of course learning that you need to include % in the function is a good lesson, but i'd solve your problem by using a set as a function: (filter #{\r} (round-actions game)
18:14gfrlogdavekong: sorry bout wandering off.
18:15davekongnp
18:15amalloyand you can do the same in the cond expression in play-game: (cond (nil? msg) game, (#{\# \;} (first msg)) (recur game))
18:15gfrlogdid it get sorted out? lotta stuff to read through...
18:15amalloyyeah
18:16gfrlogoh I see it was the anon function
18:16gfrlogthose are fun
18:16amalloygfrlog: today's lesson was for us to always demand a real stacktrace, not a summary
18:17gfrlogamalloy: could you repeat that as a stacktrace?
18:17amalloy$kill gfrlog
18:17sexpbotKILL IT WITH FIRE!
18:19davekongneat
18:19davekongI like how concise clojure can get
18:20mrnex2010What would be a simple way to execute code upon invoking lein repl? (edgar goncalves sais that since lein 1.3 u cant just put it in the project.clj)
18:22gfrlogwoah
18:22gfrlogI was gonna make a joke that you could make a user.clj and just stick your code in there
18:22gfrlogthen I tried it and it worked
18:23gfrlogit worked...twice actually.
18:23davekongWell I noticed core.clj gets loaded automatically?
18:23amalloyi think user.clj is deprecated though
18:23gfrlogprobably has something to do with that "server listening..."
18:23gfrlogoh does it?
18:23mrnex2010da hell? if i have a user.clj in the project, it will execute that code?
18:23amalloyor something like that
18:23gfrlogmrnex2010: did it for me
18:24gfrlog$ lein repl
18:24gfrlogUSER
18:24gfrlogUSER
18:24gfrlogREPL started; server listening on localhost:27883.
18:24gfrloguser=>
18:24gfrlogwhere user.clj contains (println "USER")
18:24mrnex2010oh thats nice!!
18:24gfrloglemme def something and see if it's there...
18:25gfrlogthat works too
18:25amalloypft. you wish
18:25mrnex2010coz i wanna make something that imports all namespace in the project for developement purposes
18:25gfrlogyeah core.clj don't work
18:25davekongmaybe it is only when you say it is main
18:26gfrlogdavekong: confirmed
18:26gfrlogdavekong: and once again it loads it twice
18:29mrnex2010thank you very much guyse
18:32SomelauwI think I really hate emacs, but like its interaction mode. So I will just program in vim and refresh the file in emacs whenever I want to test something.
18:32mrnex2010srry gfrlog, where did you place the user.clj?
18:33gfrlogmrnex2010: src/user.clj
18:33mrnex2010ty
18:33mrnex2010YaY!
18:37amalloySomelauw: a lot of the benefit comes from things like having documentation available while editing
18:37amalloyeg, start typing a function call and it gives you hints about what args it takes
18:39gfrlogwhy nobody builds SLIMV?
18:39amalloygfrlog: you need it built for you?
18:39amalloyi can't tell if you're punning or clueless; slimv does exist, though i assume slime is better
18:40gfrlogoh I'm clueless
18:40gfrlogI need to learn to google before I announce stuff I make up
18:41gfrlogman if this thing works halfway decently that might be the nail in the coffin of me learning emacs
18:42amalloygfrlog: you should hang out in here when someone asks how to install slimv
18:42amalloyit's like having to invent the wheel every time you build a car. so many things to do
18:43gfrlogbut every 5th question is about swank/slime
18:47amalloygfrlog: right at the moment my slime is broken because i wanted to try out ritz. so i guess i'm not in a position to brag about slime's simplicity. although i did get it set up on a fresh ubuntu install in no time at all
18:48gfrlogwhat about SLIMW?
18:48gfrlog(Word)
18:49gfrlogsorry, I won't do it again...
18:52amalloygfrlog: you should be able to put together a convincing demo of SLIMW by next april 1st
18:53amalloyor the conj. surely there's space for some comic relief
18:55gfrlogamalloy: if it didn't require mucking about in all that windows stuff I'd think about it
18:55amalloy$google microsoft word apple osx
18:55sexpbotFirst out of 2600000 results is: Microsoft Office for Mac Downloads and Updates | Office For Mac
18:55sexpbothttp://www.microsoft.com/mac/downloads
18:56gfrlogamalloy: half as gross
18:56amalloy*chuckle* sometimes you have to get your hands dirty for a laugh
18:57gfrlognow with manual syntax-coloring!
18:58amalloyheh
18:59amalloyClippy: It looks like you're trying to: call a function! Would you like me to insert the closing ")" for you? Y/N
18:59gfrlogoh I know which letter I'm clicking
19:00gfrlogit's never been easier to export your .clj files to outlook!
19:03gfrlogI wish I knew how to get jvisualvm to tell me the total executation time for the functions...
19:25gfrlogif (binding [*warn-on-reflection* true] ...) does not output any warnings, does that mean that there's no benefit to adding type hints to the code?
19:49__name__.w abdicate
19:49__name__]dict abdicate
19:49__name__Gosh darned.
19:49__name__Tabs are evil.
19:49__name__How did I end up in this tab anyway?
19:50gfrlogyou mean that wasn't some strange invocation of sexpbot?
19:50__name__I blame … GTK.
19:50__name__No it was not.
19:50__name__It was me being an idiot.
19:50gfrlogit looks like vim?
19:51amalloy$dict abdicate
19:51sexpbotamalloy: verb-transitive: To relinquish (power or responsibility) formally.
19:51__name__That would be :
19:51amalloy(for what it's worth)
19:51gfrlog:)
19:51__name__I blame the time of day.
19:51__name__It's 1.51 AM.
19:51amalloygfrlog: i don't expect the (binding) to have any effect at all
19:51amalloyyou have to (set! *warn-on-reflection* true) before you compile the code
19:51gfrlogamalloy: this sounds like useful information
19:51amalloybecause it's a flag that's checked at compile time
19:52gfrlogokay. So if I'm using lein, when does the code get compiled?
19:52amalloyuhhh
19:52gfrlogI guess "lein compile" would have to do it at some point
19:52gfrlogso then where should the (set! ...) go?
19:52gfrlogin my user.clj? :)
19:52amalloygfrlog: i usually set! it in the repl before require'ing my code
19:53gfrlogthat sounds worth a try. I'ma do it.
19:54gfrlogI think it worked.
19:54amalloygfrlog: $ cake check
19:54gfrlogokay, so back to the original question -- does a type hint only help in a situation that produces a reflection warning?
19:54amalloyyes
19:55gfrlogthis is weird because I get almost none
19:55gfrlogthe only warning is when I call (.join ...) on a thread
19:55amalloyokay...so don't add type hints?
19:55gfrlogI guess so. :/
19:55amalloyyou only need them if you're doing direct interop with (.foo) or really-really want to work with primitive numbers
19:56gfrlogI have some integer + :infinity arithmetic that I feel like is probably slower than it could be
19:56amalloy(and getting it right for primitives is a lot harder than you think)
20:03amalloygfrlog: but type-hinting can definitely help by getting you to work with primitives, even in the absence of reflection warnings
20:03gfrloghmm :/
20:03amalloyit's just hard to do right
20:04gfrlogor I could use an array instead of a hash....
20:49amalloygfrlog: i don't think i want to live in a universe where that suggestion makes sense
21:54pcavsWhere's a good place to look (outside of the source) to see how Clojure implements its parallelism? I am under the impression that it is done automatically by the runtime + compiler, but maybe I am incorrect.
21:54hiredmanyou are
21:55pcavsincorrect?
21:55pcavsAny places to look/read?
21:55hiredmanyes
21:56pcavshttp://clojure.org/concurrent_programming is the concurrency screencast good?
22:08pcavsIs it possible to convert a string to a keyword?
22:14pcavssorry, stupid question
22:15pcavs,(keyword "My answer is thus")
22:15clojurebot:My answer is thus
22:16amalloyaugh who put mixed tabs&spaces in clojure.xml?
22:25hiredmanmust be clojure/core
22:34technomancy!guards
22:34technomancyoops
22:34technomancy~guards
22:34clojurebotSEIZE HIM!
22:36seancorfieldquick Q... if i have a vector, is there a built in function to find the index of a given value?
22:37seancorfieldand what's the bot command to find functions based on arguments
22:37hiredman,(.indexOf [1 2 3] 1)
22:37clojurebot0
22:37seancorfieldoh.... a java method... that explains why i couldn't find it :)
22:38seancorfieldi'm a bit surprised there isn't a clojure fn for that (but thank you hiredman )
22:40seancorfieldwhat about finding the key in a map for which the value matches? (just curious now)
22:41hiredmannope
22:41seancorfieldok, just checking
22:41seancorfield(again, just a bit surprised)
22:41technomancy(zipmap (vals m) (keys m))
22:41hiredman,(first (some (comp #{:a} second) {:z :a}))
22:41clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
22:41technomancyrich doesn't like to expose things unless they're performant; see contains?
22:42hiredmanbleh
22:42seancorfield(somefn map value) was what i was looking for
22:42seancorfield(first (vals (filter (fn [[k v]] (= v stuff)) map))) was what i came up with (for stuff in map)
22:42hiredmantechnomancy: well, that is not a very performant solution
22:43hiredmancreating a reverse map
22:43hiredmanseancorfield: right
22:57semperossay I have an arbitrary map m which is {:a "y" :b "z"}, and I need to create (and (= "y" (:a m)) (= "z" (:b m))) to verify the values of the map
22:57semperoshow would I go about generating that and expression?
22:58seancorfielddo you want to test the whole map or just some key/value pairs?
22:58semperoswhole map
22:59seancorfieldso you can just test the whole map
22:59seancorfield(= {:a "y" :b "z"} other-map)
23:00semperosI'm actually using it as part of a clojureql `select` function, which is generating a SQL query behind the scenes from this and expression
23:00semperosI've been able to generate the and expression using templating
23:00semperoshttps://gist.github.com/1064187
23:01semperosbut I'm not sure what to do with it, and was hoping there was some other way
23:13pcavsHey, I'm trying to represent a 2D game-map. I was thinking of going with a vector of vectors, does that sound like a good idea? If so, what's the best way to define such a thing? The game-map is generated, so there's a variable number of rows and cols
23:28amalloy$findfn [1 2 3] 1 0
23:28sexpbot[]
23:28amalloyseancorfield: ^ would get your answer if it were a plain function
23:29seancorfieldthanx amalloy
23:30amalloysemperos: there's no way that gist makes any sense. you're not unquoting inside the for
23:30seancorfield$findfn [1 2 3] 2 2
23:30sexpbot[clojure.core/max-key clojure.core/cond clojure.core/dosync clojure.core/sync clojure.core/char-escape-string clojure.core/with-loading-context clojure.core/*clojure-version* clojure.core/case clojure.core/min-key clojure.core/and clojure.core/locking clojure.core/c... http://gist.github.com/1064215
23:30seancorfield:)
23:30seancorfield*clojure-version*... interesting match :)
23:31amalloyseancorfield: ##({:k :v} :whatever 2)
23:31sexpbot⟹ 2
23:31amalloybut yes, clearly silly
23:33amalloysemperos: clojure.core/and is, guaranteed, not the thing you want to be using here. i'd guess you want every?, but your gist doesn't really make it clear what your intent is if you don't like seancorfield's solution, so i can't solve it "for" you
23:33semperosamalloy: yeah, I realized it didn't make much sense
23:33semperosshouldn't tinker while watching movies with family :)
23:34semperosnot looking for anyone to solve it for me
23:34semperosusing clojureql.core/select to do a query of a database
23:34semperosI want to be able to have a map/record with certain keys that match column names in a database table
23:35semperosand write a function where I pass in this map/record and use all of the entries to fill out the "where" clause of the select function
23:35semperosbasic use looks like (clojureql.core/select (table :foo) (where (= :id (:id my-map))))
23:36amalloyblugh. iirc clojureql has a lot of macro stuff, which makes this not easy
23:45semperosturns our clojureql's `where` macro for which I was trying to do this just puts together a WHERE clause as a string
23:46semperossince I already wrote code to mangle that with some functions for clojure.contrib.sql with strings, this is a non-issue
23:56seancorfieldit's pretty easy to do that with clojure.java.jdbc already
23:57seancorfieldhttps://gist.github.com/1064231
23:57seancorfieldq and qi and naming strategies
23:58seancorfieldupdated gist with those
23:58semperosseancorfield: thanks for sharing
23:59semperosstill using 1.2 myself, but that all makes sense
23:59seancorfieldthat's from our production code (hence ws/worldsingles-db-readonly)
23:59semperosyeah
23:59seancorfieldnaming strategies are new in c.j.j (compared to c.c.sql) but the rest should work
23:59semperosyep
23:59seancorfieldyou know you can depend on c.j.j 0.0.3 even tho' you're on clojure 1.2?