#clojure logs

2016-05-02

02:16dysfunjustin_smith, asdf12z_: the binding for compojure can be a vector, symbol or map
02:17dysfunit treats them all differently with magic macro shit
02:19amalloywell, it treats the map and symbol the same
02:19amalloyie, it just applies clojure's normal destructuring rules to both
02:19amalloyvectors are the special case; it destructures the :params key instead of the whole map
02:22dysfunyeah, that
03:41jonathanjare there any tools that output coverage data that i could use with codecov.io?
03:44jonathanjcloverage is... weird:
03:44jonathanjCaused by: java.lang.IllegalArgumentException: Can't call nil, form: (nil (nil #{map__14313}) (nil nil nil (nil #{map__14313})) #{map__14313})
03:45jonathanjcompiling:(aleph/http/client_middleware.clj:176:5)
03:47TEttingerthat's a lot of nil there
03:47jonathanjhaha, yeah
03:47clojurebotCool story bro.
03:48TEttingerI don't think I even know what code coverage is
03:48TEttingeris it a test thing?
03:48jonathanjit's basically how many lines of your source your tests exercise
03:48jonathanj100% coverage means every line (and possibly every branch condition) is exercised by your test suite
03:49jonathanjanyway, cloverage doesn't seem to work at all for me, it bails out with this bizarre error
03:49jonathanji was kind of hoping someone else had encountered this
03:50jonathanjhttps://github.com/lshift/cloverage/issues/85
04:00jonathanjis it possible to use a lein plugin from a local repo?
04:17fikgolTEttinger you are right. thanks
04:18fikgolTEttinger: you are right. thanks
04:21TEttingerah glad i could help
04:28tolstoyjonathanj: One way to do it is add leiningen/whatever to your source, then make sure it's on the classpath in .lein-classpath.
04:28tolstoy~/.lein-classpath (I think the name is).
04:28clojurebotexcusez-moi
04:28tolstoyThen you can develop plugins within your existing project.
04:37tolstoyOops, I mean <project>/.lein-classpath.
06:25bikeshedrasdf12z_: haha, I was just wondering this last week while going through the luminus-book
06:59panordoes anyone know whether (set-agent-send-executor!) also increases the pool when futures are used?
07:33Keksikewhat are clojure function parameters in curly braces called and how do they work, for example (defn myFunction [{id :id}] ...
07:34M-martinklepschKeksike (IRC): it's called destructuring http://blog.jayfields.com/2010/07/clojure-destructuring.html
07:34KeksikeM-martinklepsch: thanks
07:35M-martinklepschKeksike (IRC): essentially they allow you to bind certain keys in maps without an extra let
07:35Keksikeah ok
07:36KeksikeM-martinklepsch: is there a way to define two sets of params for a function, one which has a map-parameter and takes the value from it that way, and one which just has the id as a normal parameter for example?
07:36KeksikeI don't remember what thats called when defining many sets of params for a function
07:36bsamorimguys, how do I use a custom-made Java class to a clojure code?
07:36bsamorimvia lein
07:37lumathat's called multiple arity, but you need to have a different amount of parameters for each
07:37M-martinklepschKeksike (IRC): variadic is the term used to describe functions taking a varying number of arguments (varying arities)
07:37lumayou can't define two different implementations for the same amount of parameters
07:37panordoes anyone know whether (set-agent-send-executor!) also increases the pool when futures are used?
07:37Keksikety again M-martinklepsch
07:38M-martinklepschKeksike (IRC): luma__ (IRC) right but he could do `(defn x ([map] ...) ([id data
07:38M-martinklepsch]))`
07:38Keksikeok
07:38M-martinklepschthat might be a bit confusing to others but in theory it's possible
07:39M-martinklepschKeksike (IRC): if you're looking for pattern matching there are a few libraries out there as well
08:46panordoes anyone know whether (set-agent-send-executor!) also increases the pool when futures are used?
09:19bsamorimguys, how can I import a custom-made java class?
09:19bsamorimin clojure
09:19bsamorimall the way from the class's .class file
09:25ridcullyjust make sure it is in the right place of the directory structure (what it claims to be in the package) in your classpath and you should be good to go?
09:28bsamorimridcully: but what would be the "right place"? i mean, suppose that i created my project with lein and put my java Foo class in src/java/Foo.class
09:29bsamorimridcully: how should I import it?
09:31ridcullyif it's in not package, then it's just Foo. also i am not sure, if src/java/*.class get picked up at all?
09:32ridcullydoes it actually turn up in your target-dir?
09:40bsamorimridcully: how do I check that?
09:44ridcullybsamorim: on unix i'd use `find target|grep ...` - ymmv. but my advice here is just "java knowledge applied". i never had the need to deal with single pre compiled java.class files in lein yet
09:44bsamorimridcully: hmmm....is it possible to create a java class via clojure?
09:45bsamorimridcully: it would be a ridiculously simple class, just a List with some extensions
09:45bsamorimridcully: i'd use it mainly for java's mutability
09:49TimMcbsamorim: You can use bytecode generation. :-)
09:50bsamorimTimMc: hmmm...interesting...how would I go about doing that ?
09:50bsamorimTimMc: is there a tutorial somewhere?
09:50TimMcOh, I was kidding, you'd really want gen-class.
09:50ridcullybsamorim: https://github.com/technomancy/leiningen/blob/4a683b85eda2e0662120a12a1f0680e6ebc0c28c/doc/MIXED_PROJECTS.md
09:50TimMcI mean, "want" is a strong word, but for your purposes gen-class is probably the least worst.
09:52bsamorimridcully: many thanks!!!!!
09:52bsamorimi'm checking it out
10:22justin_smithTimMc: why not deftype with some mutable fields?
10:23sdegutisGood morning one and all.
10:26dysfunyou're perky this morning
10:29sdegutisdysfun: Until this day, I never knew perky meant "cheerful and lively."
10:29sdegutisI thought it was more like upbeat or something.
10:29TimMcjustin_smith: Depends on what they need.
10:30panordoes anyone know whether (set-agent-send-executor!) also increases the pool when futures are used?
10:31justin_smithpanor: the pool futures use is auto-expanding, and is used by send-off
10:31justin_smithsend uses a smaller pool
10:31justin_smith(that does not auto-expand)
10:32panorHMm not sure, i read in the docs: Clojure futures are evaluated in a fixed size thread pool that is also used by agents (updated via clojure.core/send).
10:33justin_smithpanor: not fixed size, that is false
10:33justin_smithagents have two pools, you can read the code to verify that
10:35justin_smithpanor: right here, it creates two pools, one fixed, the other cached (expandable), agents use both (send vs. send-off), futures use the expandable one https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Agent.java#L49
10:35justin_smithpanor: you might want to correct the person who told you futures were using a fixed pool
10:36justin_smith(this has been an issue in my own codebase in the past, someone was spawning futures like penny candy and crashed the vm by all the memory used in creating the new thread stacks)
10:36panor2sorry dc'd :(
10:37panor2the pooledExecutor is fixed?
10:37justin_smithpanor2: yes, you can look up Executors.newFixedThreadPool - you saw the source link?
10:37panor2ye i got that
10:38panor2so how does it expand?
10:38panor2a fixed one has at most n threads right?
10:38justin_smiththe newCachedThreadPool creates that
10:38justin_smithit is not fixed
10:38justin_smithread down a couple of lines :)
10:39justin_smithas I mentioned before, two pools
10:40justin_smithpanor2: here's the doc for newCachedThreadPool https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool(java.util.concurrent.ThreadFactory)
10:41panor2ah yes i see
10:41panor2i thought there was two times fixed, oops :D
10:41justin_smithpanor2: this is why the docs mention you should use send-off (edpandable pool) for indefinite operations, and send (fixed pool) for quicker ones
10:41panor2but i'm talking about futures atm :) so if i do (future ...) which pool will it use
10:41panor2the docs say the fixed one
10:41justin_smithpanor2: the expandable one
10:42panor2hmm ok then :)
10:42jonathanjif you want to limit parallelism in an easier way, consider using claypoole
10:43jonathanjit has a (future) implementation that lets you provide a threadpool
10:44justin_smithpanor2: relevant line of the future code (future uses future-call) https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6687
10:44panor2hmm indeed, it seems you are correct :D
10:45justin_smiththat uses soloExecutor, which if you cross reference to the other link, is the one that expands
10:45justin_smithafter an app crashing and burning because you have wrong assumptions about these things a couple of times, one has incentive to really know what's going on :)
10:46panor2true, thanks for the effort :)
10:47justin_smithalso, once you figure out which stuff is in java and which in clj, the clojure codebase is pretty straightforward to navigate to find answers
10:50justin_smithdysfun: OT - what's your take on Haskell From First Principles? As a perpetual Haskell n00b it looks good but I'd be interested in a more informed perspective.
10:51sdegutisYes, Clojure is simple.
10:51sdegutisAnd easy.
10:52dysfunjustin_smith: haven't read it. is that the bitemyapp one?
10:52justin_smithyeah, well him and a co-author (education expert)
10:56dysfunoh
10:57mpenetsoloExec is an (unbounded) cached threadpool if I recall
10:57justin_smithit's kind of cool - Julie learned Haskell as part of the process of them writing the book, which informed the content...
10:57justin_smithmpenet: yup, that's what the source / javadoc I linked to above says as well
10:57mpenetrule of thumb is to avoid using any of the clojure.core stuff relying on threads unless it's for small stuff
10:57dysfuni can't comment on her and i'm going to refrain from commenting on him
10:57justin_smithdysfun: fair enough
10:58mpenetsadly some part of core.async suffer the same pb
10:59mpenet*parts
11:01mpenetex: `thread` and I think the all callbacks for put/take (and all the functions that uses these), so a lot of stuff :(
11:01beakyhelllo
11:01beakyhow do you select the best steaks
11:01beakyoops wrong channel
11:03TimMcsort, then take n
11:05justin_smithTimMc: surely fmap with the juiciness monad - oops, wrong channel
11:06dysfunwell if you're in a shop where you could walk out with bad steak, you're in the wrong shop
11:06TimMcAre you sure we should be sending steaks over channels in the first place?
11:06justin_smithTimMc: yeah, the buffers could lead to freshness issues
11:07sdegutis,(count [""""""""""""""""""""""""])
11:07clojurebot12
11:25justin_smithis there a standard idiom for repl foolishness that I don't want to impose on collaborators, but I do want loaded into user? maybe a small project that injects bindings into the user ns?
11:28TimMcjustin_smith: .lein/profiles.clj, yeah?
11:29justin_smithTimMc: but I want functions for user
11:29justin_smithI guess I'll put those in a plugin
11:30justin_smithor maybe just (when (.exists (io/file "~/user.clj")) (load-file "~/user.clj")) or some such directly in profiles.clj
11:30TimMcIf it's just local stuff, you can write code as nonrepeatable as you like. :-P
11:31justin_smithhaha, right, I just wondered if there was something pre-rolled, seems like it would be a common enough thing
11:31TimMcThe :repl map in projects has some useful stuff, as long as the project itself doesn't define anything.
11:31TimMchttps://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L346
11:32justin_smithTimMc: right, of course, and I can put that in profiles.clj, thanks!
11:33ridcullythere is also -i with a regular repl
11:33Glenjaminjustin_smith: i've added "dev/" to src paths in a :dev profile, then added "dev/user.clj" to gitignore before
11:33justin_smithGlenjamin: yeah, I wanted global for all projects though
11:34GlenjaminI have vinysa set up to inject a bunch of stuff into a namespace called "." - that sort of thing?
11:34justin_smithGlenjamin: yeah, that's another approach - but I'm gonna see how far I can get with ~/user.clj and then consider vinyasa
11:35Glenjaminthis is my user profiles.clj: https://www.refheap.com/118554
11:46justin_smithGlenjamin: cool, that's helpful - now to stop shaving yaks and get some work done
11:47binjuredis there any way to alias an import of a Google Closure class in CLJS? I need to import two classes with the same name from different namespaces.
11:48justin_smithbinjured: you can use require to get google closure libs in cljs, right?
11:49justin_smithand you can use :rename with require
11:49binjuredjustin_smith: yeah, but i can't figure out how to construct via that. compiler always complains "foo.bar.Baz isn't a constructor"
12:30panorhow do you get the internal state of an agent?
12:32dysfunyou mean the current value?
12:32dysfun@
12:33panorah yeah im stupid lol
13:18WorldsEndlessSelmer allows passing of variables into the rendered page (ie for Javascript use). But I'm using Hiccup; anyone know of a similar faculty without encoding them in the DOM?
13:20ridcullyyou mean like [:script {:type "text/javasript"} (str "var something='" (quoteproperly something) "'"] ?
13:25_maddycool I just discovered something called defrecord, and it looks better suited for storing data than a hashmap... have to figure out how it works next
13:29WorldsEndlessridcully: Yeah, I suppose so. Looks lke it needs to be hand-made?
13:30mlovelessand of course there's always defleopard
13:31ridcullyWorldsEndless: i don't know if there is shortcut. i just wanted to understand the question
13:31ridcullyleopard?
13:31mlovelessthe band.. sorry, bad joke
13:32WorldsEndlessridcully: Looks like there is a javascript-tag option, still requiring actual writing of javascript though
13:32ridcullythats def leppard ;)
13:34mlovelesswhoops!
13:42TimMcWorldsEndless, ridcully: It's surprisingly difficult to do that safely.
13:43TimMcMy strong recommendation is to emit <input type="hidden" name="foo" value="json-goes-here"> because otherwise you can run into the most *exciting* security issues.
13:44TimMcLong story short, there's no general way to encode data safely in a <script> block because it's CDATA.
13:53jonathanjcouldn't you emit something like <script id="app-config" type="application/json">...json data...</script> and parse it as JSON? as long as you're not eval()ing the contents, you should be fine?
13:55jonathanjyou'd obviously need some JS code to run after that script tag: window.MyApplication.config = JSON.parse(document.getElementById('app-config')); // or such
13:55jonathanjseems a bit easier to manage (and a lot harder to mess up) than interpolating values into strings intended to be valid javascript code
13:56ben_vulpesanyone have experiences positive or negative to share with the clojure scheduling libraries, or the unadorned java versions thereof?
13:57jonathanjben_vulpes: never used it before but i read about it in a post when the author announced his time library: http://docs.caudate.me/hara/hara-io-scheduler.html
13:58ben_vulpestestability is very important to me
13:58jonathanjhara.io.scheduler separates the what and the when, which i would imagine makes it a lot easier to test
14:01ben_vulpesman this hara dude has gone a wee bit nuts
14:01ben_vulpesi am an impress
14:01TimMcjonathanj: No, that's insecure for the exact same reason a text/javascript block would be.
14:01TimMcI'm going to make a blog post about this sooner or later.
14:01jonathanjalthough in my experience testing time-based things, you want some way to step the clock whenever you want and as much as you want
14:02jonathanji don't see anything like this for hara
14:02jonathanjTimMc: how so?
14:02TimMcjonathanj: I don't have the time to get into it right now, but <script> is CDATA, so </script> ends a script block, always.
14:02TimMcand if that ends up in your data, you're hosed.
14:03jonathanjit does?
14:03jonathanjeven if you wrap it in <![CDATA[...]]>?
14:04jonathanjhow would "</script>" end up there anyway?
14:05jonathanjpresumably when hiccup (or whatever) serializes your markup it escapes all the bad things, so you never end up with a literal <, >, &, etc.
14:05TimMcjonathanj: Give it a try.
14:05TimMcand remember that an attacker can supply ]]></script> if they want to.
14:07TimMcFor the moment, just trust me when I say that the only viable options are: 1) Backslash-escaping forward slashes in the JSON; 2) Base-64-encoding the JSON (which is actually difficult due to character encoding issues); and 3) putting the JSON in an element attribute.
14:07TimMcThe blog post will have more detail + a demo, I just need to reformat it.
14:08jonathanjhang on, an attacker where?
14:09jonathanjif someone happens to inject some JS into your config database on the server, that still won't matter because it'll all be quoted instead of literal when it's rendered
14:09jonathanjif there is some guy injecting code into the client's browser on their local machine you're basically screwed anyway
14:15TimMcSecurity needs to be general.
14:36_maddyis mapv more efficient than map, if I need to go through all the items in any case?
14:37amalloyjonathanj: the default behavior of hiccup (or whatever) is not to escape everything. you have to specifically say what needs to be escaped
14:39will_sm_maddy, map is lazy, so a new collection isn't created so the values are calculated as needed
14:39will_sm_maddy, a case where this may be detrimental is when you need the entire seq multiple times
14:40amalloywhy would that be a problem?
14:40will_smIn the REPL, I did `(def a (map println (range 10)))`, which should be 10 nils
14:41will_smoutputing `a` calls the printlns each time
14:41AimHereDid you really want a list of ten nils?
14:41will_smAimHere, didn't matter
14:41AimHereOtherwise, wouldn't doseq be the more idiomatic
14:42amalloywill_sm: no it doesn't
14:42AimHereOh right, sorry, you're explaining stuff
14:42will_smamolloy, nvm lol
14:44_maddywill_sm: like for example map-reduce, it will go over the whole seq anyway
14:46will_smamalloy, does getting the first element calculate the whole thing? `(first (map println (range 10)))` printed out all of them in the REPL, but is this always the case?
14:47amgarchIn9I think 32 element chunks are hardwired. Try (range 33).
14:48will_smamgarchIn9, yup
14:48AimHereDoesn't (range 33) have 33 elements?
14:49amgarchIn9yes, that's two chunks.
14:49will_smAimHere, yeah, it printed 0-31 inclusive when I took the first
14:53amalloy_maddy: the main disadvantage of using mapv instead of map is that you get the entire collection in memory at once, whereas with (reduce f x (map f xs)) you can produce it only as needed, and throw away old items
14:54amalloyi don't know whether mapv or map is faster there, if the size of the collection is not an issue, but either way it is probably fairly close and not worth worrying about, so i'd use the safer map
14:54amalloyi wonder if mapv would exist, actually, if transducers had been invented first
14:55amalloyprobably not
15:12justin_smithamalloy: agreed
15:13justin_smith_maddy: are you consuming the results, or doing some side effect as you go?
15:21_maddyjustin_smith: consuming
15:23justin_smithaha, yeah. If it was just side effects you could use run!, but consuming you could check out using the map transducer if appropriate, or just use map as amalloy mentions
15:29_maddyok, thanks
16:14binjuredwith CLJS/JS interop, am i missing something or is it normal to have to wrap just about everything in clj->js?
16:15Glenjaminbinjured: you'd generally want to constrain interop to a small area, but then yes - you can't use lists/vectors/maps on JS funcs without converting
16:16binjuredGlenjamin: seems like i can't even pass Closure class instances to other constructors without it.
16:16Glenjaminah, i don't know much about that - I rarely use classes in JS-land
16:18chemounaI wanted to share this list for people who are learning clojure https://github.com/chemouna/ClojureResources (i've collected while learning clojure myself)
16:21chemouna if i'm missing some excellent other resources i would love to find them , please point them out
17:48jrc..
17:48jrc..
17:49jrc.............................................................................................
17:49jrc.0.
17:51jrcsorry
17:51amalloysay hello to your cat for us
17:52justin_smith😼
17:53jrcI will haha
18:06irctcHi there. I am wondering if anyone can tell me what has happened to conj.io?
18:07irctcIs it down temporarily, or has it been perma-deprecated?
18:07justin_smithirctc: I was wondering too, maybe arrdem can enlighten us
18:51ZimaBluewhy is areduce a macro?
19:19jrcI installed vim-fireplace seems to be working, :%Eval etc works, but commands like cqq cqc do nothing, I wasn't instructed to add anything to .vimrc to make these work, has anyone had luck with this vim plugin?
19:23ben_vulpeswhat's literal syntax for a partial'd function?
19:23ben_vulpesi'd like to test that a function returns a particular function
19:23ben_vulpes,(defn bens-funk [] :hi)
19:23clojurebot#'sandbox/bens-funk
19:24ben_vulpes,(println (partial bens-funk))
19:24clojurebot#object[sandbox$bens_funk 0xb8f8de4 sandbox$bens_funk@b8f8de4]\n
19:24ben_vulpes,(println (partial sandbox/bens-funk))
19:24clojurebot#object[sandbox$bens_funk 0xb8f8de4 sandbox$bens_funk@b8f8de4]\n
19:24ben_vulpesalternatively, what'd be the idiomatic approach to test that a particular function got returned from another function?
19:25amalloyben_vulpes: don't test functions for equality
19:25ben_vulpesboo
19:25amalloythe only thing you can do is test their behavior by calling them with interesting arguments
19:25ben_vulpescool nbd
19:53EgyptPharaohHi guys, im new to clojure
20:23sdegutisAha! I hvzae data challeng.e Finally!
20:24sdegutisSo you have data like this.. µany maps, list of them (or seq), and it has: each have a key :age, and you want to find the number of quantity of each.
20:26sdegutis(f [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}]) => 3
20:27sdegutisIt's kind of like, the opposite of distinct.
20:27sdegutisthe intermediate of that (f ...) is {1 3, 2 2, 3 1} because that's the frequencies
20:28sdegutisAg! Frequencies!
20:28sdegutisMap it to :age ahd then (frequndcies) it
20:28sdegutis,(->> [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}] (map :age) (frequencies) (vals) (map dec) (reduce + 0))
20:29sdegutis[SOLVED]
20:29clojurebot3
20:29sdegutisThis was good challeng.e
20:30justin_smith,transduce (map :age) (fn ([s] (count s)) ([s i] (conj s i))) #{} [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}]) ; sdegutis
20:30clojurebot#object[clojure.core$transduce 0x3c23ebbb "clojure.core$transduce@3c23ebbb"]
20:31justin_smithergh
20:31justin_smith,(transduce (map :age) (fn ([s] (count s)) ([s i] (conj s i))) #{} [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}]) ; sdegutis
20:31clojurebot3
20:31sdegutisBAH, FOILED AGAIN BY JUSTIN_MSITH
20:31sdegutisI will never understand transduers jsut.
20:31sdegutisjustin_smith: .
20:31sdegutisHmm let me prettyify that CLojure code. rst.
20:32justin_smiththe key to understanding transduce is to use it to answer toy problems like this one, of course
20:32sdegutisHmm.
20:32sdegutisYour solution confuses the **** out of me.
20:32sdegutisI don't undrstand what the (fnn) is doing or why there' a se.t
20:32justin_smith,(transduce (map :age) (completing conj count) #{} [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}]) ; improveder
20:32clojurebot3
20:33justin_smith(completing conj count) is cool
20:33sdegutisimproveder?
20:33justin_smithsdegutis: it was improved, now it's even improveder
20:33sdegutisearlier today i adjusted my work email signature in an email to an old colleague i used to work with to isnead of "Technical Support" to say "Code Typer In-er"
20:33sdegutiser, *Codes
20:33justin_smithsdegutis: set because I'm just counting how many ages (perhaps that answers the wrong question but is coincidentally right?)
20:34sdegutisAhh yes it's coindidental.
20:34justin_smithoops!
20:34sdegutisIt's number of "repeats".
20:34sdegutisSo, age 1 is in there 3 times, so that's 2 repeats.
20:34justin_smithahh
20:34sdegutisSge 2 is in there twice, so 1 repeat.
20:34sdegutis3 once, 0 repeats.
20:34sdegutis2 + 1 + 0 = 3
20:35sdegutisAlso what the heck is completing? Is CLojure just untyped Haskell now?
20:36TEttinger,(doc completing)
20:36clojurebot"([f] [f cf]); Takes a reducing function f of 2 args and returns a fn suitable for transduce by adding an arity-1 signature that calls cf (default - identity) on the result argument."
20:36TEttingeroh nice
20:36justin_smith,(transduce (map :age) (completing #(update % %2 (fnil inc -1)) (comp (partial apply +) vals)) {} [{:age 1} {:age 1} {:age 1} {:age 2} {:age 2} {:age 3}])
20:36clojurebot3
20:36sdegutisYeah I sitll don't understand completing after reading htat.
20:36sdegutisjustin_smith: fnil inc -1? Haha why not dec?
20:36sdegutishmm
20:36justin_smithsdegutis: you know that pattern of (f (reduce g coll))
20:36sdegutisMy brain is mal functionling tonight.
20:37sdegutisjustin_smith: No,
20:37sdegutisjustin_smith: you say earlier "perpetual Hasskell newb" to refer to yosuelf as, yet here we see that you think in arity and function calls!
20:37justin_smithsdegutis: you never do (f (reduce g coll))? that is for when you want to accumulate one kind of data, and then process it before returning it
20:37sdegutisI seem to think in context-dependent transformations
20:37justin_smithsdegutis: haskell does not have arity
20:38sdegutisjustin_smith: not that I can recall
20:38justin_smithwell, mostly not
20:38sdegutisjustin_smith: (it pretends to"
20:38justin_smithheh
20:38sdegutisHmm. Only 17 matchs for "reduce" in our code.
20:38sdegutisMost of them are (reduce + 0) in an ->>
20:38sdegutis(at the end)
20:38justin_smithbecause you don't like (apply +) ?
20:39sdegutisCorrect. I hate apply.
20:39sdegutisMost of my apply is apply str or apply max 0
20:39amalloy"haskell does not have arity". a strange way to put it, but i guess not crazy
20:40justin_smithamalloy: maybe I meant "arity is not relevant to haskell in quite the way we are talking about here"
20:40sdegutisamalloy: justin_smith: you could almost say it has terminal and non-terminal transformations
20:40justin_smithbecause of course it does have arity
20:40sdegutisit almost has like, a function can take 0 args, like foo = "bar", now foo refers to "bar", or it takes 1 arg and returns a value, or it takes 1 arg and returns a function
20:41sdegutisso weird
20:41sdegutishey wait a minute
20:41amalloyi mean, the way transducers use arity is pretty gross imo. it's a way to smuggle two totally distinct functions together as one "function" with two arities
20:41sdegutisyou tricked me into thinking about haskell
20:41jeayeamalloy: Yup
20:42justin_smithwell, the single arg function should take the same kind of thing as the first arg of the two arg function
20:42justin_smithso there's at least some relationship there
20:43sdegutisCrap. Out data ia ugly
20:43sdegutiscrap
20:43sdegutisjustin_smith: I will study your final exapl thanks
20:44sdegutisThis i s oncufsong!
20:46sdegutisjustin_smith: you will become world famous if you write a tutorial on transducers
20:47sdegutisNobody understands them at all and there are no tutorials on them using simple data like this example.
20:47sdegutisholy crap that was remarkably typo roof
20:47justin_smithsdegutis: hmm
20:47sdegutisjustin_smith: and It's very difficult to dissest your code
20:48justin_smithdissect?
20:51Lewix (cond-> {:first first :last last}
20:52Lewixwhat does cond-> do
20:52amalloyhave you tried (doc cond->)
20:54justin_smithsdegutis: for starters, #(update % %2 (fnil inc -1)) is your frequencies but 0 indexed instead of 1 indexed to avoid the map dec
20:54sdegutisjustin_smith: correct, dissoect
20:54sdegutisjustin_smith: so it's an /alternative/ to map dec, rather than "avoiding" it
20:55sdegutisjustin_smith: i feel like map dec would make more sense in the context semantically, and should work fine with transducers
20:55justin_smithsdegutis: what I mean, is it does the same amount of work that frequencies does, and avoids the extra work of map dec
20:55sdegutishello eah another typo-less sentence!
20:55sdegutisjustin_smith: but at the risk of more confusion for the sake of efficiency?
20:55justin_smithbut sure, it could be a pointless optimization
20:56justin_smithsdegutis: why does everyone find fnil so weird? I think it's awesome and should be used a lot.
20:56sdegutisjustin_smith: i like fnil sure, but update % %2 confuses my face off
20:56sdegutisextra level of indirection that makes my understanding more didfficult
20:56justin_smithOK
21:00sdegutisHmm. This is hard problem.
21:01sdegutisOur database appears unhelpfully structured.
21:02sdegutis,::find
21:02sdegutisHaha.
21:02clojurebot:sandbox/find
23:48sdegutisWow.
23:48sdegutisI just realized, you can reduce with max instead of apply!
23:48sdegutis,(->> [1 3 2] (reduce max))
23:48sdegutisheck yeah!
23:48clojurebot3