workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
Each jobs takes 10-20 seconds to execute.
2017-12-24T21:17:57.000093
Berry
clojurians
clojure
Turns out, I was mis-reading the output of TOP. On per process, it' sshowing full usage (i..e 2400%), but on the top overall usage, it's showing 99% (i.e. 2400 / 2400).
2017-12-24T21:18:24.000009
Berry
clojurians
clojure
s/tuple is also just a vector (and is typically used for heterogeneous collections)
2017-12-24T23:17:23.000013
Edward
clojurians
clojure
is it possible to: 1. pass an anonymous function to a macro and 2. evaluate the function at MACRO EXPANSION time in particular, I want to do: `` (defmacro foo [ .... ] ....) (foo (fn [x] (println (+ 1))) ...)
2017-12-25T03:39:34.000051
Berry
clojurians
clojure
and I want the function evaluated at macro expansion time
2017-12-25T03:39:44.000078
Berry
clojurians
clojure
you're actually passing a list to your macro ... that might require a call to eval
2017-12-25T03:43:29.000103
Amee
clojurians
clojure
yeah, I have this weird situation where `foo` behave as follows: `(foo f1 f2 data)` where `data` is interpreted as data however, I want to parameterize `foo` by passing it functions `f1`, `f2`, that modify the behaviour of `foo` -- is this possible ?
2017-12-25T03:48:32.000089
Berry
clojurians
clojure
Sounds like (def bar (partial foo f1 f2)) (bar data)
2017-12-25T04:47:22.000062
Virgil
clojurians
clojure
maybe i lack imagination, but i can't imagine a case where some client code would use a macro, parameterizing it with a function... So I guess you're writing a macro that itself calls a macro. In that case you would want the outer macro calling into functions that build the code rather than callinbg into macros, so you're out of the macro system as soon as you enter the outer level
2017-12-25T05:13:00.000096
Amee
clojurians
clojure
in 10 (?) years since i started playing with clojure, i wrote maybe 5-10 macros and most were of the def-thing kind...thinly wrapping a function call.
2017-12-25T05:14:58.000018
Amee
clojurians
clojure
then again, i had my macro abuse period earlier with common lisp =)
2017-12-25T05:15:53.000017
Amee
clojurians
clojure
macros are a code smell (most of the time)
2017-12-25T05:16:57.000055
Amee
clojurians
clojure
that's to say, are you really sure you want a macro? and if so, can you simplify it so that it's only a wrapper around your data orienbted or function oriented underlying system
2017-12-25T05:17:41.000040
Amee
clojurians
clojure
ah nice! never heard of it :eyes:
2017-12-25T05:36:31.000072
Kristy
clojurians
clojure
I'm writing macros to help me generate clojure bindings to an java api
2017-12-25T05:50:25.000095
Berry
clojurians
clojure
There are alot of functions to bind. I want to pass it two functions, `c-name` and `j-name`, which decides how the functions are named, for example, I want
2017-12-25T05:51:07.000034
Berry
clojurians
clojure
```(make-bind c-name j-name foo bar cat dog)``` to bind cu-foo to java.jcuda.JCublas2/cublasFoo cu-bar to java.jcuda.JCublas2/cublasBar ...
2017-12-25T05:51:44.000078
Berry
clojurians
clojure
so I have c-name be a function (s -> (symbol (str "cu-" s))) and j-name something to append the java.jcuda.JCublas2/cublas and capitalize the symbol
2017-12-25T05:52:18.000041
Berry
clojurians
clojure
but now, I want the cname and j-name to be functions rather than hard coded, because I also will be binding jcudafft, jcuda/cudnn / ...
2017-12-25T05:52:41.000085
Berry
clojurians
clojure
<@Berry> can't you turn the macro into a function returning a map (of functions)?
2017-12-25T07:13:38.000032
Daine
clojurians
clojure
During cider debugging, is there a way for it to keep refreshing local variables every step ( the l key) ?
2017-12-25T08:33:22.000019
Temple
clojurians
clojure
(visually)
2017-12-25T08:45:53.000105
Temple
clojurians
clojure
Looks like a fine occasion for macros indeed. I would take it in reverse order, by first gathering/processing a list of symbol names then feeding that into a def-bindings macro
2017-12-25T12:29:06.000012
Amee
clojurians
clojure
Guys how can I call the base method of a class on an object?
2017-12-25T15:39:36.000073
Cristina
clojurians
clojure
by making a class that calls the superclass' method right?
2017-12-25T15:44:26.000025
Margaret
clojurians
clojure
maybe I don't understand what you're asking for
2017-12-25T15:45:27.000010
Margaret
clojurians
clojure
<https://clojuredocs.org/clojure.core/proxy-super> ?
2017-12-25T15:54:34.000038
Amee
clojurians
clojure
Why I can't `(&gt; #inst"2017" #inst"2018")` in clojure? It works on cljs. And on clojure, I can compare `inst` via `sort`..
2017-12-25T16:14:07.000051
Jutta
clojurians
clojure
the fact that it works on cljs is just because javascript can do `&gt;` with Dates and cljs's `&gt;` delegates to javascript's `&gt;`
2017-12-25T16:27:23.000002
Kareen
clojurians
clojure
clojure's `&gt;` is defined only in terms of numbers
2017-12-25T16:27:33.000007
Kareen
clojurians
clojure
the fact that it works in cljs is an accident of the implementation
2017-12-25T16:27:48.000014
Kareen
clojurians
clojure
I don't remember if `#inst` in Cljs emits `js/Date` or `goog.date.DateTime` or `UtcDateTime`, if latter, it shouldn't be comparable by default, but if `cljs-time.extend` ns is loaded, that will extend `IComparable` to `DateTime` and `UtcDateTime`
2017-12-25T16:58:17.000020
Carletta
clojurians
clojure
`#inst` creates JS Date, so `cljs-date.extend` won't affect that
2017-12-25T17:03:42.000013
Carletta
clojurians
clojure
<http://www.jcuda.org/jcuda/jcublas/doc/jcuda/jcublas/JCublas2.html#cublasSgemm(jcuda.jcublas.cublasHandle>, int, int, int, int, int, jcuda.Pointer, jcuda.Pointer, int, jcuda.Pointer, int, jcuda.Pointer, jcuda.Pointer, int) is there a way to call 'resolve' or some other function, and get taht function as a result ?
2017-12-25T17:04:22.000023
Berry
clojurians
clojure
i.e. I want something that will take "jcuda.jcublas.JCublas2/cublasSgemm", and return that function
2017-12-25T17:04:36.000001
Berry
clojurians
clojure
Hm, could somebody explain me the difference between `merge` and `into`? does the latter have side effects?
2017-12-25T17:09:27.000025
Marcel
clojurians
clojure
nope, apparently not
2017-12-25T17:10:08.000001
Marcel
clojurians
clojure
`into` supports a transducer…
2017-12-25T17:13:32.000047
Marcel
clojurians
clojure
<@Berry> no, java methods are not first class in clojure
2017-12-25T17:15:25.000045
Kareen
clojurians
clojure
<@Marcel> `merge` is only for maps, `into` works for any collection
2017-12-25T17:15:41.000027
Carletta
clojurians
clojure
you could do that via reflection if you wanted to but it doesn't sound like a particularly good idea
2017-12-25T17:16:02.000032
Kareen
clojurians
clojure
<@Carletta> hmm, but `merge` does merge vectors as well. kind of
2017-12-25T17:20:56.000038
Marcel
clojurians
clojure
but yeah, merge source calls the parameter `&amp; maps`
2017-12-25T17:22:05.000012
Marcel
clojurians
clojure
<@Kareen>: so the only three ways to get a java method are: 1. type it out literally in clojure code 2. have a macro generate it at macro expansion time 3. get it via reflection ?
2017-12-25T17:23:26.000024
Berry
clojurians
clojure
yes, 1&amp;2 are equivalent, I dont know how else you'd expect to do it
2017-12-25T17:25:23.000047
Kareen
clojurians
clojure
"either statically(1,2) or programmatically(3)" make a total set
2017-12-25T17:26:43.000030
Kareen
clojurians
clojure
lol, it has been said that genius is rephrasing the question so the answer is obvious
2017-12-25T17:33:04.000006
Berry
clojurians
clojure
this works accidentally and isn't an intended feature
2017-12-25T17:52:42.000066
Margaret
clojurians
clojure
alrighty; thanks!
2017-12-25T18:26:26.000035
Marcel
clojurians
clojure
(:require [clojure.string :as ...])
2017-12-26T03:16:58.000004
Berry
clojurians
clojure
what is a good name, as `str` is already a function
2017-12-26T03:17:03.000053
Berry
clojurians
clojure
`string`
2017-12-26T03:47:55.000102
Elijah
clojurians
clojure
Lots of people use str as an alias for clojure.string, because str/lower-case doesn't cause any conflict with the clojure.core/str function.
2017-12-26T03:55:27.000144
Micha
clojurians
clojure
<@Jutta> You can use clojure.core/compare to get a result of -1, 0, or +1 when comparing two #inst's to each other.
2017-12-26T03:56:37.000159
Micha
clojurians
clojure
what is the simplest string manip function which does camelCase to hypen-separated
2017-12-26T04:10:17.000039
Berry
clojurians
clojure
ah, found this: ``` (defn kebab-case "Converts CamelCase / camelCase to kebab-case" [s] (str/join "-" (map str/lower-case (re-seq #"\w[a-z]+" s)))) ```
2017-12-26T04:11:28.000036
Berry
clojurians
clojure
<@Micha>: I have n oidea why that works, but yes, it appears that namespace alias str does not collide with buildin function
2017-12-26T04:15:08.000090
Berry
clojurians
clojure
aliases and vars live in different "namespaces"
2017-12-26T05:39:20.000043
Kareen
clojurians
clojure
what is the conceptual difference between `compare` and `&gt;`?
2017-12-26T07:37:37.000124
Jutta
clojurians
clojure
`&gt;` is for numbers. See also +, *, /, - etc. - in other languages they might be overloaded for other data types but in jvm clojure they are only for numbers
2017-12-26T08:24:37.000192
Margaret
clojurians
clojure
<@Berry> When a textual identifier contains a "/" character, the thing before the "/" is tried to be resolved as either a full namespace, or as an alias of a namespace (I don't know off hand which order is checked for between those two). If there is no "/", no part of it is considered a namespace or alias, just a symbol on its own.
2017-12-26T14:38:31.000072
Micha
clojurians
clojure
meh, can’t come to a solution :weary: I have a lazyseq (file-seq) which I have to iterate through while occasionally change a local data structure (fill and read a hash-table in this loop). Is `loop/recur` the right approach?
2017-12-26T16:54:27.000133
Marcel
clojurians
clojure
or `reduce`?
2017-12-26T16:55:31.000056
Marcel
clojurians
clojure
if you always move through the lazy-seq in order, reduce is simpler / more direct than loop
2017-12-26T16:55:40.000012
Margaret
clojurians
clojure
so it’s okay to work with only one hash-structure for both the “actual” work data and help data?
2017-12-26T16:57:04.000134
Marcel
clojurians
clojure
I’m not super experienced with functional programming yet…
2017-12-26T16:57:31.000103
Marcel
clojurians
clojure
using one reduce argument to hold both an accumulated result and ancillary data is common
2017-12-26T16:58:01.000168
Margaret
clojurians
clojure
technically it is possible, question is about whether it is a good way of implementation
2017-12-26T16:58:02.000146
Marcel
clojurians
clojure
alrighty, thanks! will try it out immediately
2017-12-26T16:58:18.000054
Marcel
clojurians
clojure
if you use transduce, you can even specify the function that gets the real result out of the accumulator
2017-12-26T16:58:58.000205
Margaret
clojurians
clojure
<@Margaret> yeah, works as expected! didn’t try transduce yet, though
2017-12-26T17:27:58.000125
Marcel
clojurians
clojure
transduce is mainly useful if you are doing some transform on each item as it comes in
2017-12-26T17:28:35.000181
Margaret
clojurians
clojure
eg. replacing (reduce f init (map g coll)) with (transduce (map g) f init coll)
2017-12-26T17:29:05.000100
Margaret
clojurians
clojure
I’m iterating through a list of files keeping some information to exclude duplicates from being inserted into a DB… (file-hash, last-modified, path)
2017-12-26T17:29:39.000083
Marcel
clojurians
clojure
reduce might be enough for now, I think
2017-12-26T17:29:49.000165
Marcel
clojurians
clojure
sounds about right - the note about transduce was because including that feature indicates that it’s idiomatic to transform the accumulator to get your value out at the end
2017-12-26T17:30:40.000080
Margaret
clojurians
clojure
one advantage of loop/recur might be, that one can continue the loop from an arbitrary position, whereas with reduce, your nested if-clauses have always to return something…
2017-12-26T17:54:30.000082
Marcel
clojurians
clojure
just a guess
2017-12-26T17:54:32.000076
Marcel
clojurians
clojure
I should refactor a bit first
2017-12-26T17:56:20.000119
Marcel
clojurians
clojure
not arbitrary, it has to be from the "tail" position, so to speak
2017-12-26T17:56:25.000038
Ambrose
clojurians
clojure
maybe it’s not that bad
2017-12-26T17:56:31.000102
Marcel
clojurians
clojure
oh I thought calling “recur” is similar to “continue” in other langs
2017-12-26T17:57:00.000043
Marcel
clojurians
clojure
nope
2017-12-26T17:57:04.000109
Ambrose
clojurians
clojure
plus new bindings of course…
2017-12-26T17:57:08.000056
Marcel
clojurians
clojure
hm
2017-12-26T17:57:09.000030
Marcel
clojurians
clojure
you do always have to "return something"
2017-12-26T17:57:26.000057
Ambrose
clojurians
clojure
it seems I didn’t understand loop-recur :sweat_smile:
2017-12-26T17:57:39.000068
Marcel
clojurians
clojure
whether you're using loop/recur, or reduce, or anything else in clojure
2017-12-26T17:57:41.000052
Ambrose
clojurians
clojure
does it mean if I have a nested structure, that i can’t call “recur” from the most inner level to jump straight into the next iteration?
2017-12-26T17:58:48.000023
Marcel
clojurians
clojure
you can, as long as that recur is still in the tail position
2017-12-26T17:59:43.000111
Ambrose
clojurians
clojure
meaning, it needs to be the last thing that could get called
2017-12-26T17:59:52.000073
Ambrose
clojurians
clojure
I should stop talking and try it out myself - I’m concerned that I start explaining my misunderstandings and embarrass myself :smile:
2017-12-26T18:01:04.000150
Marcel
clojurians
clojure
``` (loop [] (if blah-blah (if something-else (recur) (other-stuff)) (foo)) ```
2017-12-26T18:01:05.000073
Ambrose
clojurians
clojure
in that example, recur is in the tail position
2017-12-26T18:01:42.000053
Ambrose
clojurians
clojure
but your example would look almost exactly the same with reduce, wouldn’t it?
2017-12-26T18:01:44.000017
Marcel
clojurians
clojure
coincidentally, other-stuff and foo are also in tail positions
2017-12-26T18:01:59.000077
Ambrose
clojurians
clojure
just that the else-branches would return the untouched collection
2017-12-26T18:02:11.000008
Marcel
clojurians
clojure
hm
2017-12-26T18:02:14.000036
Marcel
clojurians
clojure
well, it's a fairly contrived example, the else branches here are breaking out of the loop
2017-12-26T18:02:35.000100
Ambrose
clojurians
clojure
ah, of course!
2017-12-26T18:02:47.000036
Marcel