Fork me on GitHub
#clojure
<
2016-07-16
>
seancorfield00:07:43

^ @bcbradley — does that help?

bcbradley00:07:57

Yes sort of, but I'd like one point of clarification

bcbradley00:07:29

Eductions can be built from other eductions right?

bcbradley00:07:48

the same way transducers can be built from other transducers?

bcbradley00:07:33

I'm thinking that since eduction takes a collection, and since eduction implements collection...

seancorfield00:07:53

eduction produces something "collection-like"

seancorfield00:07:08

it is iterable

seancorfield00:07:33

It’s like a repeatable capsule of a set of transducers and a collection to apply them to

bcbradley00:07:46

my use case is using eduction as a way to represent game state as a collection of entities, as a function of the last game state, and I want to be able to build up the stack of transformations by passing around a composable bundle of transformations

bcbradley00:07:10

i looked at eduction and thought that it looked like it self composes, captures the idea of applying a stack of transformations to a collection...

bcbradley00:07:13

seemed like a good fit

seancorfield00:07:43

Transducers already compose tho'...

bcbradley00:07:57

they do, which is why I'm feeling a little confused

bcbradley00:07:19

i know transducers certainly compose and you can pass them around if you'd like

bcbradley00:07:38

eduction bundles that together with the collection data

bcbradley00:07:50

but that feels an awful lot like complecting functionality with data to me

seancorfield00:07:56

If you have a composition of transducers, you can apply it to any collection and run it. With eduction, that starting collection is baked in.

bcbradley00:07:58

which is the pitfal of object oriented programming

bcbradley00:07:45

so what you are saying is that eduction is a partial on transduce?

bcbradley00:07:41

i'm going to make a claim and I want you to tell me whether or not it is right

bcbradley00:07:30

i should only use educe when i want someone to be able to transform a collection, but I don't want them to be able to choose which collection to transform and I don't want to pass them the collection, or necessarily tell them what the original collection even is

bcbradley00:07:50

aka educe only has utility beyond transduce for the purpose of information hiding

seancorfield00:07:19

And you want them to be able to re-run the transformations each time they realize the result (reduce / iterate over it).

bcbradley00:07:58

so essentially its not really a collection-like thing at all, its just a view, er... more like a view through a transforming/ distorting "lens" of another collection somewhere off in the distance, and every time you want to view that thing in the distance you have to recallibrate your telescope and pay the computation cost

bcbradley00:07:36

it looks collection-like because the thing you are viewing is collection-like

bcbradley00:07:04

well thanks for your help with understanding it sean... I know i can be a bit stubborn with trying to interpret things in my own terms.

dpsutton01:07:40

anybody have any experience querying active directory from clojure?

dpsutton01:07:04

i've got to query AD for users and spit out an xml file for populating users and just wondering if anyone had messed with AD through clojure before

dpsutton01:07:31

i don't need to authenticate users, just query and collect results

akiva01:07:49

I haven’t but I’d sniff around for a Java library you could import. I’d be surprised if such a beast wasn’t lurking out there somewhere.

dpsutton01:07:27

yeah figured java world had to have something. wondering if someone had made it in clojure as well

akiva01:07:35

Nothing in Clojars...

Alex Miller (Clojure team)01:07:45

I think you can use ldap to query ad

Alex Miller (Clojure team)01:07:07

At least that's where I'd start looking

akiva01:07:33

Ah, good call, Mr. Miller. @dpsutton, I’d start here: https://clojars.org/search?q=ldap

dpsutton01:07:32

thanks yall

Alex Miller (Clojure team)01:07:43

@bcbradley an eduction is a 1-time, non-caching, suspended transformation

Alex Miller (Clojure team)01:07:09

Best suited to doing a single traversal of an external input source

magnus11:07:31

I am totally stumped. I’m doing some interop with a Java library. The library requires me to define a Java class that extends a certain base class and add some arbitrary methods to it (not defined in the base class). I can’t seem to use ‘proxy’ to do this.

magnus11:07:51

(.hello (proxy [LibraryBaseClass] [] (hello [] (println "Hello")))) An example I’m trying.

magnus11:07:55

this fails

Alex Miller (Clojure team)12:07:33

Requires gen-class I think

Alex Miller (Clojure team)12:07:11

Or just do it in Java (often simpler if it's just a thin shim)

magnus13:07:20

will check both solns out, thank you

paulspencerwilliams14:07:16

Hey all, has anyone had to work with java.util.Collections$UnmodifiableRandomAccessList before? I’m having a little trouble getting one into Clojure data structures.

gfredericks14:07:35

paulspencerwilliams: you can't just pass it to seq?

paulspencerwilliams14:07:48

@gfredericks: you’d have thought but seq? evaluates to false.

akiva14:07:37

Which error is it giving you?

paulspencerwilliams14:07:06

er, saying that...

paulspencerwilliams14:07:12

(println (seq (.asMaps fill-ups)))
outputs
(#object[java.util.Collections$UnmodifiableMap 0x5a917723 {date=2016-06-13, quantity=37, cost=0, mileage=24}] #object[java.util.Collections$UnmodifiableMap 0x7e4579c7 {date=2016-06-17, quantity=33.61, cost=37.95, mileage=426}] #object[java.util.Collections$UnmodifiableMap 0x796f632b {date=2016-06-20, quantity=22.12, cost=24.97, mileage=683}] #object[java.util.Collections$UnmodifiableMap 0x5d94a2dc {date=2016-06-24, quantity=36.69, cost=41.42, mileage=1134}] #object[java.util.Collections$UnmodifiableMap 0xcedee22 {date=2016-06-30, quantity=36.95, cost=40.61, mileage=1577}] #object[java.util.Collections$UnmodifiableMap 0x59b32539 {date=2016-07-06, quantity=39.71, cost=44.83, mileage=2063}] #object[java.util.Collections$UnmodifiableMap 0x5b47731f {date=2016-07-09, quantity=25.58, cost=28.88, mileage=2386}] #object[java.util.Collections$UnmodifiableMap 0x233db8e9 {date=2016-07-16, quantity=32.72, cost=36.94, mileage=2783}])

gfredericks14:07:00

paulspencerwilliams: seq? is different from seq

paulspencerwilliams14:07:25

as seq? is returned false, I assumed that meant that the collection wouldn’t comply with seq

gfredericks14:07:50

seq is for converting something to a seq

gfredericks14:07:01

seqable? is a new 1.9 function that expresses that idea

akiva14:07:02

Ah, looks like it’s choking on converting each entry in the collection into individual maps. {date=2016-07-16…} and so forth.

gfredericks14:07:28

(into {} some-unmodifiable-map) should work for that part

paulspencerwilliams14:07:47

that’s the next challenge. okay. Will try now.

gfredericks14:07:51

i.e., try (->> fill-ups .asMaps (map #(into {} %)))

paulspencerwilliams14:07:53

Yes, that works a treat. Thank you both. I’d been trying to map straight over

(.asMaps fill-ups)
and had been getting a
java.lang.ClassCastException: java.util.Collections$UnmodifiableMap cannot be cast to clojure.lang.Associative
which led me to believe a slightly more complicated interop issue.

akiva14:07:32

Exxxcellent.

paulspencerwilliams14:07:18

and previous attempts to (map into {}) had also failed, but this incantation works well!

gfredericks17:07:39

am I crazy or does the regex feature of clojure.test/is not work at all?

gfredericks17:07:07

that second assertion doesn't fail

gfredericks17:07:39

oh nevermind you have to use thrown-with-message? for that