workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians | clojure | Full TOC, some free downloadable chapters/excerpts, Beta e-book. I buy most of my tech books in Beta/Early Access direct from the publishers these days. | 2017-12-18T23:00:06.000004 | Daniell |
clojurians | clojure | <@Berry> I think you'll be in relatively uncharted territory. Have you asked folks in <#C03S1L9DN|clojurescript> ? | 2017-12-18T23:01:16.000275 | Daniell |
clojurians | clojure | For Expectations, which -- notionally -- supports ClojureScript as well as Clojure, the cljs tests are run using a cljs REPL but it's bootstrapped from a Clojure REPL (on the JVM). | 2017-12-18T23:05:55.000173 | Daniell |
clojurians | clojure | Both, planck runs on JS core (self hosted) so you're a bit limited, but lumo runs on Node.JS and can use node modules | 2017-12-18T23:13:38.000147 | Sandy |
clojurians | clojure | not really sure what you mean by "used as a dev env" though | 2017-12-18T23:13:51.000047 | Sandy |
clojurians | clojure | a REPL is a dev environment | 2017-12-18T23:14:42.000115 | Sandy |
clojurians | clojure | and you can use planck and lumo with `inf-clojure` so emacs can work with them similar to CIDER but without the huge jvm deps | 2017-12-18T23:53:17.000004 | Willow |
clojurians | clojure | Good to know! Just installed npm on my Windows 10 WSL Ubuntu bash and then installed Lumo via npm and, sure enough, I can start a Socket Server REPL and connect to it from telnet or similar... Not sure whether that helps <@Berry> (and I see Lumo advertises its cljs compilation as experimental) but it's impressive. | 2017-12-19T00:49:50.000050 | Daniell |
clojurians | clojure | And it looks like Lumo's cljs compilation is a lot more solid now (just reading the mid-September blog post about it). | 2017-12-19T01:02:13.000033 | Daniell |
clojurians | clojure | hm, i enabled reflection warnings on my project and i'm getting one i don't know how to interpret:
```
Reflection warning, /tmp/form-init4283907053113722510.clj:1:903 - call to static method invokeStaticMethod on clojure.lang.Reflector can't be resolved (argument types: unknown, java.lang.String, unknown).
```
any ideas? can i get a full stack for that warning? | 2017-12-19T04:50:25.000169 | Elizbeth |
clojurians | clojure | do reflection warnings happen at compile time or run time? | 2017-12-19T04:53:08.000097 | Berry |
clojurians | clojure | compile time | 2017-12-19T04:53:52.000130 | Kareen |
clojurians | clojure | <@Kareen> that's what I thought too, the 'full stack for that warning' confused me | 2017-12-19T05:11:32.000062 | Berry |
clojurians | clojure | ```
(defn rnd-f-arr [n]
(let [random (java.util.Random.)
x (float-array n)]
(doseq [i (range n)]
(aset x i (.nextFloat random)))
x))
(seq (rnd-f-arr 2))
```
^-- help shortening the above: I think it can be made more idiomatic | 2017-12-19T05:25:29.000311 | Berry |
clojurians | clojure | hmm, I get:
```
(defn rnd-f-arr [n]
(let [random (java.util.Random.)]
(float-array n (repeatedly n #(.nextFloat random)))))
```
is this still as efficient, or does 'repeatedly' cause performance problems | 2017-12-19T05:27:33.000478 | Berry |
clojurians | clojure | `(aset (float-array [0 0 0 0]) 2 2)` <-- what am I doing wrong in this code? I'm passing it an array, an index, and a number | 2017-12-19T06:04:10.000231 | Berry |
clojurians | clojure | 2 is not a float | 2017-12-19T06:05:28.000120 | Kareen |
clojurians | clojure | (or a double) | 2017-12-19T06:05:38.000152 | Kareen |
clojurians | clojure | yeah, changing it to 2.0 made it work | 2017-12-19T06:06:30.000440 | Berry |
clojurians | clojure | is there a way to "unquote" format strings?
for macros, we can do
```
`( .... ~(...))
```
now, for format strings, we can do `(format "v: %s, i: %s" v i)` ... but is there a way to "unquote" where the v/i are placed right at the `%s` ? | 2017-12-19T06:17:04.000003 | Berry |
clojurians | clojure | ```
(ns a.behemoth
(:import [jcuda.jcublas.JCublas]
[jcuda])
(:require [a.atlantis :as a]))
(jcuda.jcublas.JCublas/cublasInit)
```
is there a way I can shorter the `jcuda.jcublas.JCublas/cublasInit` | 2017-12-19T06:43:32.000213 | Berry |
clojurians | clojure | ```
(ns a.behemoth
(:import (jcuda.jcublas JCublas)))
(JCulbas/cublasInit)
```
? | 2017-12-19T06:43:59.000380 | Mallie |
clojurians | clojure | ah, that works; thanks! | 2017-12-19T06:45:14.000172 | Berry |
clojurians | clojure | so 'classes' can be imported as 'namespace' ? | 2017-12-19T06:45:21.000293 | Berry |
clojurians | clojure | That's how we've always done our Java interop imports. The `(` vs `[` is just a weird Clojure convention IIRC, imports normally use `(` but requires are `[`. It's the space instead of dot that makes it work. I couldn't tell you *why* it works though | 2017-12-19T06:46:17.000410 | Mallie |
clojurians | clojure | You are right, thank you. It did totally catch me by surprise though. | 2017-12-19T07:42:17.000470 | Augusta |
clojurians | clojure | in clojure.spec, do you guys have any idea of how i could deref a value before checking it?
```
(s/fdef foo!
:args (s/cat :arg1 (s/coll-of (fn [v] (instance? Bar v)))))
```
`arg1` in `foo!` is a reference value containing a collection, i'd like to `deref` it so that i can check it with `coll-of` | 2017-12-19T08:06:00.000511 | Ahmad |
clojurians | clojure | You could use s/and an s/conformer that calls deref | 2017-12-19T08:27:07.000119 | Sonny |
clojurians | clojure | Which is a little dicey | 2017-12-19T08:27:57.000540 | Sonny |
clojurians | clojure | hello everyone I’m trying to generate a fat jar (leiningen) of a project which will run some jobs and die, and I have some module levels declarations with `def` that accesses the database, something like
`(def sms-body (get-msg-from-db "smsInviteText"))`
but when I run `lein uberjar` it tries run those commands upon compilation, is there a way to avoid that? | 2017-12-19T08:28:09.000003 | Amado |
clojurians | clojure | Although i find it’s usually best to stop passing atoms around as much as possible and instead write your function on the data inside | 2017-12-19T08:29:10.000347 | Sonny |
clojurians | clojure | To get to@the point where all the logic that is worth testing operates on data, not state. Then you don’t need to spec the stateful functions | 2017-12-19T08:30:09.000240 | Sonny |
clojurians | clojure | Yeah, don’t do that :) | 2017-12-19T08:30:40.000070 | Sonny |
clojurians | clojure | how? id like to have this value as a constant visible to all functions of the module | 2017-12-19T08:31:35.000192 | Amado |
clojurians | clojure | Make that a function, invoke it at runtime, and pass it around | 2017-12-19T08:32:07.000069 | Sonny |
clojurians | clojure | I know that sounds like a pain in the ass, but you will probably be thankful a year from now | 2017-12-19T08:32:43.000233 | Sonny |
clojurians | clojure | The short term fix would be to wrap it in `delay` and then deref it where it’s used | 2017-12-19T08:33:20.000313 | Sonny |
clojurians | clojure | oh nice, i will try that! thanks alex! by the way, it's an exercise in which i'm simulating database collections as references, so whenever i need to query the data i use this reference + core.logic. i thought it was a good idea at the time | 2017-12-19T08:33:23.000032 | Ahmad |
clojurians | clojure | I mean, you could have a function you invoke at startup that puts the result in a `def`'d atom, then just access the atom whenever you need the value, but that's a very un-Clojureish way to do it | 2017-12-19T08:33:31.000221 | Mallie |
clojurians | clojure | I ll just pass it around i guess :slightly_smiling_face: thx | 2017-12-19T08:34:06.000429 | Amado |
clojurians | clojure | Hello, question about `pedestal` : is it possible to have `:constraints` and `:path-params` for static routes, i.e. routes that don't have any placeholder like `:id` etc. ? | 2017-12-19T09:30:00.000058 | Katy |
clojurians | clojure | My use case is that I'd like to pre-generate all routes of my app (several millions, I think 2~5) since I know them in advance, but still be able to differentiate them in the interceptors. Some are product pages, others are listing pages. Several of them will also have query-params attached to them (like ?productid=X) | 2017-12-19T09:33:02.000460 | Katy |
clojurians | clojure | Or maybe I need to do something else once I generate the routes ? I can't find enough help in pedestal docs/tests/source as to what to pass to `expand-routes` (to be more precise, to some function that will call `expand-routes`). | 2017-12-19T09:36:18.000010 | Katy |
clojurians | clojure | FWIW there is a <#C0K65B20P|pedestal> room which be a better place to ask | 2017-12-19T10:11:03.000933 | Hugo |
clojurians | clojure | oh thanks, didn't know | 2017-12-19T10:33:09.000720 | Katy |
clojurians | clojure | Hey folks, I'm trying to get gen-class working and I can't seem to get the syntax right for passing an array of Strings. I've tried the following (and then some). I'm sure the actual answer is pretty simple, but I haven't found it yet. Can someone help me out? Thanks!
```
;Nope
(:gen-class
:methods [#^{:static true} [foo [[Ljava.lang.String;] int]])
;https://groups.google.com/forum/#!topic/clojure/TFLUw8GSAbY
(:gen-class
:methods [#^{:static true} [foo [#^"[Ljava.lang.String;"] int]])
;Another guess
(:gen-class
:methods [#^{:static true} [foo [(Class/forName "[Ljava.lang.String;")] int]])
``` | 2017-12-19T10:34:53.000678 | Monet |
clojurians | clojure | Anyone know a good python slack team? or anyone here know python? | 2017-12-19T10:56:15.000270 | Billye |
clojurians | clojure | I can help with Python | 2017-12-19T10:57:36.000582 | Vilma |
clojurians | clojure | <@Monet> Corrected: ```;https://groups.google.com/forum/#!topic/clojure/TFLUw8GSAbY corrected
(:gen-class
;; Remove spurious hash-and-caret (#^) in front of type definition
:methods [#^{:static true} [foo ["[Ljava.lang.String;"] int]])```
Now, incidentally, I haven’t been able to get a `static` definition to work… | 2017-12-19T12:57:54.000472 | Heide |
clojurians | clojure | you can replace `#^{:static true}` with `^:static` iirc | 2017-12-19T13:01:47.000632 | Margaret |
clojurians | clojure | True, but let’s try one more time (<@Monet>) ```(ns sandbox.HelpOut
(:gen-class
:name sandbox.HelpOutClass4
:main false
:methods [
^:static [foo ["[Ljava.lang.String;"] int]
[bar ["[Ljava.lang.String;"] int]
]))
(defn -foo
"This is declared `static`"
[some-strings]
(let [how-many (count some-strings)]
(doseq [[i x] (map-indexed #(vector %1 %2) some-strings)]
(println (format "(%d): %s" i x)))
how-many))
(defn -bar
"This is an instance method"
[_ some-strings]
(let [how-many (count some-strings)]
(doseq [[i x] (map-indexed #(vector %1 %2) some-strings)]
(println (format "(%d): %s" i x)))
how-many))```
The `^:static` notation goes before the whole vector that describes the method | 2017-12-19T13:03:00.000699 | Heide |
clojurians | clojure | correct | 2017-12-19T13:03:01.000515 | Kareen |
clojurians | clojure | also `#^` is old deprecated syntax, just `^` will do | 2017-12-19T13:03:16.000794 | Kareen |
clojurians | clojure | Awesome, thanks for the help! | 2017-12-19T13:12:18.000094 | Monet |
clojurians | clojure | Why was it deprecated? I quite like how special things use `#` | 2017-12-19T13:16:47.000353 | Jodie |
clojurians | clojure | because `^` is shorter | 2017-12-19T13:19:00.000076 | Kareen |
clojurians | clojure | originally `#^` was what `^` is now | 2017-12-19T13:19:08.000192 | Kareen |
clojurians | clojure | and `^` was reader syntax for `(meta` | 2017-12-19T13:19:20.000057 | Kareen |
clojurians | clojure | it was later changed so that `^` is syntax for with-meta like `#^`, with `^` being the preferred syntax | 2017-12-19T13:19:59.000074 | Kareen |
clojurians | clojure | I was glad for the (re-?)education, thanks for the opportunity | 2017-12-19T13:36:27.000224 | Heide |
clojurians | clojure | (And, as for “old deprecated syntax”: some learn from older books, like those in former Colonies learning English from books from the 1880s; some of us are old enough [in Clojure] that that syntax was once our native tongue, and we have to learn your newfangled slang.) | 2017-12-19T13:38:58.000219 | Heide |
clojurians | clojure | I believe `^` has been the preferred way since 1.2, so for quite a long time :) | 2017-12-19T13:47:13.000111 | Kareen |
clojurians | clojure | This has been my fallback link every time I forget how to do this <https://stackoverflow.com/questions/2181774/calling-clojure-from-java> and it has "Ye Olde English" style. Perhaps an updated example on <https://clojure.org/reference/java_interop> would set things aright. | 2017-12-19T14:03:01.000485 | Monet |
clojurians | clojure | That seems different to other of clojure's design choices, especially the recent ##NaN | 2017-12-19T14:25:40.000345 | Jodie |
clojurians | clojure | how? | 2017-12-19T14:26:07.000180 | Kareen |
clojurians | clojure | they're completely different scenarios | 2017-12-19T14:26:30.000491 | Kareen |
clojurians | clojure | Using # for all special syntax seems consistent. Having ^ be an exception seems inconsistent. | 2017-12-19T14:27:05.000119 | Jodie |
clojurians | clojure | I'm sure you wouldn't like to write `#@` either | 2017-12-19T14:27:14.000334 | Kareen |
clojurians | clojure | there's a number of reader macros that are not routed through the `#` dispatch | 2017-12-19T14:27:30.000448 | Kareen |
clojurians | clojure | the reason why we went for `##NaN` and not `NaN` is that Rich didn't want to pollute the namespace of special symbols | 2017-12-19T14:27:59.000611 | Kareen |
clojurians | clojure | but in this case `^` was already reserved as a reader macro | 2017-12-19T14:28:13.000002 | Kareen |
clojurians | clojure | we use `#` as a dispatch macro mostly just because (good) top level symbols were running out | 2017-12-19T14:29:38.000100 | Kareen |
clojurians | clojure | That's true, I hadn't considered @. I'd be happy to move to #@ though.
I think I've grown fond of consistent syntax. | 2017-12-19T14:30:16.000399 | Jodie |
clojurians | clojure | what about :, ` ' ; ~ etc | 2017-12-19T14:30:47.000503 | Kareen |
clojurians | clojure | there's tonnes of top level reader macros | 2017-12-19T14:30:55.000470 | Kareen |
clojurians | clojure | and there's absolutely no reason for them to be prefixed | 2017-12-19T14:31:06.000156 | Kareen |
clojurians | clojure | There's much less sanctity of # than I realised when making the comment. I think I've seen comments valuing that clojure has concise syntax for many things, it makes sense in that context. | 2017-12-19T14:33:38.000537 | Jodie |
clojurians | clojure | I still struggle to picture myself wanting #^ to be shorter. | 2017-12-19T14:34:14.000627 | Jodie |
clojurians | clojure | you've never used `^foo` or `^:foo` then I assume? ;) | 2017-12-19T14:34:38.000489 | Kareen |
clojurians | clojure | here's the thing, `#^` didn't become `^` *because* it was shorter, rather, we realized that `^` as a reader macro for `(meta` had virtually no use, while `with-meta` had quite a bit of use | 2017-12-19T14:36:18.000457 | Kareen |
clojurians | clojure | so it was decided to repurpose `^` to be the more useful `with-meta`, and `#^` was kept for backwards compatibility | 2017-12-19T14:36:47.000304 | Kareen |
clojurians | clojure | I see, that's a more interesting growth. I can't actually see a particular purpose for the old ^ symbol.
I have never used those much, no. They don't seem to come up in normal use of clojure, for me. Not enough that I'd want to shave a character off.
Generally speaking, outside of functions and arguments, I don't see any use of metadata in clojure code. Arguments cited usually involve losing metadata under certain cases, and being concealed. | 2017-12-19T14:42:25.000123 | Jodie |
clojurians | clojure | <@Monet> An alternative to generating classes in Clojure is to use the Java API to require and invoke code (it's the approach we've used at World Singles) -- see Alex Miller's answer to that SO question <https://stackoverflow.com/questions/2181774/calling-clojure-from-java/23555959#23555959> | 2017-12-19T15:07:22.000423 | Daniell |
clojurians | clojure | could someone please advice? I want to load namespace every time I run "lein repl", but not on other tasks... | 2017-12-19T15:13:04.000761 | Shelly |
clojurians | clojure | Are there any clojure SQL libs that just make every table lazily available? Something like
`(take 2 (:customers tables)) => [{:name "drew"} {:name "sally"}]` | 2017-12-19T15:14:46.000344 | Glory |
clojurians | clojure | <@Shelly> one traditional answer to this is to add `:profiles {:dev {:source-paths ["dev/"]}}`, and then put the code you want to load in `dev/user.clj` where Clojure will load it automatically for you. | 2017-12-19T15:16:54.000323 | Charity |
clojurians | clojure | @aardem , but won't `dev/user.clj` load on all other tasks as well? | 2017-12-19T15:17:50.000112 | Shelly |
clojurians | clojure | I wish there were special profile for repl... | 2017-12-19T15:20:27.000285 | Shelly |
clojurians | clojure | <@Glory> I can think of all sorts of ways that would be problematic for resource usage (connections etc). Also, what would it mean to lazily process a table while updates were made to that table in other threads or processes? | 2017-12-19T15:29:26.000277 | Daniell |
clojurians | clojure | About the closest you can probably get is building some sort of abstraction on top of `reducible-query` (from `clojure.java.jdbc`) because you could use `sequence` and/or `eduction` to produce sequences of rows from tables... (off the top of my head). | 2017-12-19T15:31:27.000193 | Daniell |
clojurians | clojure | Good input @seancofield thanks. hmmm | 2017-12-19T15:34:15.000139 | Glory |
clojurians | clojure | Special profile for `:repl`? I think there is: <https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md> | 2017-12-19T15:40:32.000007 | Heide |
clojurians | clojure | that's mess for a beginner... I am trying to extend the :repl profile
` :dev-repl {:repl {:source-paths ["src" "env/dev"]
:main "env.figwheel-api"}}`
but fails with *Warning: no nREPL dependency detected.* | 2017-12-19T16:02:12.000093 | Shelly |
clojurians | clojure | ```
;; (wrap cublasSasum 3) -> #(JCublas/cublasSasum %1 %2 %3)
;; (wrap cublasSaxpy 4) -> #(JCublas/cublasSaxpy %1 %2 %3 %4)
(defmacro wrap [fname n]
(let [args (vec (take n gensym))
jname ...]
`(fn ~args
(~jname ~@args))))
```
what do I put in the ... ? JCublas = not a clojure namespace, but a Java class | 2017-12-19T16:14:58.000561 | Berry |
clojurians | clojure | `(symbol "package.to.Jcublas" (name fname))` | 2017-12-19T16:16:18.000354 | Kareen |
clojurians | clojure | Is it possible to launch REPL with different Leiningen profile? Is it only my setup? :face_with_rolling_eyes: | 2017-12-19T16:43:06.000448 | Shelly |
clojurians | clojure | two options: `lein with-profile +foo repl` - that merges the foo profile in; `lein with-profile foo run -m clojure.main ...` that starts a vanilla repl with only the foo profile (no nrepl btw) | 2017-12-19T16:45:18.000398 | Margaret |
clojurians | clojure | thank you very much! | 2017-12-19T16:47:54.000104 | Shelly |
clojurians | clojure | Can I run `lein repl` with different `user.clj` specified? ideally cpecified via Leiningen's profile.clj... | 2017-12-19T17:01:40.000247 | Shelly |
clojurians | clojure | wouldn’t putting a different directory on the front of the classpath (source-paths) so that the user.clj there is found first do the trick? | 2017-12-19T17:15:00.000039 | Margaret |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.