#clojure logs

2010-11-28

00:12KirinDaveHum
00:12KirinDaveWhat is the difference between defvar and def?
00:14KirinDaveDoes defvar just give a more convenient syntax for dropping vars for things like documentation purposes?
00:24pppaul(ns your.namespace.here
00:24pppaul (:require '[clojure.string :as str])) gives me an error
00:24pppauljava.lang.Exception: lib names inside prefix lists must not contain periods (NO_SOURCE_FILE:50)
00:25pppaulnm, i'm not supposed to quote the vector
00:26pppaulfound it on this site: http://clojure.github.com/clojure/clojure.string-api.html#clojure.string/split
01:12replacaKirinDave: yeah, that's right.
01:13KirinDavereplaca: Figured
01:14replacaKirinDave: I think that part of the thought is also that defvar is in itself documentation (that this is a ver and not a memoized function or some other thing you could do with def)
01:16replacas/ver/var/
01:16sexpbot<replaca> KirinDave: I think that part of the thought is also that defvar is in itself documentation (that this is a var and not a memoized function or some other thing you could do with def)
01:30Guest43529quit
01:54ossareh_I've a situation where I need to rewrite a function, I think the correct way to do this is with a defmacro. essentially something like this: (wrap-this (some-fn "x") (some-fn "y")) -> (some-fn "x" "y") (some-fn "y" "y")
01:55ossareh_additionally I want to check whether the forms have a second argument and augment it if it is there.
01:55ossareh_However when I do this I end up with the following output: Unable to resolve symbol: f__41681__auto__ in this context
01:56ossareh_(defmacro add-arg [fn] (let [[f#] fn] (prn f#) `(f# "x"))) - called as (add-arg (prn))
01:56RaynesYou don't want to use gensym outside of syntax quote.
01:57RaynesJust name it f and then refer to it as ~f in the syntax quote.
01:58ossareh_Thanks, Raynes!
01:58Raynesuser=> (macroexpand '(add-arg (prn)))
01:58Raynesprn
01:58Raynes(f__2635__auto__ "x")
01:59ossareh_cool - that works - let me work this into my larger requirement.
01:59RaynesMacroexpand is your best friend. Treat him well, and he'll always be there for you.
02:04ossareh_ye - I rely on it pretty heavily, got caught out by the gensym stuff.
02:05ossareh_is there something from your macroexpand output that should have triggered something for me?
02:06Raynesossareh_: Well, now that I think about it, not really. Since you didn't know to not use gensym outside of syntax quote, it made perfect sense.
02:52ossarehand in the same vein (i.e. rewriting forms) what is the correct way to iterate [& forms] without executing each form? (defmacro add-arg [& forms] (for [[fn] forms] `(~fn "x"))) => (macroexpand '(add-arg (prn) (prn)) => ((prn "x") (prn "x")). Where as I want (prn "x") (prn "x")
03:01ossarehalso, I chose to use for since using map (my first attempt) requires I ~@ forms which seems to then be executing the (prn) arguments
03:13hoeckossareh: macros can only return a single expression
03:15hoeckossareh: but it could expand into (do (prn "x") (prn "x"))
03:16hoeckand it doesn't matter what code map or for or whatever you are using in the macro, what matters is the right quoting and unquoting
03:18hoecke.g. with map: (defmacro add-arg [& forms] `(do ~@(map (fn [fn] `(~fn "x")) forms)))
03:18ossarehahh, the splice being up front... of course!
03:24ossarehthanks hoeck that did the trick :)
03:26hoeckossareh: you're welcome :)
04:53neotykGood morning!
04:55LauJensenMorning!
04:57neotykHow does one declare contract for interface from Clojure to Java?
04:57neotyknow I return map-of-maps
04:58neotykbut have no way to be sure that for new entities I will follow same syntax
08:11lyonscfhey guys, I
08:11lyonscfI'm having a little bit of trouble with webmine
08:11lyonscfI can't seem to find a resource for including the ilb
08:12lyonscfin the (use 'foo.bar.webmine) format
08:16lyonscfoh wait, nevermind
08:17lyonscfjust read into the core
08:17lyonscfthe namespace is webmine.core
08:17lyonscfThanks anyway :)
08:27@rhickeyanyone try *unchecked-math* yet?
08:36fliebelmorning
08:45jaleyhi guys! can anyone give me a little advice on how best to interoperate with Quartz (the scheduler) from clojure? I don't like that insists on constructing job objects itself from a provided class, because this way i think i'd need to write loads of boiler plate wrappers around clojure functions to get the callback... any suggestions?
08:47raekjaley: I don't have any experience with Quartz, but interop with cron4j is very simple: (doto (it.sauronsoftware.cron4j.Scheduler.) (.schedule "30 16 * * 1-5" #'some-function) .start)
08:48raekI don't know if cron4j provides what you are looking for, but using it requires minimal amount of boilerplate
08:49jaleyraek: that looks simpler, thanks
08:49raek(the example runs some-function 16:30 every Monday-Friday)
08:49jaleyraek: the problem i have with Quartz is that the interface to add a job is: addJob(JobDetail, Trigger, Class) - where the service creates the job instance based on the class you pass in
08:50LOPPwhy the quote on #'some-function
08:50raekI have an IRC bot that I like to hack on while it's running
08:51LOPPdo you have to change the code if you stop using the quote?
08:51jaleyraek: so with quartz i don't think i could avoid a load of gen-class...
08:51raekthe var-quote lets me redefine that function and next time the task is executed, it will use the new version
08:52raekLOPP: I think you need to restart the scheduler (which is pretty simple too) if you want it to use the new version
08:52raekhrm, I might be wrong in this case. if you put the function in a datastructure, you need the var-quote
08:53raekbut for function parameters...
08:53LOPPbecause I had to make special code to have functionality where I could use either var-quoted fns or normal fns
08:53LOPPfor instance #() ones
08:55raekok, it turns out that when passing the function directly as an argument, you don't need the var-quote
08:56LOPPthese things confuse me :D
08:57LOPPI always have to determine need for quotes with testing
09:02raekI think that when a symbol represents a var, the compiler will compile in a reference to the var itself rather than its value
09:02raeklocals introduced by let and function parameters are different
09:04LOPPI think of this in a different manner
09:05LOPPcompiler evaluates vars whenever they are part of an expression
09:06LOPPthat includes passing them as function parameter or adding them to a data structure
09:06LOPPso if I add a fn to a data structure, the var will get evaluated and value added to the list
09:07LOPPa function using the list of fns will get the same fn every time even if I change the function bound to the var
09:08LOPPwhen the var of fn is passed as an argument to the function, it gets evaluated to value each time it's called so changing function bound to var changes the behavious of the program
09:08LOPPanyway that;'s how I see it
09:09lyonscfWhat's the best practice for declaring static global vars?
09:09lyonscfIs it just a def at the top of the file?
09:09raekLOPP: makes sense
09:11raeklyonscf: a globally accessible value would be a simple def
09:11lyonscfthanks raek. :)
09:11raekwhat do you mean by "static"?
09:11lyonscfstatic meaning constant
09:12lyonscfbut obviously the focus is on immutability in Clojure.
09:14LOPPI hear in 1.3 vars will be immutable by default
09:14LOPPso you'll basically get public static final stuff
09:16raekthey can still be redefined, I think
09:16raekbut they cannot be dynamically rebound with 'binding'
09:19LOPPdoesn't that kinda defeat the purpose
09:22raekin 1.3, when a var is redefined, functions using it will be recompiled at the first time they are called after the redefinition, IIRC
09:22raekso there is some "var version" check on each function entry, I think
09:23raekredefining a var should only be done when correcting a running system, or during development, though
09:25LOPPdoesn't that incur a performance penalty though
09:25raekit is a lot faster than the current implementation
09:25raekif I understand things correctly
09:28raekbut yes, having a language allowing interactive development cannot be exactly as fast as a purely compiled language
09:28raekbut the HotSpot JVM makes a really good job
09:28raekand the 1.3 stuff lets it do much more of its magic
10:07LOPPso you are saying that var version check is done now too
10:16raekI think think this is in the master branch now
10:32jarpiainreferences to non-:dynamic vars are compiled into calls to Var.getRawRoot() that just returns the private volatile instance field
10:35jaleynot in the doc string, but does anyone know if there's a keyword option to add a watch function to an agent?
10:36jaleyi mean for the agent function, of course. just to avoid needing add-watch
11:31djpowellis unchecked-math supposed to work with binding?
11:32djpowell(binding [*unchecked-math* true] (byte 200)) fails
11:32djpowellbut (set! *unchecked-math* true) (byte 200) works
11:35djpowellah - does it only affect what is compiled?
11:35djpowellok that makes sense
11:37djpowellI think. I'm not sure how you would go about turning it on and resetting it tho?
12:20zmyrgelhi, how can I test if item implements protocol/
12:20zmyrgel?
12:37kaiserhi, guys
12:37Guest43491i'd like to execute n times a function and get the last result...what's the best construction for this?
12:38raekis this for java interop?
12:38Guest43491no
12:40Guest43491in fact, i want to accomplish the following...
12:40Guest43491i have a function 'a'
12:40Guest43491and the result must be the input of the same function 'a'
12:41Guest43491and i want to execute this function n times...
12:41raeksounds a bit like iterate
12:41raek,(doc iterate)
12:41Guest43491i have performance issues
12:41raek&(doc iterate)
12:41sexpbot⟹ "([f x]); Returns a lazy sequence of x, (f x), (f (f x)) etc. f must be free of side-effects"
12:41Guest43491so, i'm reading about lazy-seq with recursion...
12:42Licenserevening
12:42Guest43491hmm...gonna try this iterate...
12:43raek&(take 10 (iterate inc 0))
12:43sexpbot⟹ (0 1 2 3 4 5 6 7 8 9)
12:43Licenseriterate passes the result of the current call to the next call
12:45Guest43491thanks
12:46raek&(let [compose-n-times (fn [f n] (fn [x] (nth (iterate f x) n))), plus-10 (compose-n-times inc 10)] (plus-10 5))
12:46sexpbot⟹ 15
12:48opqdonut&(let [compose-n-times (comp (partial reduce comp) repeat) plus-10 (compose-n-times 10 inc)] (plus-10 5))
12:48sexpbot⟹ 15
12:52slyrus_technomancy: thanks!
12:58Guest43491thank you raek
13:29miltondsilvaHi
13:32miltondsilvaI have a vector like [:f :- :push :f :pop] and would like to generate code like ((forward) (rotate) (push-matrix (forward))) do I need a macro to do this?
13:33raekno
13:33chouser_no, though once you've generated the code you'll need either a macro or 'eval' to run it.
13:34miltondsilvahmmm ok but is it easier with one? I've never felt the need to use macros so I haven't learn how to used them
13:34raekyou could do a function that interprets that vector and executes the functions
13:35miltondsilvaI was trying to use strings and read-string + eval.. but somehow it's getting a bit ugly
13:35raekthe :f and :- case should be pretty simple:
13:37raek(defmacro foo [x] (if (empty? x) nil `(do ~(case (first x) :f `(forward) :- `(rotate)) (foo ~(rest x)))))
13:37raekor somehing like that
13:38raekmiltondsilva: there is no need to go through strings
13:39raeka macro is just an ordinary clojure function that takes unevaluated code expressions as its arguments and returns some new code
13:39chouserraek: replace "just" with "like" and I'll let it go. :-)
13:40raekright.
13:40raekthe &env thingy?
13:40chouseryes, and &form
13:41miltondsilvahmm.. thanks I think I can do it now
13:53IntertricityIs there any documentation on using .Net in the clojure-clr implementaiton?
13:54Intertricity*implementation
13:54Intertricitylike how to access dictionaries, or the system libraries
13:55Rayneschouser: Why is &form useful?
13:58chouserRaynes: I think primarily for pulling metadata off the form and the first symbol
14:02jjido_can I tell Clojure to tell the JVM to reload a Java class?
14:02chouseryou can generate a new class with the same name with deftype and defrecord, but otherwise no
14:03jjido_ok
14:03chouseryou may be able to use some other tool to do that, javarebel or whatever, but I don't know if anyone has gotten such things working with clojure
14:04jjido_I will just restart the JVM no big deal.
14:50Intertricitywow clojure is hard xD
14:51IntertricityI have to chew on chunks of tutorials for a while to grasp the concept
14:51DeranderIntertricity: have you had any experience w/ functional programming before?
14:52IntertricityDerander, not really, I just did basic C and Python before that
14:53Derandermakes sense then :-)
14:53Intertricityhehe
14:54IntertricityWith the beginnings of clojure on clr though, I want to try porting my .Net program over to clojure
14:54IntertricityI've been waiting for the clr implementation to start learning it
14:54Deranderit's fun
14:55Derandernot a java fan?
14:55IntertricityDerander, do you know where I can get docs on how to use clojure-clr to access the .Net libraries like system or dll's?
14:55IntertricityDerander, the library I use is all .Net unfortunately
14:55Deranderno, unfortunately, I have no idea. I've never used clojure-clr.
14:55Intertricityaw nutbunnies
14:56IntertricityI was originally using ironpython
14:56Intertricitybut I long to see parenthesis in my code xD
14:56Deranderright
14:56Derander:P
14:56raekfor interfacing with .net classes, I suspect it should work like java interop in "clojure-jvm"
14:56Deranderthat would be my guess too
14:56hoeckIntertricity: I only managed it to compile clojure-clr once and ran a simple hello-world windows dialog
14:57Intertricityhoeck, they have binaries available now
14:57hoeckIntertricity: and does it now run on mono?
14:57IntertricityI wouldn't know, sorry
14:57raekIntertricity: ​http://clojure.org/java_interop
14:57Intertricityraek, ty :)
14:58hoeckthe interop seemed the same as on (java-)clojure, import classes and then call .methods on them
14:58IntertricityI dont' know much about java if any, I wonder if it's simlar to this to laod a dll?
14:58Intertricity*load
15:01hoeckIntertricity: how do you load a dll in .net?
15:02Intertricityclr.AddReference("System", "OpenMetaverse","OpenMetaverseTypes")
15:02Intertricityfrom OpenMetaverse import *
15:02raekin java-land, you start the jvm instance with a classpath option. the classpath is a list of directories and jar-files that contains .class-files
15:02IntertricityI see
15:04IntertricityHm. well tihs is a little closer http://www.mail-archive.com/clojure@googlegroups.com/msg24944.html
15:04Intertricitybut nothing about dll's
15:08hoeckIntertricity: the assemblies may reside in some dll, and on windows it may be enough when your dll is on the search path
15:09Intertricityhoeck, how would I define the path myself? I usually keep the library I'm working with close to my sourcefile atm
15:09Intertricityor if you have any past code that shows it, that would be even better >.>
15:09IntertricityI can't find docs or examples
15:10hoeckdon't know about .net, but win32 dlls have to reside in %PATH% or . or win\system32\ or so
15:11hoeckIf you have a working IronPython solution, the just try that (System.Reflection.Assembly/LoadWithPartialName "System.OpenMetaverse.OpenMetaverseTypes")
15:12hoeckfollowed by an (import '(System.OpenMetaverse OpenMetaverseTypes))
15:12hoeckif IronPython finds that dll without tweaking, clojure-clr should do the same
15:12Intertricityhoeck, ty :)
17:44jweiss_i'm trying to introduce clojure to co-workers in the most painless way possible. I think the labrepl tutorial is great, but I don't want them to go thru the pain of installing the prereqs until they're "hooked". I can host the labrepl webapp for them, but any suggestions how to host a repl?
17:45jweiss_i checked out http://tryclj.licenser.net/ , but there's no cut/paste.
17:45Raynesjweiss: try-clojure.org is the actual domain.
17:46RaynesI use jquery-console which doesn't support copy and paste.
17:46RaynesIn any case, there is no way to run a server-side REPL without sandboxing, and even then it may not be totally safe.
17:47jweiss_Raynes: googling "try clojure" links to the address i pasted. but yeah i know that is not the official url
17:47jweiss_Raynes: since it's just co-workers and I can run it on a vm, i'm not concerned with security
17:48jweiss_\some paredit functionality would be nice
17:48RaynesThat it would. It most likely wont happen though. At least, not while jquery-console is being used.
17:50jweiss_Raynes: yeah, i wish there was a way to "webify" a slime session
17:51jweiss_but i don't see how a browser is going to take over those keybindings
17:51jweiss_trying to convince someone to use clojure without them knowing of paredit's existence, well, it doesn't help clojure's cause :)
17:55lucianRaynes: wouldn't a java applet work too?
17:55Rayneslucian: Yes, but applets are ugly and meh.
17:55Rayneshttp://github.com/Raynes/webrepl
17:57lucianRaynes: wouldn't it also be easier on the server?
17:57RaynesYes, but applets are still ugly and meh. :p
17:58jweiss_an applet would be pretty straightforward actually. still no paredit, but no need for security
17:58lucianRaynes: yeah, they do tend to be ugly
17:58Raynesjweiss: If you want, you're welcome to use webrepl.
17:58RaynesIt's ugly as sin, but it'll do the trick.
17:59jweiss_Raynes: let's see how ugly :)
18:00jweiss_Raynes: how do i run it
18:00RaynesAren't there instructions in the README?
18:00jweiss_Raynes: no
18:00jweiss_not the readme on the github page, anyway
18:00RaynesThat sucks. I don't remember how to run it.
18:00jweiss_hehe
18:02jweiss_Raynes: i think you left JConsole out of the deps in project.clj
18:02RaynesIt's included in the source.
18:02jweiss_ah
18:03jweiss_lein doesn't seem to know how to build it
18:03RaynesI would be more helpful, but I'm in the process of moving stuff to a new server. Trying to get sexpbot up and running there.
18:03KirinDaveHum.
18:03jweiss_Raynes: that's ok, i'll figure something out :)
18:04KirinDaveIs there any consensus on best practices in clojure for using protocols and deftype?
18:04Raynesjweiss: lein repl and then use webrepl.core, and then run -init
18:04KirinDaveFor example, what's the right way to make default behavior?
18:04jweiss_Raynes: thx
18:04KirinDaveI had hoped I could do something like: (extend-protocol tester Object (c [d] (a d))), (extend-protocol tester java.lang.Integer (a [b] (inc b)))
18:05KirinDaveAnd have (c 1) return 2.
18:06KirinDaveBut it seems like if you omit a function definition from a protocol map for a given type, it won't try to call the method on a more general type.
18:15brehautis there an XML-RPC library that works with ring?
18:33RaynesOops. Forgot to run it in screen. ._.
18:36dnolena much faster implementation of miniKanren for Clojure - https://github.com/swannodette/logos for the logic / relational programming fans. Lots of Clojure specific additions and tweaks.
19:26markj9anyone have a minute to offer suggestions on why lein is now giving me this error http://pastie.org/1331111
19:51brehautwhat is the naming conventions for defrecord types? is it camel cased like a java class?
20:16jweiss_anyone noticed that labrepl doesn't build anymore? it has a dev dep on autodoc-0.7.0, which depends on clojure-contrib 1.1.0-master-SNAPSHOT, which unsurprisingly is no longer available in the repo
20:18Raynesjweiss: :exclude it's autodoc dependency.
20:19Raynesjweiss: There is an example of using exclusions in sample.project.clj in the Leiningen repository.
20:19jweiss_Raynes: i know how to fix it for myself. but i'm setting up my co-workers to check out the source from github and their source will be wrong
20:19RaynesOh.
20:19jweiss_i was wondering if there was a different command than lein deps i could run that would bypass the dev deps
20:20jweiss_i suppose i could just build an uberjar and distribute that
20:21jweiss_but i was hoping not to have to host anything
20:21jweiss_i guess i could fork the project on guthub
20:21jweiss_that's probably the easiest
20:22KirinDaveAm i the only person a little frustrated by non-seq laziness in clojure?
20:27replacaKirinDave: what do you mean exactly by non-seq laziness?
20:27replacaKirinDave: you mena like vecors not being lazy?
20:27replacas/mena/mean/
20:27sexpbot<replaca> KirinDave: you mean like vecors not being lazy?
20:28replacaok, I'm going to give up on typing now :)
20:29KirinDavereplaca: Ha
20:29KirinDavereplaca: I mean like how you have to force delays.
20:30KirinDavereplaca: Yes, force is idempotent on non-delay objects, but then I'm writing force everywhere on the off chance client code sends my library a delay.
20:30KirinDaveIt'd be better if the force was implicit.
20:31replacaKirinDave: isn't that just the definition of a delay? "That which needs to be forced"?
20:31KirinDavereplaca: Well i wish I had a (lazy ...) then
20:31KirinDave,(doc lazy)
20:31KirinDaveDamn it
20:31KirinDaveThe Secret™ fails again.
20:31replacaKirinDave: make it.
20:32KirinDavereplaca: I am not sure how.
20:32KirinDaveI suspect it's a pretty non-trivial thing.
20:32KirinDaveGonna have to go into the compiler to do it properly.
20:33replacaKirinDave: why, can't you just wrap a delay in an object that implements IDeref which does a force, then the regular deref?
20:33KirinDavereplaca: Doesn't deref already force?
20:33replacaor am I misunderstanding your use case?
20:34KirinDavereplaca: The fact that I have to explicitly force values means I need to expect laziness and just force everything before using it.
20:34KirinDavereplaca: This clutters up the code pretty significantly.
20:35KirinDaveI think from a library-writer's perspective, this means that you won't handle implicit client laziness very often without sacrificing a lot of code readability.
20:35replacaoh, I see
20:35KirinDaveIt'd be great if, if someone passed me in a delay to my library, it was auto-forced at the appropriate time.
20:35replacayeah, you're right, I think
20:35KirinDaveBut like I said, I think it'd need compiler and stdlib support
20:36KirinDaveIf it was more like scala's lazy keyword, we'd see laziness used a lot more in clojure code, I think.
20:36KirinDavePart of the popularity of seqs is their magic.
20:36KirinDaveYou don't have to explicitly force seq values, that happens implicitly as you move along the seq.
20:37replacaso what you're after is "(let [foo (magic (bar baz))] foo)" to have bar called when foo is referenced?
20:38KirinDaveYes.
20:38KirinDaveBut _not_ if, say, foo is just passed as a function argument
20:38KirinDaveOr put into a let.
20:39KirinDaveIt has to be "used" for some definition of used that is not just handling.
20:39replacaKirinDave: actually, you are explicitly forcing the seq: you call next
20:39replacayou're just so used to that that you don't consider it
20:39KirinDavereplaca: Well, the stdlib supports that very aggressively.
20:39replacayup. sure does
20:39KirinDavereplaca: I probably have written "next" like 3 times in my clojure experience.
20:40KirinDaveSo delay could be the mechanism if the stdlib aggressively supported it.
20:40KirinDaveIt'd take an audit of the whole stdlib tho
20:41KirinDaveIt would also make clojure.lang.Delay the Invisible Man of the clojure library. :)
20:41KirinDaveBecause then #(class (delay 1)) would not be what people think it would be.
20:41KirinDaveDerp, why'd I write #?
20:41replacayeah, the decision about when to force is tough too. For how long to you jest keep all the dependent computions deferred and then do it.
20:42replacaVery much like Haskell when you drive it as far as you can
20:42KirinDaveYeah. That's why it'd need compiler support too.
20:42KirinDaveYeah, which would be nice.
20:42KirinDaveI worry I am coming around to haskell.
20:42KirinDaveI don't want to. I love the lisp legac.
20:42KirinDaves/c$/cy/
20:43KirinDaveha
20:43replacaSee I'd rather go with Haskell if I could convince myself it would be anywhere close to as productive as Clojure
20:43KirinDaveI suck.
20:43KirinDavereplaca: That is the issue, isn't it
20:43replacaKirinDave: completely. and I don't think that even being close is possible
20:43replacaKirinDave: but you can do some cool stuff
20:44replacaKirinDave: but these days I can't convince myself to write in any other language than Clojure
20:44replacaKirinDave: of course, I lack your appreciation for C#
20:45replaca:)
22:30ossarehhow would you improve this? (reduce (fn [acc x] (assoc acc (clojure.contrib.string/as-str (first x)) (second x))) {} {:k "k" :v "v"})
22:30ossarehI feel like there is a smarter way to do this - I just don't know enough of the stdlib to know what I should be mapping
22:31brehautossareh well to start you could desctructure your args
22:31brehaut(reduce (fn [acc [k v]] (assoc acc (clojure.contrib.string/as-str k) v)) {} {:k "k" :v "v"})
22:32ossareh(reduce (fn [acc [k v]] (assoc acc (clojure.contrib.string/as-str k) v)) {} {:k "k" :v "v"})
22:32ossarehah
22:32ossarehheh
22:32ossareh:)
22:36chouserwhat does as-str do again?
22:36brehautLike clojure.core/str, but if an argument is a keyword or symbol,
22:36brehautits name will be used instead of its literal representation.
22:36chouser,(name ":k")
22:36chouserer
22:36chouser& (name :k)
22:36sexpbot⟹ "k"
22:36chouser& (name "k")
22:36sexpbot⟹ "k"
22:37chouserlike that?
22:37brehautapparently so
22:37ossarehhuh, didn't know about name
22:37ossarehthanks for that
22:37ossarehsaves me a (use) :)
22:38chouserit wasn't always that way
22:39ossarehdamn straight. I started just over a year ago and it was hard back then.
22:39ossarehyou core people have nailed it, thanks chouser et al.
22:41chouserossareh: you really want a map with keys matching the values?
22:43ossarehchouser: {:foo "bar"} => {"foo" "bar"}
22:43chouserah
22:43chouser&(let [m {:k1 "k2" :v3 "v4"}] (zipmap (map name (keys m)) (vals m)))
22:43sexpbot⟹ {"v3" "v4", "k1" "k2"}
22:43chousernot really any better
22:43ossarehform-dot-clj gives you :keywords, expects strings back.
22:44ossarehI know so little about zipmap - I prefer readability of the reduce solution.
22:47chouser& (apply conj {} (map (fn [[k v]] [(name k) v]) {:k1 "k2" :v3 "v4"}))
22:47sexpbot⟹ {"v3" "v4", "k1" "k2"}
22:48brehautchouser, is there an advantage to using apply conj over into there?
22:48chouserno!
22:48chouseruse into
22:48chouser& (into {} (map (fn [[k v]] [(name k) v]) {:k1 "k2" :v3 "v4"}))
22:48sexpbot⟹ {"k1" "k2", "v3" "v4"}
22:48chouserslipped my mind
22:54brehauti wonder how common that pattern of (fn [[a b]] [(fun-a a) (fun-v b)]) is
22:54brehautseems like it would be common enough to have something like (vec-apply fun-a fun-b)
22:55brehautthat is the mutant offspring of juxt and vec
23:03Rayneschouser: You? Making a mistake? Surely not!
23:09RaynesI must alert the Higher Order.
23:10ossarehlol @ ^