2015-11-05
| 00:03 | gfredericks | maybe that will help me sleep extra effectively |
| 00:04 | gfredericks | goodnight internet |
| 00:04 | rhg135 | Night |
| 00:04 | justin_smith | (Human/sleep (* 8 60 60 1000)) |
| 02:15 | owlbird | WARNING: get already refers to: #'clojure.core/get in namespace: |
| 02:15 | owlbird | (:require [console.app :as app]) |
| 02:16 | owlbird | (app/get "xx") is still conflict with clojure.core/get, how to fix that? |
| 02:16 | opqdonut | it shouldn't |
| 02:16 | opqdonut | perhaps you're also use'ing console.app? |
| 02:18 | owlbird | after 'lein ring server', api works fine, server only shows a warning message |
| 03:05 | owlbird | how to call a 'get' func of current *ns*, not clojure.core/get ? |
| 03:07 | TEttinger | ,(defn get [coll k] "hey guys!") |
| 03:07 | clojurebot | #error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb... |
| 03:07 | owlbird | I (defn get [code] ...) and call is like (if (get code) ...), but it failed |
| 03:07 | owlbird | ArityException Wrong number of args (1) passed to: core/get |
| 03:08 | TEttinger | you can call it with your current ns |
| 03:08 | owlbird | it seems called clojure.core/get, not my 'get' |
| 03:08 | TEttinger | ,*ns* |
| 03:08 | clojurebot | #object[clojure.lang.Namespace 0x7b36f42a "sandbox"] |
| 03:08 | TEttinger | ,(defn reductions [f coll] "hey guys!") |
| 03:08 | clojurebot | #error {\n :cause "denied"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6891]}\n {:type java.lang.SecurityException\n :message "denied"\n :at [clojurebot.sandbox$enable_security_manager$fn__835 invoke "sandbox.clj" 69]}]\n :trace\n [[clojureb... |
| 03:08 | TEttinger | sigh |
| 03:09 | TEttinger | I don't know what it denies, but I guess "everything" |
| 03:09 | TEttinger | hm |
| 03:09 | TEttinger | that core/get |
| 03:09 | TEttinger | that doesn't sound like clojure.core/get |
| 03:09 | TEttinger | ,(get {}) |
| 03:09 | clojurebot | #error {\n :cause "Wrong number of args (1) passed to: core/get"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/get"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.AFn invoke "AFn.java" 32]\n [sandbox$eval91 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval91 invo... |
| 03:09 | TEttinger | nvm |
| 03:10 | TEttinger | but you can call it with your own ns |
| 03:10 | TEttinger | (my.namespace.core/get {}) |
| 03:11 | owlbird | that's too long, i mean, is there some namespace indicator? like :: in c or dot in python? |
| 03:12 | TEttinger | what is your ns here? |
| 03:12 | TEttinger | you can also alias an ns |
| 03:12 | TEttinger | or alias your get fn |
| 03:12 | TEttinger | ,(alias get2 get) |
| 03:12 | clojurebot | #error {\n :cause "Unable to resolve symbol: get2 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: get2 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: get2 in this co... |
| 03:12 | TEttinger | ,(doc alias) |
| 03:12 | clojurebot | "([alias namespace-sym]); Add an alias in the current namespace to another namespace. Arguments are two symbols: the alias to be used, and the symbolic name of the target namespace. Use :as in the ns macro in preference to calling this directly." |
| 03:13 | TEttinger | what am I thinking of... |
| 03:13 | owlbird | OK I know why |
| 03:13 | TEttinger | also, why does it need to be called get? |
| 03:13 | owlbird | I'm using ac-cider in emacs, and *ns* is user> |
| 03:13 | TEttinger | user/get ? |
| 03:15 | TEttinger | ,(alias cs clojure.string) |
| 03:15 | clojurebot | #error {\n :cause "Unable to resolve symbol: cs in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: cs in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: cs in this context"... |
| 03:15 | TEttinger | ,(alias 'cs 'clojure.string) |
| 03:15 | clojurebot | nil |
| 03:15 | owlbird | when I call a function, which then call 'get', it failed |
| 03:15 | TEttinger | ,(cs/join " " [:hey :people]) |
| 03:15 | clojurebot | ":hey :people" |
| 03:15 | owlbird | ac-cider's default ns is user |
| 03:15 | TEttinger | your ns should never be clojure.core I Think |
| 03:16 | TEttinger | that |
| 03:16 | TEttinger | that's used for the clojure language |
| 03:16 | owlbird | en, that's right |
| 03:17 | owlbird | then, it's ignoring to switch ns, if I want to test a function in repl after executing C-c C-c in emacs |
| 03:24 | adamz | Hi. Im using a clojure application (Riemann) and it defines an internal variable as `defonce`. I was wondering it it was possible to redefine a `defonce` variable, as odd as that sounds? |
| 03:27 | kungi | adamz: As far as I know you can only redefine vars with the ^:dynamic metadata. |
| 03:27 | adamz | darn |
| 03:31 | schaueho | kungi: not true |
| 03:31 | kungi | schaueho: Ok? Enlighten me? |
| 03:31 | schaueho | you can only rebind vars that have ^:dynamic |
| 03:31 | schaueho | also, calling defonce twice will not lead to a re-definition |
| 03:32 | schaueho | but you can, of course, call def again |
| 03:32 | schaueho | ,(defonce onceonly 123) |
| 03:32 | clojurebot | #'sandbox/onceonly |
| 03:32 | schaueho | ,onceonly |
| 03:32 | clojurebot | 123 |
| 03:32 | schaueho | ,(def onceonly 125) |
| 03:32 | clojurebot | #'sandbox/onceonly |
| 03:32 | schaueho | ,onceonly |
| 03:32 | clojurebot | 125 |
| 03:33 | adamz | interesting… |
| 03:33 | adamz | i went looking for crazy solutions and it might be really simple |
| 03:34 | schaueho | all the caveats of http://http://clojure.org/special_forms#def apply, though |
| 03:39 | adamz | thanks, that worked |
| 05:14 | jonathanj | i'm having some trouble figuring out bidi route parameters in conjunction with liberator parameterized resources |
| 05:17 | tdammers | question here; is there a difference in how dynamic variable binding works in the context of deftype vs. defrecord? |
| 05:18 | tdammers | because I have this codebase here where it seems like a dynamic variable binding is resolved at definition time for a defrecord, but at method call time for a deftype |
| 05:21 | jonathanj | i have a bidi route something like: ["/foo/" {[:id] my-resource}] |
| 05:22 | jonathanj | and a liberator resource defined like: (defresource foo [x] ...) |
| 05:22 | jonathanj | but trying to access /foo/1234 in my browser results in an error i don't understand: java.lang.ClassCastException: documint.handler$session_resource$fn__10377 cannot be cast to clojure.lang.Associative |
| 05:26 | tdammers | wait, nm |
| 05:27 | tdammers | the binding is resolved at call time for both |
| 05:27 | tdammers | is there a way to have it happen when the constructor is called instead, without explicitly passing it to the constructor? |
| 05:29 | amalloy | no |
| 05:30 | tdammers | dayum |
| 05:30 | tdammers | can I have optional constructor args? |
| 05:39 | mpenet | for records kinda using map->Foo, and types just pass nil and wrap this in a function to hide the ugly |
| 05:40 | mpenet | I mean use a function wrapper to handle this stuff |
| 05:41 | jonathanj | oh... my bidi handler has to be something like: (fn [req] ((foo (get-in req [:params :something])) req)) |
| 05:42 | jonathanj | i don't know if there is a better way of writing that, but it's kind of ugly |
| 05:43 | tdammers | mpenet: yeah, that's what I'm setting out to do now |
| 05:43 | tdammers | mpenet: having some trouble wrapping it in a macro though |
| 05:44 | tdammers | I want to generate something like `(fn [& args] (apply new ~class-name *my-dyn-var* args)) |
| 05:45 | tdammers | but new isn't a fn, so I can't apply it, can I |
| 05:50 | mpenet | why a macro? |
| 05:51 | mpenet | just use a fn |
| 05:54 | tdammers | I want a macro that I can use instead of deftype |
| 05:55 | tdammers | so that I don't have to write the boilerplate for 16 types by hand |
| 05:55 | tdammers | that macro is supposed to do two things: one, pass everything to deftype to generate the type, and two, generate the fn that does the "capture dynamic var and pass it implicitly as the first arg" |
| 06:00 | mpenet | then you don't need apply in your macro template, you can just have the macro generate the proper (new ... ) call for you |
| 06:02 | tdammers | then the macro needs to know the arity of the constructor |
| 06:03 | tdammers | but nevermind, I found a solution |
| 06:03 | tdammers | I just use the ->TypeName factory fn that deftype generates |
| 06:05 | mpenet | if you generate the deftype with the macro you know the arity :], but good that you found an alternative, it sounded hairy |
| 06:05 | tdammers | hehe, no, I don't know the arity - the entire macro is (defmacro defnode [class-name & args] ) |
| 06:06 | tdammers | and I just pass args to deftype unchanged |
| 06:06 | tdammers | I could, like, inspect the first element of args, count its elements, and generate a suitable (new), but this is much easier |
| 06:37 | Glenjamin | are there any libraries which provide higher-level assertions than (is) ? Someone on our team was asking if there's an AsserJ equivalent |
| 06:38 | Glenjamin | their example was having (is (= 2 (count some-vec))) showing the vector contents if the count is wrong |
| 06:43 | noncom | Glenjamin: haven't seen anything like that, but i too would like to know if that exists... |
| 06:44 | noncom | however, if it doesn't, there won't be a big problem implementing it.... |
| 06:44 | noncom | an interesting approach would be to use core logic for that, although i still could not verify that it is stabile enough for production |
| 07:48 | rhall` | /who #clojure |
| 08:00 | dnolen | Glenjamin: test.check does stuff like that |
| 08:01 | Glenjamin | dnolen: oh, good point |
| 08:01 | Glenjamin | wait, hang on - it'll show you inputs |
| 08:01 | Glenjamin | but not derived outputs in assertions? |
| 08:01 | dnolen | it will show you the minimal failing value for your test (= count 2) |
| 08:02 | Glenjamin | eg (= 1 (count (function-under-test input))) ; if that fails, i won't be shown the value of (function-under-test input) |
| 08:02 | Glenjamin | but i can still call it myself once i know the input, outside the test |
| 08:02 | dnolen | ah the return value no it won't |
| 08:13 | jonathanj | why would i choose to use core.async over something like Manifold deferreds? |
| 08:14 | jonathanj | the common "call f with the value when it arrives" case seems to be a lot more boilerplatey with core.async |
| 08:18 | jonathanj | am i right in saying that the spelling of "call f with the value when it arrives" in core.async is (go (while true (let [[v ch] (alts! [c1])] (f v))))? |
| 08:21 | stain | what about (async/map f c1) ? |
| 08:42 | mpenet | in both libs there are many ways to do this |
| 08:42 | mpenet | ex: (go-loop [] (f (<! ch))) |
| 08:43 | mpenet | manifolds seems to have more "knobs" (ex: with the use of the underlying thread) |
| 08:44 | jonathanj | how do you construct a processing pipeline with core.async? |
| 08:44 | jonathanj | like, to build up several functions that process the result sequentially |
| 08:45 | jonathanj | this seems like a really long way of going about it: http://www.braveclojure.com/core-async/#Escape_Callback_Hell_with_Process_Pipelines |
| 08:46 | mpenet | you can use transducers to do this |
| 08:49 | jonathanj | so how would you write that example with transducers? |
| 08:50 | jonathanj | it's not clear to me how you turn clojure.string/upper-case into a transducer |
| 08:50 | mpenet | (map clojure.string/upper-case) |
| 08:51 | mpenet | you can then pass it to the chan constructor directly or via other c.c.async function ex pipeline if you want it connected to another chan |
| 08:53 | jonathanj | so in that example the xform is (comp (map s/upper-case) (map s/reverse)) |
| 08:54 | jonathanj | but what is the reducing function? |
| 08:54 | jonathanj | maybe i don't want to call (transduce) |
| 08:55 | jonathanj | maybe (sequence xform [...])? |
| 08:55 | mpenet | you don't have to |
| 08:55 | mpenet | this is the signature of `chan` for instance ([] [buf-or-n] [buf-or-n xform] [buf-or-n xform ex-handler]) |
| 08:56 | mpenet | you can create a chan that will transform it's input as you feed to it |
| 08:56 | mpenet | or as I said connect it to another chan and have the transformation done when msgs move from one to antoher |
| 08:56 | mpenet | via pipeline |
| 08:58 | jonathanj | do i just pass nil for any of those parameters i don't want to specify? |
| 08:58 | jonathanj | like if i wanted to pass ex-handler without xform or buf-or-n |
| 08:58 | mpenet | ex: (def c (clojure.core.async/chan 1 (map clojure.string/lower-case))) |
| 08:59 | mpenet | try without the buff-size but I think it will throw |
| 09:03 | jonathanj | okay, so buf-or-n must be supplied if you have a transducer, but you can pass only ex-handler by filling the others with nil |
| 09:05 | mpenet | then this example is with map, but you can fold over values, filter, etc... |
| 09:08 | jonathanj | this still doesn't really help me understand why to choose core.async over manifold |
| 09:08 | jonathanj | or vice versa |
| 10:06 | jjttjj | anyone know if there are any idioms for working with arithmatic with NAs in incanter, similar to how it's done in R? specifically, i want to add multiple columns of a dataset, where some will start later than others but are backfilled with NAs (nils?), and i want the result to have NAs/nils in these spots. Seems like this should be a fairly common problem but I can't really find a "standard" way to do it? should i just wrap the inc |
| 10:32 | jonathanj | is there a comprehensive core.async guide that goes through some of the more obscure parts? like (mix) etc. |
| 10:40 | jonathanj | http://martintrojer.github.io/clojure/2014/03/09/working-with-coreasync-chaining-go-blocks/ :( |
| 11:08 | sdegutis | How do you sort by two things? Like, if you wanted to sort [[1 2] [2 1] [3 3] [2 3] [3 2]] by first and then second, so you would get [[1 2] [2 1] [2 3] [3 2] [3 3]]? |
| 11:09 | llasram | sdegutis: yes. be warned though of the surprising-to-me behavior that Clojure vectors sort first by length, *then* by successive elements |
| 11:09 | justin_smith | sdegutis: sort |
| 11:09 | justin_smith | ,(sort [[1 2] [2 1] [3 3] [2 3] [3 2]]) |
| 11:10 | clojurebot | ([1 2] [2 1] [2 3] [3 2] [3 3]) |
| 11:10 | justin_smith | llasram: or sort-by #(take 2 %) - good point |
| 11:10 | sdegutis | No but I mean technically I'm sorting by :queued-email/date and then queued-email/priority. |
| 11:10 | sdegutis | So that's what confuses me beyond reason. |
| 11:10 | sdegutis | That's what `first` and `second` represent here. |
| 11:11 | sdegutis | But f/s are easier to experiment with in samples. |
| 11:11 | justin_smith | sdegutis: (sort-by (juxt :queued-email/date :queued-email/priority) mails) |
| 11:11 | cichli | (sort-by (juxt :queued-email/date :queued-email/priority) coll))? |
| 11:11 | sdegutis | s/s/ex/g |
| 11:11 | sdegutis | justin_smith: is that even right? will it truly work? |
| 11:11 | justin_smith | sdegutis: yes |
| 11:11 | sdegutis | ,(sort-by (juxt first second) [[1 2] [2 1] [3 3] [2 3] [3 2]]) |
| 11:11 | clojurebot | ([1 2] [2 1] [2 3] [3 2] [3 3]) |
| 11:12 | sdegutis | ,(sort-by (juxt second first) [[1 2] [2 1] [3 3] [2 3] [3 2]]) |
| 11:12 | clojurebot | ([2 1] [1 2] [3 2] [2 3] [3 3]) |
| 11:12 | sdegutis | Now I'm confusing myself by mixing sort with sort-by. |
| 11:12 | justin_smith | ,(sort-by (juxt :a :b) [{} {:a 0 :b 1} {:b 3} {:a 12 :b 1}]) |
| 11:12 | clojurebot | ({} {:b 3} {:a 0, :b 1} {:a 12, :b 1}) |
| 11:12 | sdegutis | Great. |
| 11:12 | justin_smith | sdegutis: those results were all correct |
| 11:12 | sdegutis | Thanks justin_smith. |
| 11:12 | sdegutis | You're rock. |
| 11:12 | justin_smith | haha, I try |
| 11:15 | sdegutis | Oh I see justin_smith. |
| 11:15 | sdegutis | Juxt forces it to take advantage of how sort automatically sorts seqs in order with respect to all elements from left to right. |
| 11:15 | justin_smith | exactly |
| 11:15 | clojurebot | excusez-moi |
| 11:15 | sdegutis | (IF THERE EVEN IS SUCH A THING AS LEFT TO RIGHT IN SEQS HAHA) |
| 11:16 | justin_smith | beginning / end left / right, it works unless you're speaking Hebrew or Chinese or Japanese or whatever I guess |
| 11:16 | justin_smith | they actually do have ttys that go right to left |
| 11:16 | justin_smith | or back and forth for Arabic |
| 11:19 | jjttjj | Is there a reason not to just use Double/NaN all over the place with clojure.core.matrix so i can do vector math with missing values? ie (add [1 2 Double/NaN] [1 1 1]) => [2 3 NaN] |
| 11:21 | justin_smith | jjttjj: iirc hitting a NaN tends to make things slower - like the math unit does more work when it hits a nan or something |
| 11:21 | justin_smith | jjttjj: maybe there is a sparse matrix lib that would work? |
| 11:22 | jjttjj | justin_smith: cool thanks, I'll look into that |
| 11:22 | justin_smith | otherwise, if the perf is OK and it gives the right answer, go for it I guess? |
| 12:23 | sdegutis | justin_smith: thanks |
| 12:24 | sdegutis | for the helpful answer -- you are helpful as always |
| 12:24 | sdegutis | Is there something I can do to repay you for your generous help? Maybe you have a link I can advertise on my twitter account? |
| 12:24 | justin_smith | haha, not really, but I appreciate the gratitude |
| 12:25 | sdegutis | Are you sure I have 13 followers |
| 12:25 | sdegutis | I think one of them still uses twittr |
| 12:25 | justin_smith | lol |
| 12:30 | Weebz` | I'm having trouble figuring out how to do interop with Node.js libraries, could someone explain why I keep getting a no such namespace/use of undeclared var with this? |
| 12:30 | Weebz` | http://paste2.org/6mx8AA1k |
| 12:30 | Weebz` | i know in js it would be new sql.Connection(...) |
| 12:32 | Weebz` | merp. doing (new sql.Connection ...) seems to work |
| 12:47 | justin_smith | Weebz`: |
| 12:47 | justin_smith | err |
| 12:47 | justin_smith | Weebz`: (sql.Connection. ...) is more idiomatic though |
| 12:53 | justin_smith | ,(java.util.Date. 0) ; vs (new java.util.Date 0) |
| 12:53 | clojurebot | #inst "1970-01-01T00:00:00.000-00:00" |
| 13:13 | Glenjamin | hi all, i'm experimenting with using clojure to write tests for a java app - is there any way to get leiningen to pull in dependencies from the "test" scope of a pom? |
| 13:52 | Glenjamin | is there any way to pass values created in clojure.test fixtures into tests |
| 13:52 | Glenjamin | or should i just use (binding) ? |
| 13:59 | sdegutis | I recently developed need for an email queue that runs in the background written in Clojure. However, I'm coming up with difficulties knowing how to communicate with such a background thread in a queue-like way. |
| 14:00 | sdegutis | Is there any such tools that help alleviate such technical difficulties of implementation for the burden of the developer? |
| 14:00 | sdegutis | Mitigation of any difficulty would be appreciated. Thanks. |
| 14:02 | sdegutis | justin_smith: do you ever write something like this and have recommendations? |
| 14:05 | sdegutis | Oh. Looks like core.async helps with this I think? |
| 14:06 | sdegutis | Reading https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj suggests so. |
| 14:14 | jakedust | sdegutis: I'd say core.async + channels |
| 14:14 | sdegutis | Are channels part of core.async? |
| 14:14 | jakedust | yup |
| 14:14 | jakedust | if you are familiar with Go channels, they are very similar |
| 14:14 | sdegutis | Perfect, thanks! |
| 14:14 | sdegutis | Yep, I am. |
| 14:14 | sdegutis | Not 100% the same? |
| 14:15 | jakedust | I'm not knowledgeable enough to say if they are 100% the same, but I've never had problems so far assuming so |
| 14:16 | sdegutis | Cool, thanks jakedust! |
| 14:16 | jakedust | there's a lot more in core.async, but I basically just use goroutines and channels for everything |
| 14:16 | sdegutis | Sounds like a good plan. |
| 14:27 | carkh | sdegutis: core.async is nice, but not the only tool. channels are blocking, there are also agents which are not, but provide no control on the size of the queue (afaik) |
| 14:27 | sdegutis | carkh: I thought channels only block when unbuffered? |
| 14:27 | carkh | they will block on the size of your lossless buffer |
| 14:28 | carkh | i mention agents because i find them easier than channels for many tasks |
| 14:28 | sdegutis | Realistically though, all I need to do is tell a continuous background job to do something. I literally only need to send half a bit (a full bit could mean true/false, I only need to send "hey you, do your thing"). In which case, are channels overkill? |
| 14:28 | sdegutis | So maybe I do need agents. |
| 14:29 | carkh | you only need a thread then =) |
| 14:29 | sdegutis | How so? |
| 14:29 | carkh | why do you need a queue ? are you cosntrained by the possibility of too many "requests" ? |
| 14:30 | carkh | sometimes just fire and forget is enough |
| 14:30 | sdegutis | I just need to tell the background job "hey you got another job to do", and it knows where to find it. It'll keep doing jobs as long as there are some left. When there's none, it just waits for this message. |
| 14:30 | sdegutis | But it has to do them sequentially. |
| 14:30 | sdegutis | That's the difficult part. It can't do any of these jobs simultaneously, even though it can get simultaneous requests to do it. |
| 14:31 | carkh | with agents you have the risk of filling the memory with more requests than you can process, but it's sequential all right |
| 14:31 | norton- | I want to create my own project which uses code from this project, https://github.com/adamtornhill/code-maat , but it seems like it's not available as a library on clojars. Is there a simple way I can use the code? Copying all code into my own project perhaps works but it feels like there should be a better way. |
| 14:31 | carkh | with core.async you _can_ have backpressure |
| 14:32 | lxsameer | is it safe to derefrence an atom inside swap! of other atom ? |
| 14:33 | tcrawley | norton-: you can deploy to clojars under org.clojars.your-user-name/code-maat and use that |
| 14:34 | amalloy | lxsameer: it's safe in that you are guaranteed to get the current value of that atom. but it might well have a different value the very next instant, so any decision you make based on that value may be out of date |
| 14:34 | lxsameer | thanks |
| 14:35 | carkh | lxsameer: the best woudl be to deref outside of it though |
| 14:35 | lxsameer | carkh: awesome thanks |
| 14:35 | norton- | tcrawley: thanks |
| 14:35 | carkh | (swap! atom1 do-it @atom2) is correct |
| 14:35 | tcrawley | norton-: my pleasure! |
| 14:44 | jonathanj | liberator allows you to return a map from a handler which it will turn into JSON in the case of application/json media, but it's not clear how you have it encode some non-standard value into JSON |
| 14:44 | jonathanj | clojure.data.json/encode requires an additional arg that you don't have access to when using liberator like this |
| 14:44 | jonathanj | cheshire has a way to add an encoder globally but liberator isn't using cheshire |
| 14:59 | gfredericks | jonathanj: I swear data.json has a similar global mechanism |
| 15:19 | jonathanj | gfredericks: i don't know if i'm looking in the wrong place then but there doesn't seem to be anything like that here: http://clojure.github.io/data.json/ |
| 15:20 | jonathanj | maybe JSONWriter? but what happens if i want to encode one of the existing types in a different way? |
| 15:30 | jonathanj | i feel a bit stupid: i don't understand how to invoke to-hex-string with clj-uuid |
| 15:31 | amalloy | carkh: that has exactly the same problem as derefing inside |
| 15:31 | jonathanj | (clj-uuid/to-hex-string (clj-uuid/v4)) tells me: java.lang.IllegalArgumentException: No implementation of method: :to-hex-string of protocol: #'clj-uuid/UUIDRfc4122 found for class: java.util.UUID |
| 15:32 | amalloy | you can't make a coordinated decision based on the instantaneous state of two different atoms: there is just no way to do it, because they are uncoordinated. if you need to do that, you want refs |
| 15:32 | carkh | amalloy: maybe for your concern, but the function should be pure, which it isn't when derefing inside |
| 15:32 | carkh | amalloy: true |
| 15:33 | amalloy | it's true you do avoid one problem by derefing outside, although it's not one that i find usually matters |
| 15:33 | carkh | amalloy: true again, i'm just blindly following the doc recommendation =) |
| 15:45 | jonathanj | gfredericks: so if i do something like: (extend java.util.UUID JSONWriter {:-write (fn [x ^PrintWriter out] (.print out (uuid/to-string x)))}) |
| 15:45 | jonathanj | gfredericks: then i get json that looks like: {"foo": 1234-arst-uuid-goes-here} |
| 15:46 | jonathanj | and the "write-string" implementation in data.json is private |
| 15:59 | jonathanj | *oh* i have to import -write from clojure.data.json, that was not very obvious to me at all :( |
| 16:02 | gfredericks | jonathanj: yeah, or you can write the double-quotes yourself (which is what I did, but I like yours better) |
| 17:28 | uptown | in a cider REPL, can I hook namespace changes? |
| 18:15 | Frozenlock | uptown: hook namespace change? |
| 18:17 | uptown | execute a function when the user types (ns some.ns) in the REPL |
| 18:21 | Frozenlock | uptown: Hmm... ns is a macro, so I'm not sure this will work: https://github.com/technomancy/robert-hooke/. |
| 18:22 | Frozenlock | Otherwise you can jump through some hoops and do something similar I did to redefine 'fn' in https://github.com/Frozenlock/force-serialize |
| 18:23 | justin_smith | and you can also switch namespaces via in-ns, which is not a macro, it's a special form I think |
| 18:23 | justin_smith | maybe not |
| 18:23 | justin_smith | Frozenlock: uptown: put the hook on in-ns, ns calls in-ns |
| 18:24 | uptown | aha |
| 18:24 | Frozenlock | justin_smith: hooks work with special forms? |
| 18:25 | justin_smith | Frozenlock: it's not implemented in clojure, but it's also not a special form, it's just a function |
| 18:25 | justin_smith | so you can totally hook on it |
| 18:25 | amalloy | i don't think you really want to hook in-ns |
| 18:25 | justin_smith | oh? |
| 18:25 | amalloy | i mean, that will impact every namespace that gets loaded |
| 18:25 | justin_smith | that's true |
| 18:27 | justin_smith | amalloy: totally works though https://www.refheap.com/111402 |
| 18:28 | Frozenlock | Btw, is technomancy still alive? I think the last time I heard of him he was moving to another country or something... |
| 18:29 | justin_smith | Frozenlock: he pops up in #leiningen sometimes |
| 18:29 | justin_smith | he just dropped out of the high-pace #clojure lifestyle |
| 18:29 | uptown | for clarity, the point of this is to print a count and abbreviated list of publics when i switch namespaces as a sanity / typo check |
| 18:30 | justin_smith | uptown: that should be pretty easy with alter-var-root if you don't mind a permanent change, but robert.hooke does it much more elegantly, if you don't mind this printing every time a namespace gets loaded |
| 18:31 | uptown | justin_smith: i think the point is print it every time i change |
| 18:31 | uptown | which i understand would annoy most people but |
| 18:32 | Frozenlock | uptown: many editors will also autocomplete and offer the list of known functions/variables if you are worried about typos. |
| 18:32 | uptown | i seem to make enough typos to justify it |
| 18:33 | uptown | my emacs setup seems not to do that for me? perhaps that's my real problem |
| 18:33 | Frozenlock | Yeah, I'd check that first :-p |
| 18:33 | Frozenlock | Cider? |
| 18:34 | uptown | an excellent point. got frustrated and started treating symptoms |
| 18:34 | uptown | yes, cider / emacs |
| 18:36 | Frozenlock | uptown: I'm using Cider with Company-mode: http://i.imgur.com/5aTa1N2.png |
| 18:38 | Frozenlock | So I've got the dropdown menu as shown, TAB autocomplete, and in some cases hippie-expand (meta-/). I ain't got any typos :-p |
| 18:38 | uptown | company-mode offers me namespaces i've previously mentioned but does not expand to a list of funtions |
| 18:39 | uptown | but you have fewer cider / nrepl warnings on startup than i do |
| 19:02 | noncom|3 | i am working on a PC with limited caps, and eclipse is getting very hungry, it can eat like 400-800mb. i am thinking about moving to emacs on this machine, how do you think, will it be more feasible? |
| 19:02 | oddcully | Eight Megs And Constantly Swaping - should work fine then! |
| 19:03 | Frozenlock | noncom|3: It will most probably work. The only question is 'are you read for Emacs?' |
| 19:03 | Frozenlock | *ready |
| 19:03 | justin_smith | emacs is much weirder, but yeah, it can also run with less heap |
| 19:03 | noncom|3 | yeah, i got some experience with emacs |
| 19:04 | noncom|3 | on my last emacs usage though, i remember the weirdness - the linum mode was taking up to 15% CPU ! |
| 19:04 | Frozenlock | o_O |
| 19:04 | noncom|3 | i remember discussing that on #emacs and people said, like yeah, well, linum eats that much |
| 19:04 | noncom|3 | and i was like WTF |
| 19:04 | noncom|3 | maybe even up to 25 CPU, i don't recall exactly. |
| 19:04 | noncom|3 | i can check tomorrow |
| 19:05 | noncom|3 | i got to know this by some inbuilt emacs profiler.. |
| 19:05 | noncom|3 | i dont remember how to call for it, but someone on #emacs guided me |
| 19:05 | noncom|3 | that's the story.. |
| 19:06 | noncom|3 | *it was taking that much on scrolling |
| 19:07 | noncom|3 | justin_smith: btw, what about that hang in your app? did you nail it down? |
| 19:07 | Frozenlock | How do you use linum? I don't use it and I might be missing on some nice wizardry... |
| 19:07 | noncom|3 | Frozenlock: i just hardcodely enable it in init.el for everything |
| 19:08 | noncom|3 | you know, i like having line numbers everywhere |
| 19:08 | Frozenlock | But it only shows the line number? |
| 19:08 | noncom|3 | no, it shows a column of numbers to the left |
| 19:08 | noncom|3 | like that: http://joxi.ru/82QVZ9eIYO4QAd |
| 19:08 | noncom|3 | (it's eclipse) |
| 19:09 | Frozenlock | Yes... what I'm asking is how do use that in your workflow. |
| 19:09 | noncom|3 | for navigation, for stack traces |
| 19:09 | noncom|3 | somehow i feel better with it |
| 19:09 | oddcully | Frozenlock: some folks need that to see... others just tell the editor |
| 19:09 | noncom|3 | tried to work without it, but found that i always turn it on |
| 19:11 | Frozenlock | I see. Yeah I just tell emacs to go to line when I have a stacktrace. 'M-g g' |
| 19:12 | noncom|3 | i know, eclipse can do this too |
| 19:12 | Frozenlock | I hope so :-p |
| 19:12 | noncom|3 | :D |
| 19:27 | the_nonameguy | hey, has anyone written a test.check generator based on a schema from the 1.0 prismatic/schema release? |
| 19:30 | the_nonameguy | http://blog.getprismatic.com/schema-1-0-released/ |
| 19:30 | the_nonameguy | it states that it 'provides way to plug in custom generators', but I couldn't figure out how, based on the source |
| 20:06 | gfredericks | the_nonameguy: haha I just figured that out today |
| 20:07 | gfredericks | (cgen/generator the-schema {SomeSchema some-generator}) |
| 20:41 | bluezone | OH my GOD. How on EARTH do I erase brackets around an expression in Cursive ?!?! |
| 20:41 | cfleming | bluezone: https://cursiveclojure.com/userguide/paredit.html :) |
| 20:43 | bluezone | GOD BLESS YOU! |
| 20:43 | gfredericks | ~GOD |BLESS| cfleming |
| 20:43 | clojurebot | 'Sea, mhuise. |
| 20:51 | TEttinger | to the tune of god bless america: GOD BLESS G. FREDERICKS / TESTS CAN BE CHUCKED / MAKE EXPRESSIONS / AND DOUBLES / FROM THE NAN TO THE HASH DOUBLE QUOTE |
| 20:52 | TEttinger | sorry cfleming, your name doesn't have the extra syllable to fit the scheme |
| 20:53 | cfleming | It would have to be a fle-he-ming - worse things have been done to make something scan |
| 20:53 | TEttinger | phlegming |
| 20:54 | TEttinger | really appreciate what you wonderful tools authors do |
| 20:54 | TEttinger | I'm so glad clojure has a good community of people making productivity better for everyone |
| 20:57 | cfleming | I notice that only gfredericks gets a song, though. |
| 20:57 | cfleming | I mean, I'm just saying. |
| 21:05 | TEttinger | to the tune of god bless america: GOD BLESS INTELLI J/ CURSIVE WE LOVE / USE PAREDIT / AND EDIT / ALL YOUR CLOJURE WITH C FLEMING'S HUG |
| 21:06 | cfleming | TEttinger: That's awesome. I'm going to make Cursive play that at startup. |
| 21:06 | TEttinger | haha |
| 21:07 | cfleming | It'll be like the pledge of allegiance |
| 21:08 | cfleming | I wonder if I could remix it to the tune of God save the Queen |
| 21:08 | gko | Is there a way to have a Cursive REPL in a single window? |
| 21:09 | cfleming | gko: How do you mean, in a single window? |
| 21:09 | gko | I mean not a "output window on top / input window at the bottom" |
| 21:10 | gko | one window with both input and output |
| 21:10 | gko | like most REPL |
| 21:10 | gko | like in cider or SLIME |
| 21:12 | cfleming | gko: No, there isn't |
| 21:12 | bluezone | https://www.refheap.com/111403 I'm trying to have the function accept a vector. I believe I am doing something wrong :/ |
| 21:13 | cfleming | It's because in IntelliJ editors are strongly typed, so the input editor has to be a Clojure editor, but the output isn't actually Clojure, it's arbitrary text |
| 21:13 | cfleming | gko: So I have to separate them. |
| 21:14 | cfleming | That said, it's actually quite nice, especially for editing multi-line forms. |
| 21:14 | gko | cfleming: oh, so if you insert random text it will actually try to parse the colors, etc... |
| 21:15 | cfleming | gko: Right. There's actually a problem with that, which is that if you try to (read) in a Cursive REPL, it currently won't work well. |
| 21:15 | cfleming | Since Cursive will always try to treat it as Clojure code. |
| 21:17 | cfleming | There are some potential hacks to get around that, but I haven't implemented anything yet. |
| 21:17 | gko | OK, too bad... fortunately, there's cider for the REPL side... |
| 21:20 | gfredericks | wow a lot of singing happened here while I wasn't looking |
| 21:20 | bluezone | It's telling me on line 7 that i'm passing 4 arguments https://www.refheap.com/111404 |
| 21:20 | bluezone | I'm just trying to pass [1 2 3 4 5] into the vect parameter :( |
| 21:20 | gfredericks | bluezone: that's not causing the error |
| 21:20 | gfredericks | it's happening on line 5 |
| 21:21 | cfleming | gfredericks: It was great. |
| 21:21 | bluezone | Why doesn't the stack trace tell me that :( |
| 21:21 | gfredericks | bluezone: what's the stack trace look like? it ought to |
| 21:22 | cfleming | gfredericks: Are you going to be at the conj? |
| 21:22 | gfredericks | cfleming: absolutamente |
| 21:22 | cfleming | gfredericks: Muy bien |
| 21:22 | cfleming | We can sing odes to each other. |
| 21:22 | bluezone | gfredericks: https://www.refheap.com/111406 (in my code, line 5 is line 7) |
| 21:22 | cfleming | TEttinger has given us some great material |
| 21:22 | badatclojure | Hey guys! Quick question about multimethods. I'm wanting to dispatch off a map containing a certain property (params request in Compojure). Is there a good way to do that? |
| 21:23 | gfredericks | I'll sing you your song if you sing me mine |
| 21:23 | badatclojure | certain key* sorry |
| 21:23 | gfredericks | bluezone: looks like the problem is you're not seeing the stack trace at all -- try typing *e at the repl |
| 21:24 | bluezone | oh, heh nice |
| 21:25 | gfredericks | this year will be my first conj since maybe the first one |
| 21:25 | gfredericks | or maybe the second one |
| 21:25 | gfredericks | they were so long ago now I can't remember |
| 21:30 | Frozenlock | bluezone: the clojure syntax? |
| 21:30 | bluezone | yes |
| 21:31 | bluezone | never sure when to put brackets |
| 21:32 | Frozenlock | Do you have an editor that highlights the brackets? |
| 21:32 | TEttinger | unless you have ' quotes involved, () starts with a function to call and anything else in it is an argument |
| 21:32 | TEttinger | that's most of it |
| 21:32 | bluezone | hmm |
| 21:32 | badatclojure | brackets are basically used to separate functionality. In Java, you'd type something like cons(a,b). In clojure, you move the name inside the parens and drop the comma (cons a b). |
| 21:32 | TEttinger | (function or macro) |
| 21:33 | Frozenlock | It's like math :-p |
| 21:33 | bluezone | if I want to pass rest vect as one parameter I need to do (rest vect) ? |
| 21:33 | badatclojure | same thing for deeper function stacks. Java: cons(a, something(b)) Clojure: (cons a (something b)) |
| 21:33 | TEttinger | ,(let [vect [1 2 3 4 5]] (map inc (rest vect))) |
| 21:33 | clojurebot | (3 4 5 6) |
| 21:34 | bluezone | hmm |
| 21:35 | TEttinger | inc is sorta like ++, it increments (but doesn't change any existing variables, things that do that are rare) |
| 21:35 | bluezone | I think I'm just unaware of something special i need to do for recursion |
| 21:35 | TEttinger | ,(let [vect [1 2 3 4 5]] (rest vect)) |
| 21:35 | clojurebot | (2 3 4 5) |
| 21:36 | TEttinger | bluezone, usually you don't directly do recursion in clojure |
| 21:36 | TEttinger | there's loop and recur, which are pretty much always used together |
| 21:36 | bluezone | wat |
| 21:36 | Frozenlock | bluezone: Don't listen to him, recursions are cool :-D |
| 21:36 | badatclojure | Bluezone: Direct recurson doesn't happen much. You'll see loop and recur. Oh, and you'll see map a lot too. |
| 21:36 | TEttinger | tail recursion can blow the stack if you don't use loop/recur |
| 21:37 | badatclojure | Yeah, make sure to use loop/recur. |
| 21:37 | TEttinger | (also non-tail recursion) |
| 21:37 | bluezone | I guess they aren't using java8? I think they removed that problem in java8 |
| 21:37 | badatclojure | Learned that the hard way. |
| 21:37 | TEttinger | nope |
| 21:37 | TEttinger | java8 still lacks TCO |
| 21:37 | bluezone | java8 still lacks a language |
| 21:37 | badatclojure | I dont really know when Java8 will have TCO. |
| 21:37 | TEttinger | it as under consideration |
| 21:37 | TEttinger | *was |
| 21:37 | Frozenlock | I use recursions when I know my dataset will be small-ish. loop/recur is... not pretty. |
| 21:38 | jasonx2 | in some ways recur is nicer than tail recursion. you get a compile-time check if your function is tail recursive |
| 21:38 | badatclojure | People dont really write recursive Java to my knowledge though. Or really even try. Stateful recursion is scary anyways. |
| 21:38 | TEttinger | I strongly recommend trying to phrase things with map, filter, recur, and other common fns like that before you start doing loop/recur |
| 21:38 | TEttinger | *map, filter, reduce |
| 21:39 | bluezone | I just don't understand why it's still passing 4 arguments https://www.refheap.com/111407 |
| 21:39 | badatclojure | Shameless self-plug. Could someone explain how to setup multimethods that dispatch off of a key existing in a map parameter? |
| 21:40 | bluezone | like it takes the rest of vect, but instead of passing it as a vect it passes each value individually |
| 21:40 | Frozenlock | bluezone: https://www.refheap.com/111408 |
| 21:41 | Frozenlock | And you don't need the 'apply', unless I misunderstood what you are trying to do. |
| 21:41 | netrobyatmobile | who know how to compile Clojure code into Executable Binary ELF file? |
| 21:42 | bluezone | Well |
| 21:42 | bluezone | shit |
| 21:43 | Frozenlock | (first-element) is like calling the function 'first-element' which doesn't exist. |
| 21:43 | bluezone | yeah, hmm |
| 21:43 | bluezone | Thanks |
| 21:46 | TEttinger | netrobyatmobile: you would need to get the JVM bundled in there too |
| 21:47 | bluezone | Seems the solution works in my environment but not on 4clojure <3 |
| 21:47 | netrobyatmobile | Thanks, i hate JVM , it will takes more than 200MB space. |
| 21:47 | netrobyatmobile | Download, Upload the whole distribution was huge packages. |
| 21:47 | TEttinger | there's clojurescript and clojure CLR |
| 21:47 | netrobyatmobile | Long time to waiting it deliveried |
| 21:48 | Frozenlock | bluezone: link? |
| 21:48 | bluezone | Frozenlock: https://www.4clojure.com/problem/19 |
| 21:49 | TEttinger | netrobyatmobile: Pixie is similar to Clojure in lots of ways but doesn't use the JVM |
| 21:49 | TEttinger | it also is not very finished yet I think, though it's getting better |
| 21:50 | Frozenlock | bluezone: If you are not using 'defn', I suppose you are using 'fn'? |
| 21:50 | bluezone | it tells me I tripped the alarm? O.o I dunno wtf |
| 21:50 | Frozenlock | Ah ok |
| 21:50 | Frozenlock | So yeah, you can't define functions. |
| 21:50 | bluezone | err |
| 21:50 | Frozenlock | But you can create one that will be used immediately with 'fn'. |
| 21:51 | Frozenlock | "define function" -> defn | "function" -> fn |
| 21:52 | bluezone | well How can i use recursion if I don't have the function name |
| 21:52 | cfleming | netrobyatmobile: Check out Avian, it's an alternative lightweight JVM which can compile an executable |
| 21:52 | Frozenlock | bluezone: fn accepts an optional name. |
| 21:52 | cfleming | It's not high performance, depends on your use case |
| 21:52 | Frozenlock | Type (doc fn) in your repl. |
| 21:53 | Frozenlock | (fn last-e [vect]... |
| 21:54 | bluezone | so what would be the difference between (defn last-e) and (fn last-e) |
| 21:55 | bluezone | ah |
| 21:55 | bluezone | nevermind, fn is used immediately I guess |
| 21:55 | bluezone | defn creates a function for later use |
| 21:59 | jakedust | not really that Clojure-related, but does anybody have any recommendations of readings/code on building "services"? i.e. I want to build a data processing service with a REST API for both task-related commands (do task A as soon as you can) and "lifecycle" commands (finish all the jobs you have right now and exit as soon as you can) |
| 22:00 | jakedust | my original idea was writing everything around an event loop and core.async channels, but I'm not sure if that's a good idea or not, I'm really not familiar with this |
| 22:01 | netrobyatmobile | Thanks /msg cfleming |
| 22:10 | bluezone | Well this seems like a really sexy language so far |
| 22:11 | bluezone | I love that-I-Can-do-this insteadOfThisCamelFatassAnnoyance |
| 22:12 | jakedust | bluezone: I have to confess that seeing * in names is confusing, but still lovely |
| 22:20 | Frozenlock | bluezone: be warned, this is a one way trip. |
| 22:20 | bluezone | Frozenlock: away from what? java? |
| 22:20 | Frozenlock | It's like going from 56k to broadband. |
| 22:21 | Frozenlock | All-the-things! |
| 22:22 | bluezone | eh, I don't care anymore lol. Prefer to be a bum than to fall asleep coding in boring languages |
| 22:22 | jakedust | Frozenlock: I've been bitten by the Clojure bug. |
| 22:22 | Frozenlock | jakedust: https://mlpforums.com/uploads/monthly_06_2015/post-20300-0-98845900-1435445700.jpg |
| 22:23 | jakedust | heh, I though it'd be a parasprite, given the URL |
| 22:23 | jakedust | but yeah |
| 22:24 | Frozenlock | Pff, that's URLism |
| 22:24 | Frozenlock | Don't judge based on URL dude. |
| 22:26 | jakedust | weirdly enough, it feels like I was on another extreme, using scalaz everyday |
| 22:33 | bluezone | I keep tripping the alarm -.- |
| 22:33 | bluezone | They have so many restrictions on identifier names |
| 22:35 | TEttinger | cfleming: does avian work with clojure now? |
| 22:36 | TEttinger | I tried it a while ago, it didn't support some java data structures clojure needed |
| 22:36 | TEttinger | (also, netrobyatmobile, there's zulu builds of OpenJDK that are much less than 200MB) |
| 22:37 | TEttinger | (and you are allowed to take stuff out of those) |
| 22:44 | cfleming | TEttinger: I believe it does, but you might have to use a different class library |
| 22:44 | cfleming | The default one is very limited, but you can use OpenJDK classes or the Android ones IIRC |
| 23:32 | jeaye | ,(-> [:foo] first name symbol list str) |
| 23:32 | clojurebot | "(foo)" |
| 23:32 | jeaye | ^ is there a cleaner way to get the same result, given [:foo]? |
| 23:34 | irctc | hi guys does anyone know how to run om-next-demo project |
| 23:34 | irctc | https://github.com/swannodette/om-next-demo |
| 23:34 | irctc | I have managed to get all the deps working, it seems we need to run some kind of script instead lf lein run. |
| 23:35 | irctc | I have read this https://github.com/clojure/clojurescript/wiki/Quick-Start, but it's a bit confused. Any help would be appreciated. |
| 23:38 | TEttinger | ,(map symbol [:foo]) |
| 23:39 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.String> |
| 23:39 | TEttinger | hm |
| 23:39 | TEttinger | ,(map (comp symbol name) [:foo]) |
| 23:39 | clojurebot | (foo) |
| 23:39 | TEttinger | ,(str (map (comp symbol name) [:foo])) |
| 23:39 | clojurebot | "clojure.lang.LazySeq@9e9a82cb" |
| 23:39 | jeaye | apply str |
| 23:40 | jeaye | ,(apply str (map (comp symbol name) [:foo])) |
| 23:40 | clojurebot | "foo" |
| 23:40 | jeaye | ah |
| 23:40 | jeaye | Well, maybe what I have isn't so bad then. |
| 23:41 | TEttinger | ,(map #(str "(" (name %) ")") [:foo]) |
| 23:41 | clojurebot | ("(foo)") |
| 23:42 | jeaye | heh |
| 23:42 | jeaye | There's a lot more syntax there. |
| 23:42 | TEttinger | ,(apply str (map name [:foo])) |
| 23:42 | clojurebot | "foo" |
| 23:43 | jeaye | ,(apply str (map (comp list name) [:foo])) |
| 23:43 | clojurebot | "(\"foo\")" |
| 23:43 | jeaye | ,(apply str (map (comp list symbol name) [:foo])) |
| 23:43 | clojurebot | "(foo)" |
| 23:43 | jeaye | Correct result, not any cleaner. |
| 23:44 | TEttinger | ,(pr-string (map name [:foo])) |
| 23:44 | clojurebot | #error {\n :cause "Unable to resolve symbol: pr-string in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: pr-string in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: pr-st... |
| 23:44 | TEttinger | ,(pr-str (map name [:foo])) |
| 23:44 | clojurebot | "(\"foo\")" |
| 23:44 | TEttinger | hm |
| 23:45 | TEttinger | ,(pr-str (map str [:foo])) |
| 23:45 | clojurebot | "(\":foo\")" |
| 23:45 | TEttinger | ,(pr-str (map (comp symbol name) [:foo])) |
| 23:45 | clojurebot | "(foo)" |
| 23:52 | TEttinger | ,(apply str (nfirst (map name [:foo]))) |
| 23:52 | clojurebot | "oo" |
| 23:55 | TEttinger | ,(apply str (nfirst [:foo])) |
| 23:55 | clojurebot | #error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.lang.RT next "RT.java" 682]\n [clojure.core$n... |
| 23:55 | TEttinger | ,(apply str (nnext (str [:foo]))) |
| 23:55 | clojurebot | "foo]" |
| 23:55 | TEttinger | damn |
| 23:57 | TEttinger | ,(str "(" (name (first [:foo])) ")") |
| 23:57 | clojurebot | "(foo)" |
| 23:57 | TEttinger | ,[(count "(str \\( (name (first [:foo])) \\))") (count "(-> [:foo] first name symbol list str)")] |
| 23:58 | clojurebot | [33 38] |
| 23:58 | TEttinger | so there's some teensy golf |
| 23:58 | TEttinger | the list threw me off initially, so in my mind the explicit str with parens shows the end result |