workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians | clojure | thanks! | 2017-11-06T13:13:14.000544 | Amado |
clojurians | clojure | <@Venessa> - Agreed with the other comments about YAGNI, but in case you do need it: <https://clojuredocs.org/clojure.data/diff> | 2017-11-06T13:44:44.000331 | Adelaida |
clojurians | clojure | thanks! | 2017-11-06T13:45:01.000286 | Venessa |
clojurians | clojure | I need to parse simple text like: `"Important Field: {{important-field}}"`
and replace `{{important-field}}` with a value from a map
should I use something as heavy as instaparse, or what would be an idiomatic way in clojure? | 2017-11-06T14:02:55.000515 | Lori |
clojurians | clojure | Instaparse isn't well suited for "find/replace" use cases | 2017-11-06T14:04:11.000220 | Edelmira |
clojurians | clojure | It's more designed to parse a whole block of text data and interpret it as data | 2017-11-06T14:05:12.000700 | Edelmira |
clojurians | clojure | there are templating libraries that use that syntax already | 2017-11-06T14:05:24.000436 | Margaret |
clojurians | clojure | yeah, like <https://github.com/fhd/clostache> | 2017-11-06T14:05:39.000401 | Edelmira |
clojurians | clojure | and selmer, and antlers | 2017-11-06T14:05:51.000371 | Margaret |
clojurians | clojure | Selmer would be my first choice (we use it very heavily at World Singles), but clostache is probably simpler/more lightweight for this use case(?). | 2017-11-06T14:06:26.000013 | Daniell |
clojurians | clojure | or `(clojure.string/replace my-str #"\{\{(.*?)\}\}" (fn ...))` | 2017-11-06T14:07:07.000150 | Edelmira |
clojurians | clojure | thanks for the options, I'll weigh em out for my use case! | 2017-11-06T14:09:02.000178 | Lori |
clojurians | clojure | x = float-array of size 1000
y = float-array of size 2000
is there a builtin to say
y[1000:1999] = x ?
(I'm hoping for a java builtin faster than 1000 aset / agets) | 2017-11-06T14:41:06.000428 | Berry |
clojurians | clojure | System/arraycopy (no slices on JVM) | 2017-11-06T14:42:18.000548 | Guillermo |
clojurians | clojure | <@Guillermo>: <https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#arraycopy(java.lang.Object,%20int,%20java.lang.Object,%20int,%20int)> ? | 2017-11-06T14:43:08.000189 | Berry |
clojurians | clojure | yup ~(but the long arity version)~, that one | 2017-11-06T14:43:26.000659 | Guillermo |
clojurians | clojure | ```
(def n (* 1000 1000 1000))
(def x (float-array n))
(def y (float-array (+ 1000 n)))
(cc/quick-bench
(System/arraycopy x 0 y 999 n))
```
gives:
```
Evaluation count : 6 in 6 samples of 1 calls.
Execution time mean : 1.047620 sec
Execution time std-deviation : 98.981008 ms
Execution time lower quantile : 954.274457 ms ( 2.5%)
Execution time upper quantile : 1.137644 sec (97.5%)
Overhead used : 1.962587 ns
```
that is copying 4GB in 1.13 seconds -- that's insane | 2017-11-06T14:46:30.000486 | Berry |
clojurians | clojure | I bet that’s leaning heavily on OS level optimizations - might be interesting to benchmark on various platforms | 2017-11-06T14:58:42.000273 | Margaret |
clojurians | clojure | agreed, short of a memcpy, I'm not sure how it can be that fast | 2017-11-06T15:08:08.000128 | Berry |
clojurians | clojure | hi there, I’m having an issue with futures | 2017-11-06T16:26:38.000448 | Ross |
clojurians | clojure | I have a fn with `(try ... (catch ) ... (finally))` that works ok and returns as expected | 2017-11-06T16:27:02.000361 | Ross |
clojurians | clojure | but when I run it through an executor it returns nil | 2017-11-06T16:27:11.000033 | Ross |
clojurians | clojure | do you guys have any pointers? | 2017-11-06T16:28:20.000093 | Ross |
clojurians | clojure | ```
(defn submit-job [fn] (.submit threadpool fn))
@(submit-job (constantly 1))
nil
``` | 2017-11-06T16:29:31.000162 | Ross |
clojurians | clojure | submit can take a Runnable or a Callable, and fn's implement both, so the reflector has to pick one | 2017-11-06T16:32:34.000113 | Rebeca |
clojurians | clojure | ^Callable fn | 2017-11-06T16:32:41.000671 | Rebeca |
clojurians | clojure | submit returns a future that returns a value when you deref it | 2017-11-06T16:33:17.000337 | Rebeca |
clojurians | clojure | if you submit a Callable you get the return value of the callable | 2017-11-06T16:33:30.000589 | Rebeca |
clojurians | clojure | `Runnable` doesn't return a value, `Callable` does. | 2017-11-06T16:33:34.000469 | Daniell |
clojurians | clojure | `(deref (submit-job (cast java.util.concurrent.Callable (fn [] 1))))` still nil | 2017-11-06T16:34:02.000281 | Ross |
clojurians | clojure | (well, in an imprecise way :slightly_smiling_face: ) | 2017-11-06T16:34:02.000469 | Daniell |
clojurians | clojure | Use a type hint. | 2017-11-06T16:34:16.000143 | Daniell |
clojurians | clojure | I feel stupid :slightly_smiling_face: gonna learn something today I guess | 2017-11-06T16:34:16.000148 | Ross |
clojurians | clojure | you can't use cast for that | 2017-11-06T16:34:24.000057 | Rebeca |
clojurians | clojure | `(defn submit-job [^Callable fn] (.submit threadpool fn))` I think? | 2017-11-06T16:34:36.000531 | Daniell |
clojurians | clojure | and you can't type hint a (fn ..) form like that either | 2017-11-06T16:34:37.000436 | Rebeca |
clojurians | clojure | cast is runtime, I want to tell the compiler how to dispatch right? | 2017-11-06T16:34:46.000081 | Ross |
clojurians | clojure | correct, as <@Daniell> has it | 2017-11-06T16:35:00.000551 | Rebeca |
clojurians | clojure | nope :smile: `@(let [^java.util.concurrent.Callable f (fn [] 1)] (.submit threadpool f))` | 2017-11-06T16:35:58.000675 | Ross |
clojurians | clojure | still nil | 2017-11-06T16:36:10.000225 | Ross |
clojurians | clojure | you also need to type hint threadpool | 2017-11-06T16:36:55.000138 | Rebeca |
clojurians | clojure | if you `(set! *warn-on-reflection* true)` you will see that the method call is still reflective | 2017-11-06T16:37:28.000634 | Rebeca |
clojurians | clojure | ```boot.user=> (defn submit-job ^java.util.concurrent.Future [^java.util.concurrent.Callable f] (.submit ^java.util.concurrent.ForkJoinPool fjpool f))
#'boot.user/submit-job
boot.user=> (deref (submit-job (constantly 1)))
1``` | 2017-11-06T16:40:53.000075 | Daniell |
clojurians | clojure | (I'm using a ForkJoinPool for ease of creation but should work with a general executor service) | 2017-11-06T16:41:34.000372 | Daniell |
clojurians | clojure | (switching the type hint to `^java.util.concurrent.ExecutorService` works -- I just tried it) | 2017-11-06T16:42:16.000131 | Daniell |
clojurians | clojure | the reflected method chosen may actually vary by clojure release, with the beta of 1.9 even with reflection it chooses the callable version of submit | 2017-11-06T16:42:21.000448 | Rebeca |
clojurians | clojure | ```
user=> (set! *warn-on-reflection* true)
true
user=> (def pool1 (java.util.concurrent.Executors/newFixedThreadPool 2))
#'user/pool1
@(let [^Runnable f (fn [] 1)]
(.submit ^java.util.concurrent.ExecutorService pool1 f))
nil
@(let [^Callable f (fn [] 1)]
(.submit ^java.util.concurrent.ExecutorService pool1 f))
1
user=>
``` | 2017-11-06T16:42:34.000381 | Rebeca |
clojurians | clojure | (if I explicitly type hint I can get the Runnable version) | 2017-11-06T16:43:12.000166 | Rebeca |
clojurians | clojure | thanks all, it seems type hints fixed it | 2017-11-06T16:44:43.000362 | Ross |
clojurians | clojure | when we base64 encode a string, how much does the size increase by ? does it mean each byte is now only storing 6 bits instead of 8, so a 3MB file -> 4 MB ? | 2017-11-06T17:06:10.000228 | Berry |
clojurians | clojure | does anyone know of a good resources to learn about clojure zippers, preferably excersizes I can try to solve? | 2017-11-06T17:11:32.000543 | Evelin |
clojurians | clojure | I've read through the docs, and read an overview and a few tutorials | 2017-11-06T17:11:53.000052 | Evelin |
clojurians | clojure | but i really want to try to solve some problems with them, but its hard to create your own problems | 2017-11-06T17:12:11.000079 | Evelin |
clojurians | clojure | yes, but probably a topic for <#C03RZGPG3|off-topic> | 2017-11-06T17:34:07.000550 | Guillermo |
clojurians | clojure | does anyone know if `:ret` and `:fn` aspects of `fdef` on macros are no longer being checked? The docs sort of discourage checking `:ret` (although they do not explicitly forbid it) and I'm seeing in practice that they are not being checked and just wondered if the "discouragement" became a "mandate enforced by code itself" | 2017-11-06T18:26:41.000276 | Edward |
clojurians | clojure | apart from the docs being updated to reflect such | 2017-11-06T18:27:27.000077 | Edward |
clojurians | clojure | They are only checked during stest/check, not during instrument | 2017-11-06T18:39:06.000156 | Sonny |
clojurians | clojure | <@Sonny> so what aspects are checked during instrument? just `:args`? | 2017-11-06T18:57:29.000083 | Edward |
clojurians | clojure | Yes - the purpose of instrument is to check for correct invocation | 2017-11-06T18:57:54.000369 | Sonny |
clojurians | clojure | got it. thanks | 2017-11-06T18:58:04.000050 | Edward |
clojurians | clojure | Check is for checking whether a function does what it says | 2017-11-06T18:58:21.000281 | Sonny |
clojurians | clojure | <@Edward> you can also use <https://github.com/jeaye/orchestra> for instrumenting :ret and :fn | 2017-11-06T19:02:46.000449 | Shira |
clojurians | clojure | what does @ before a variable mean. `(let [st @state]...` from the om wiki page. Can't seem to find it googling | 2017-11-06T20:43:23.000036 | Charlie |
clojurians | clojure | <https://clojuredocs.org/clojure.core/deref> | 2017-11-06T20:44:38.000242 | Dawne |
clojurians | clojure | Without the @, it returns the atom object | 2017-11-06T20:45:02.000013 | Cristi |
clojurians | clojure | With the @/deref, it returns the _value_ contained in the atom | 2017-11-06T20:45:31.000080 | Cristi |
clojurians | clojure | thanks. | 2017-11-06T20:45:52.000184 | Charlie |
clojurians | clojure | A good little example here <https://funcool.github.io/clojurescript-unraveled/#atoms> | 2017-11-06T20:47:21.000091 | Dawne |
clojurians | clojure | @ symbols are hard to google for | 2017-11-06T20:48:09.000084 | Charlie |
clojurians | clojure | haha yes. It seems the only way would be to know that is is short for `deref` | 2017-11-06T20:49:48.000082 | Dawne |
clojurians | clojure | clojure has a lot of hard to google usage | 2017-11-06T20:50:06.000140 | Jonas |
clojurians | clojure | the backtick, `->`, `->>`, `#(+ 1 %)`, `#{}` | 2017-11-06T20:50:33.000202 | Jonas |
clojurians | clojure | to name a few | 2017-11-06T20:50:38.000144 | Jonas |
clojurians | clojure | what's the last one of those | 2017-11-06T20:50:51.000088 | Charlie |
clojurians | clojure | it’s the set primitive | 2017-11-06T20:51:11.000187 | Jonas |
clojurians | clojure | `#{1, 2, 3}` | 2017-11-06T20:51:21.000028 | Jonas |
clojurians | clojure | is a set with the numbers 1, 2, and 3 | 2017-11-06T20:51:36.000155 | Jonas |
clojurians | clojure | `#{}`, is the empty set | 2017-11-06T20:51:41.000186 | Jonas |
clojurians | clojure | symbolhound is useful for these: <http://symbolhound.com/?q=%40+clojure> | 2017-11-06T20:51:52.000045 | Raul |
clojurians | clojure | oh yea, and `#"[a-z]*"` | 2017-11-06T20:52:02.000045 | Jonas |
clojurians | clojure | after learning about threading I can't help but get frustrated at c# almost every time i turn the corner at work | 2017-11-06T20:52:29.000263 | Charlie |
clojurians | clojure | there's also a nice list of these: <https://clojure.org/guides/weird_characters> | 2017-11-06T20:52:32.000079 | Raul |
clojurians | clojure | looks like I forgot a few | 2017-11-06T20:53:24.000123 | Jonas |
clojurians | clojure | looks like it’s missing the `->` prefix | 2017-11-06T20:54:07.000245 | Jonas |
clojurians | clojure | as well as the `map->` prefix | 2017-11-06T20:54:18.000131 | Jonas |
clojurians | clojure | a few people were wondering about that earlier today | 2017-11-06T20:54:27.000205 | Jonas |
clojurians | clojure | those would be nice additions to that list. Don't know who maintains it so we can recommend the addition? | 2017-11-06T20:55:01.000216 | Raul |
clojurians | clojure | it's open source: <https://github.com/clojure/clojure-site> | 2017-11-06T20:59:28.000043 | Evan |
clojurians | clojure | feel free to send a pr or an issue to update on that repo | 2017-11-06T22:54:14.000037 | Sonny |
clojurians | clojure | also see the threading macro guide <https://clojure.org/guides/threading_macros> | 2017-11-06T22:54:53.000071 | Sonny |
clojurians | clojure | ```
(defn rx1 [x] x)
(defn rx2 [x] (* x x))
(defn rx3 [x] (* x x x))
(defn hpc [tensor cb]
;; cb :: double -> double
;; cb is called around 10,000,000 times
;; this is a big, hairy function
;; I would prefer to not turn it into a macro
)
(defn h1 [tensor] (hpc tensor rx1))
(defn h2 [tensor] (hpc tensor rx2))
(defn h3 [tensor] (hpc tensor rx3))
```
Question: is it possible to tell clojure
to inline rx1, rx2, rx3 ?
"Don't worry about it, JVM hot spotting will take
care of it" is a valid answer. | 2017-11-06T23:29:23.000183 | Berry |
clojurians | clojure | <@Berry> Well, there's `:inline` metadata but I don't know how well documented that is, and I suspect it's experimental/subject to change... | 2017-11-06T23:33:54.000121 | Daniell |
clojurians | clojure | <@Daniell>: yeah, I read <http://bytopia.org/2014/07/07/inline-functions-in-clojure/> ... but there is a comment by <@Sonny> at the bottom of the blog post suggesting caution | 2017-11-06T23:34:31.000070 | Berry |
clojurians | clojure | That was back in 2014 -- and I don't think anything has actually changed since...? | 2017-11-06T23:35:39.000132 | Daniell |
clojurians | clojure | does tat mean "nothing has changed; therefore stable to use" or "alex's caution hasn't changed, still dangerous to use" ? :slightly_smiling_face: | 2017-11-06T23:36:09.000130 | Berry |
clojurians | clojure | It's worth noting that CLJ-1227 is indicated as being caused by <https://dev.clojure.org/jira/browse/CLJ-1330> which is fixed. | 2017-11-06T23:38:59.000078 | Daniell |
clojurians | clojure | I meant "Alex's caution probably still stands but it hasn't been removed yet" :slightly_smiling_face: | 2017-11-06T23:39:26.000127 | Daniell |
clojurians | clojure | ```~(let [(vary-meta foobar# assoc :tag 'long) ...] ```
this is not allowed -- can I not use foobar# , and have to explicitly use a gensym ? | 2017-11-06T23:44:27.000054 | Berry |
clojurians | clojure | You mean with `:inline`? | 2017-11-06T23:46:18.000130 | Daniell |
clojurians | clojure | the `#` suffix is just a backtick thing | 2017-11-06T23:46:27.000137 | Jonas |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.