This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-09-28
Channels
- # admin-announcements (1)
- # announcements (1)
- # beginners (17)
- # boot (29)
- # cider (8)
- # clojure (87)
- # clojure-czech (2)
- # clojure-nl (2)
- # clojure-russia (108)
- # clojurebridge (9)
- # clojurescript (34)
- # cursive (5)
- # datascript (15)
- # devcards (14)
- # editors (6)
- # hoplon (121)
- # jobs (7)
- # ldnclj (22)
- # onyx (2)
- # re-frame (31)
- # reagent (43)
- # testing (2)
Can anyone think of a cleaner way of doing:
(swap! a-map #(assoc %1 :a (inc (get :a %1 0))))
My issue is that the atom gets reset to {}
occasionally, so it's blowing up on nulls.@lfn3: what are you trying to achieve here?
It's just counting up stuff passing through a channel, and the counter gets reset when it sees a certain message.
@lfn3: this is a little clearer
(swap! a-map
(fn [m]
(->> (get m :a 0)
(inc)
(assoc m :a))))
You could also look at using find
instead, though I’m not sure if it would be any cleaner
(update {:a 3} :a (fnil inc 1))
, this is better
aka (swap! a-map update :a (fnil inc 1))
Thanks @danielcompton
Ok. Yeah the only thing I can think of off the top of my head is (with-redefs)
but I'm sure you already know about that.
Right so the macro is defining some stuff for you, and you want to capture the things it's defined?
Or some of the other (ns-
things, there's quite a few of them, depending on what exactly the macro defines.
You could write something that wrapped the macro in question and emitted the new defs in a map.
Does anyone know of a classloader that I could use to load classes from jar files that isn’t a URLClassLoader?
Aw man namespace hacking is my favourite. It reminds me of dirty reflection hacks from when I wrote C#
@cfleming: there was someone on the mailing list a few months back who was trying to do some stuff with custom ClassLoaders
@danielcompton: Thanks, in the end I found what I needed in the IntelliJ codebase
Legend tells there’s a lisp interpreter hidden deep in the IntelliJ codebase
@danielcompton: According to Greenspun, there must be.
@borkdude: Within this video for sure https://m.reddit.com/r/programming/comments/3bnt8m/rich_hickey_javaone_presentation_clojure_made/ but I didn't find them otherwise
I need to parse a tab-separated columns file, which approach should I have? I thought about using with-open
and map #(clojure.string/split % #"\t")
over the line-seq
. Anyone got a better solution?
@profil: maybe look in: http://clojure.github.io/data.csv/
@profil: for really simple files (where you control the source of the data), what you wrote looks great. For external data, I use either data.csv, or clojure-csv, the latter is more tolerant of real-world files.
Yeah the file is really simple, 3 columns consisting of floats, so I am using clojure.edn/read-string
to parse the numbers
If the data comes from somewhere you don't control, I learned that there is no such thing as "really simple". The world continues to surprise me.
@borkdude: in general, Rich does not release his slides as he prefers them to be viewed in context of the talk
@jeremyraines: I have one that isn’t quite complete
More than willing to share. I’ve got 1-4 dimensions working but haven’t quite gotten around to getting the definable seed thing working
oh cool
I might have gotten it working . . . but it looks too regular and I can't tell if it's because I have too few pseudorandom vectors, or because I did something wrong
I just used short lookup table for gradient vectors, without using the seeds, because I didn't really understand the bit twiddling that all the implementations I saw were doing to generate the gradients on the fly
but yeah, would love to see it
here is mine so far, excuse the repitition and dog-slowness of the canvas parts, I was learning that as I went
very cool, thanks! This will help me understand it better. I don't know what the octaves are at all yet
just realized the image generator thing isn’t using it there, but can drop that in as appropriate to see it. The octaves basically tweek some parameters and do the noise iteratively to sort of improve on the initial thing
First round gives you peaks/valleys, next round gives you bumps, next one gives you boulders so to speak (if it is elevation)
octaves is like number of iterations IIRC, persistence (which I misspelled 😕 ) is like how much each next one affects it (each one is “weaker”)
another basic thing I don't quite understand is: why 256 seeds? and then also why does the permutation table need to be 512, i.e. what's the nature of and purpose of "allow[ing] for indexing to wrap-around"
yeah. So basically, that table is a hard-coded lookup table. There is a function that generates those and its super hard to find online what it is. Always see the table everywhere which makes me sad, especially because we could use memoization
(and its a table in Perlin’s paper). Anyway, the idea is that if you don’t start at the beginning and offset it some amount, you’ll get a different result (I don’t provide a way to do this in my code yet)
and the 512 thing is prevent needing to use modulus to wrap the index around to beginning when it goes past 255
oh, I see, thanks
but this only gives you a seed value for the 0-255 range. I’ve been trying to figure out how people do E.g. minecraft, with a long seed value
and that table is just for looking up the pseudorandom gradients, right?
(I did this ~1 month ago, and I read a lot until I understood 50% of the math but didn’t get much deeper)
hi, looking for help on this threaded-form.. why wouldn't this work? https://www.refheap.com/110038
This really is to be an if-stmt inside a -> call and want to bind the var to the if.else calls (not the predicate) so need to 'move' where the var gets bound
err... @ytl https://gist.github.com/ship561/aad34d6013cd1d50edc5 this works for me