Fork me on GitHub
#clojure
<
2017-09-23
>
Takis_00:09:22

Hello everyone, cascalog looks very nice,you can use it to query/update etc a relational database throw jdbc taps?

aptr32206:09:29

let's say i have a collection of elements in map and I'l like that mutable and I'ld like to change one element. How do I do that?

aptr32206:09:00

clojurewise

hmaurer09:09:34

@aptr322 could you give an example? I am not exactly sure what you mean. If you are talking about update the value under a key in a map, check functions like assoc

qqq11:09:03

https://clojuredocs.org/clojure.core/defmulti <-- is defmulti dispatch function not allowed to return ":default" ?

pesterhazy11:09:54

@qqq I don't think so

lxsameer11:09:12

hey folks, I'm encouraged a friend who is a python dev to learn clojure. what book do you recommend for a python dev to learn clojure ?

pesterhazy12:09:40

Coming from Python, it hit the sweet spot for me

jstew13:09:45

If your friend is a web dev Web Development With Clojure is good. My first Clojure book was Clojure Programming.

andrewboltachev17:09:42

Hello. Is there a way to go from output of clojure.tools.reader/read (called all till EOF I mean) back to Clojure source file?

dominicm18:09:40

@andrewboltachev rewrite-clj can do this

dominicm18:09:47

(but it provides the read function)

andrewboltachev18:09:37

thanks @dominicm . I've just had a look at it

andrewboltachev18:09:45

In fact, clojure.tools.reader itself doesn't perserve exact shape of code read. E.g. ::foo might become :current-ns/foo

dominicm18:09:48

@andrewboltachev rewrite-clj fixes that

andrewboltachev20:09:10

Is there a way to insert into a vector, e.g. having [1 2 3] and 42 get [1 42 2 3]? 🙂

sophiago21:09:54

Is anyone here familiar with core.cache? I'm trying to determine whether I have a use case for it, but I suspect the maps I'm working with are far too small. For example, microbenchmarks show memoize decreases performance by ~10%. Are there any guidelines other than comparing the size of your data to L1 + L2 cache?

cddr21:09:59

@andrewboltachev Why would 42 go into the 2nd spot in the result?

cddr21:09:31

Or are you looking to define a function that lets you specify where it should go?

andrewboltachev21:09:01

I'm looking to insert a particular element to particular position of a vector. In this case 2nd (position 1).

cddr21:09:46

Gotcha. With clojure, you'd probably construct a new vector with the element added in the correct position. Something like

(defn insert-at [v item pos]
  (concat
   (subvec v 0 pos)
   [item]
   (subvec v pos)))

cddr21:09:55

I don't think that applies in this case. n is only ever 3.

sundarj00:09:16

boot.user=> (assoc [1 2 3] 1 42)
[1 42 3]
this also works

tbaldridge23:09:38

@sophiago memoize implies a hashmap lookup on with the key being a seq of the arguments to the function. This adds a fair amount of overhead.

tbaldridge23:09:02

Probably has little to do with cache lines, and more to do with inlining and memory allocations

sophiago23:09:28

Makes sense. I was testing it on a function that performs a heavy amount of insertion. My use case doesn't do a whole lot of lookup and when it does I've found Nathan Marz's Specter library to be very useful.

sophiago23:09:45

I did try inlining some of the small functions on the lookup side, but it didn't make much of a difference and in some cases slowed things down.

sophiago23:09:57

Btw, @tbaldridge this is the library I stole a bunch of your core.async code to use for source transformation. I'm not focusing on that part right now, but am hoping to ask you some questions about it when I do as I definitely don't fully understand how it works.