Fork me on GitHub
#clojure
<
2018-02-27
>
yogidevbear00:02:08

Sorry, just got a blue screen of death. Waiting for laptop to reboot

hiredman00:02:36

(for [i (range -1 2) ii (range -1 2)] [i ii])

hiredman00:02:10

but you might want to switch data structures

hiredman00:02:33

basically you have a datastructure indexed by coordinates

hiredman00:02:40

but you want two indexes

hiredman00:02:45

coordinates and values

yogidevbear00:02:49

I don't have an issue with the update-in stuff, etc. It's more to do with the recursion. In my example above, I start with [0 0], this then finds [1 0] and [0 1] which are both 0 values. [1 0] would have no more options to pursue as no adjacent values of 0 are remaining. [0 1] however would find [0 2] repeating the process, which would then find [1 2], etc... [1 3][2 2] and then stop the recursion

yogidevbear00:02:19

I don't know how far this recursion will go though until I work through it

Charlot00:02:18

Hello all. I am working on nREPL middleware, and wonder who I might ask questions of, particularly regarding set-descriptor!

seancorfield00:02:09

@shawx538 Not sure how active it is but there's an #nrepl channel if no one here can answer...

Charlot00:02:44

yeah, asked there too, and so far there has been no response

maleghast00:02:11

@shawx538 - There is a guy you can often find in the #clojure-uk channel during U.K. - friendly hours called @dominicm who may be able to help you, but he is 99.9% sure to be sleeping right now...

Charlot00:02:52

@maleghast thank you. I will look them up.

hiredman00:02:28

I've never actually used the set-descriptor! function, but I've used alter-meta! to directly attach descriptors to vars

maleghast00:02:52

(this is how I expect he is likely to be able to help you - nrepl is a black box still to me and I’ve read the article, once)

noisesmith00:02:15

@pesterhazy that's a known issue with postwalk - you get mape-entry objects if you prewalk though

noisesmith00:02:45

@pesterhazy also if you look at the source of postwalk, you'll see how easy it would be to make your own version that preserves the map-entry type

Charlot00:02:21

@maleghast Yeah, this is already helpful. Though perchance this would be better served in #nrepl . Would you mind if I shared your messages to it?

maleghast00:02:11

Not at all :-) Share away

pesterhazy01:02:52

@noisesmith good point. Looks like there's an open JIRA for this: https://dev.clojure.org/jira/browse/CLJ-2031

pesterhazy01:02:38

I guess that's the kind of thing that people "fix" by copy-and-pasting a modified version of the function into their code

pesterhazy01:02:24

There could be a lib that provides a unofficial.clojure.core namespace with "fixed" versions of fns in clojure.core (clojure.walk etc.)

noisesmith01:02:37

I double checked - you'd have to replace walk and postwalk both, I misremembered - but even walk is pretty small

noisesmith01:02:32

@pesterhazy my best guess is it would have been changed by now except it would possibly break code that checked for vector(?)

pesterhazy01:02:08

the ticket indicates that the patch hasn't been reviewed by Rich

pesterhazy01:02:19

@noisesmith I've added a note to http://clojuredocs.org http://clojuredocs.org/clojure.walk/postwalk. Maybe this will help the next person who runs into this

noisesmith01:02:14

that was a good idea

mfikes04:02:20

Hah, ClojureScript 1.10 is now finally caught up with the postwalk / map entry behavior (at least it will be consistent with Clojure)

noisesmith04:02:00

@mfikes is this because of the change in the vector? predicate on map-entries in cljs?

qqq13:02:55

pprint :: clojure data -> vector of strings (which are printed) is there a similar function, but which does:: clojure data -> svg ? [perferably with color]

mfikes13:02:00

@qqq Walmart Labs's datascope seemed to be very close to what you are describing https://github.com/walmartlabs/datascope

borkdude15:02:11

Why does #?(:clj ...) not multiple forms between the parens?

borkdude15:02:27

like #?(:clj (defn foo []) (defn bar []))

ghadi15:02:10

there's a splicing form @borkdude, but you can't use it at the top-level

ghadi15:02:38

[1 2 #?@(:clj [3 4] :cljs [5 6])]
> This form would read as [1 2 3 4] on Clojure, [1 2 5 6] on ClojureScript, and [1 2] on any other platform. Splicing is not allowed at the top level.

Joe Lane16:02:49

Is there currently any existing tool to topologically sort clojure functions in a given namespace by function dependency? An underlying assumption here is that these functions are not in a file, just defined in a namespace. e.g.

(defn a []
  (b))

(defn b []
  (c))

(defn c []
  (println "42"))
becomes
(defn c []
  (println "42"))

(defn b []
  (c))

(defn a []
  (b))

Alex Miller (Clojure team)16:02:37

there are some function diagramming tools that must effectively do so (although I don’t have a name or link at hand)

Joe Lane16:02:22

Thanks @alexmiller, I was going to go pilfer one of those libs if there wasn’t an obvious library or technique I was missing.

Joe Lane16:02:24

Never change alex haha

emccue17:02:25

How would I use gen-class to make a POJO? I am trying to use getForObject from springframeworks RestTemplate class

rauh17:02:10

@alexmiller Should probably use mkdir -p in the TDEPS install file. I'm getting a bunch of "cannot create directory" when using --prefix / -p

Alex Miller (Clojure team)17:02:02

yeah, I’ve already fixed at least one (for man files)

rauh17:02:19

Oh ok! 🙂

fingertoe20:02:00

Anyone else known to use the JT400 library to use Clojure on the AS400/System i IBM servers? I’ve been having fun with it, and am considering building some libraries.

lwhorton23:02:20

is there an idiomatic way to reduce while tracking a sequence index? seems like loop/recur is probably the best option, but I also considered destructing and seeding a reduce with something like [(list) 0] as a seed and [[acc i] val] as the aggregator’s signature. another thing to consider is that index-based operations will be inherently un-parallelizable, right? (unless the reducers lib has some super-magic functions for handling that?)

bfabry23:02:10

(reduce ... (map-indexed vector coll))

pesterhazy23:02:50

I always thought an indexed function would be helpful, because (map-indexed vector coll) isn't very discoverable

bfabry23:02:06

you've got a point

dpsutton23:02:24

In an immutable language with good data literals and lazy mapping it's pretty easy to adjoin indices though

tanzoniteblack23:02:28

I generally just do (map (fn [v index] ...) my-coll (range))? and then reduce with that if needed

tanzoniteblack23:02:33

but that's a different pattern, and I imagine map-indexed is more efficient

dpsutton23:02:10

I like the manual way because I always forget the order of arguments on the map indexed certain

sundarj23:02:36

it's like an ordered list 😛 0. x0, 1. x1, 2. x2 ...

dpsutton23:02:53

maybe that will help. i don't use it enough to remember though

sundarj23:02:05

haha fair enough :~)

qqq02:02:24

I forget the order all the time too, so I just run: (keep-indexed vector [:a :stuck_out_tongue: :c]) in the repl

bfabry23:02:57

looks like map-indexed makes an effort to behave optimally with chunked seqs is about the only difference

lwhorton23:02:52

thanks all, always so much to learn 🙂