Yeah - I'm coming to the conclusion that this idle thought didn't really have any value. The discussion was interested though. On 8 Feb 2014 17:30, "Gary Verhaegen" <gary.verhae...@gmail.com> wrote:
> For multiple calls to map, you can always do: > > (->> things > (map #(-> % wrangle pacify)) > (filter effable) > (map #(aggravate % :bees :sharks)) > (reduce mapinate {}) > > but, as others have said, I'm not sure you can meaningfully compress that > if you have to decide between map, filter and reduce. Perhaps implement an > embeddable J to Clojure compiler, either as a macro reading in symbols or > as a function reading in a string? Not sure about the amount of effort > involved, though. > > > On 8 February 2014 15:18, t x <txrev...@gmail.com> wrote: > >> I think the problem is as follows: >> >> map = 3 characters >> filter = 6 characters >> >> Given that we're doing clojure not apl, to specify the function we're >> mapping/filtering on, we have to do either: >> #( ... % ) = 5 characters off the bat >> or provide the name of the function (atleast 1 english word) >> >> Thus, even if we reduced map to M and filter to F, it's very unlikely >> that we'll ever shorten anything by more than 50% (just given the # of >> characters required to specify the function that we are >> mapping/filtering on.) >> >> >> From this, it seems, unless we go the APL route and make the task of >> describing the filtering/mapping function itself very short, there's >> almost no gain in shortening map / filter. >> >> >> This isn't meant to be discouraging -- in fact, I'd love to see a way >> to mix APL + Clojure. :-) Often times, I'm looking at a multiline >> clojure expression and thinking: "this'd be a single line of APL." >> >> On Fri, Feb 7, 2014 at 8:03 PM, Mars0i <marsh...@logical.net> wrote: >> > Since a few of these higher order functions--map, filter, reduce, >> etc.--are >> > so common and useful, I wonder whether there could be sufficient >> benefit to >> > having some abbreviations for them. I know that some of these >> characters >> > are already taken, but just to sketch the idea: >> > >> > (--> things %wrangle %pacify |effable %#(aggravate % :bees :sharks) >> > \(mapinate {}) ) >> > >> > In one sense this reduces the visual complexity of Korny's example. In >> > another sense it increases it. I thought this option was worth >> mentioning, >> > but I don't think I like it. It makes the syntax closer to line noise, >> and >> > if there are too many magical characters, no one will remember what they >> > mean except the people who use them all of the time (like some of the >> > options in Perl regexps). Why not go all the way, and provide an >> alternate >> > APL-style syntax for Clojure? >> > >> > >> > On Friday, February 7, 2014 9:14:27 AM UTC-6, t x wrote: >> >> >> >> I think >> >> >> >> (->> things >> >> (map wrangle) >> >> (map pacify) >> >> (filter effable) >> >> (map #(aggravate % :bees :sharks)) >> >> (reduce mapinate {}) >> >> >> >> >> >> is optimal for the following reason: >> >> >> >> >> >> If you're doing "map" and "map alone", i.e. >> >> >> >> (->> things >> >> (map f1) >> >> (map f2) >> >> (map f3) >> >> (map f4)) >> >> >> >> then you can do: >> >> >> >> (map #(f4 (f3 (f2 (f1 %)))) things) >> >> >> >> >> >> Now, if you're not doing pure maps, i.e. maps + filters >> >> >> >> Then for each function call, from an information theoretic >> >> perspective, you have to, at the very least, specify: >> >> >> >> (*) the function to be called >> >> (*) whether it's a filter or a map >> >> >> >> in this case, >> >> >> >> what you initially have is optimal. >> >> >> >> On Fri, Feb 7, 2014 at 6:33 AM, Korny Sietsma <ko...@sietsma.com> >> wrote: >> >> > I tend to agree, I think. I certainly can't think of a syntax that >> >> > would >> >> > make me happy. It just feels like a bit of a smell that I keep using >> >> > ->> to >> >> > process sequences in similar ways. >> >> > >> >> > The data.zip "xml->" macro is an example of something like what I'm >> >> > thinking >> >> > about - it lets you process sequences of xml data nicely: >> >> > http://clojure.github.io/data.zip/#clojure.data.zip.xml/xml-> >> >> > >> >> > ... but I can't see a way to use something similar for the sort of >> data >> >> > I'm >> >> > processing. I'll let this percolate, and stick to just using lots of >> >> > (map) >> >> > and (filter) instead. >> >> > >> >> > - Korny >> >> > >> >> > >> >> > On 6 February 2014 18:34, Jozef Wagner <jozef....@gmail.com> wrote: >> >> >> >> >> >> I agree with Colin, the cognitive load is greater than benefits of >> such >> >> >> approach. BTW you can use comp to chain consecutive map >> transformation >> >> >> functions. (map (comp pacify wrangle) things) >> >> >> >> >> >> JW >> >> >> >> >> >> >> >> >> On Thu, Feb 6, 2014 at 3:40 PM, Korny Sietsma <ko...@sietsma.com> >> >> >> wrote: >> >> >>> >> >> >>> Hi folks, >> >> >>> >> >> >>> I seem to regularly find myself writing ->> threaded code that >> follows >> >> >>> similar patterns: >> >> >>> >> >> >>> (->> things >> >> >>> (map wrangle) >> >> >>> (map pacify) >> >> >>> (filter effable) >> >> >>> (map #(aggravate % :bees :sharks)) >> >> >>> (reduce mapinate {}) >> >> >>> >> >> >>> i.e. all stages of the code actually operate on a collection rather >> >> >>> than >> >> >>> a single value - usually with a call to "map" at each stage. This >> >> >>> example >> >> >>> is over simplified - often many of the calls to map are inline >> >> >>> functions, >> >> >>> which makes this even more verbose. >> >> >>> >> >> >>> I wonder if there would be value in (yet another) variant on '->' >> that >> >> >>> assumes you are threading a collection and calling 'map' by >> default. >> >> >>> I'm >> >> >>> not sure of the syntax that would work though. Something like: >> >> >>> >> >> >>> ([]-> things >> >> >>> wrangle >> >> >>> pacify >> >> >>> [:filter effable] >> >> >>> (aggravate :bees :sharks) >> >> >>> [:reduce mapinate {}]) >> >> >>> >> >> >>> I'm not sure about the syntax for non-map functions, I'm not even >> sure >> >> >>> if >> >> >>> this is worthwhile. Thoughts? >> >> >>> >> >> >>> - Korny >> >> >>> >> >> >>> -- >> >> >>> Kornelis Sietsma korny at my surname dot com http://korny.info >> >> >>> .fnord { display: none !important; } >> >> >>> >> >> >>> -- >> >> >>> You received this message because you are subscribed to the Google >> >> >>> Groups "Clojure" group. >> >> >>> To post to this group, send email to clo...@googlegroups.com >> >> >>> Note that posts from new members are moderated - please be patient >> >> >>> with >> >> >>> your first post. >> >> >>> To unsubscribe from this group, send email to >> >> >>> clojure+u...@googlegroups.com >> >> >>> For more options, visit this group at >> >> >>> http://groups.google.com/group/clojure?hl=en >> >> >>> --- >> >> >>> You received this message because you are subscribed to the Google >> >> >>> Groups >> >> >>> "Clojure" group. >> >> >>> To unsubscribe from this group and stop receiving emails from it, >> send >> >> >>> an >> >> >>> email to clojure+u...@googlegroups.com. >> >> >>> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >> >> >> >> >> >> -- >> >> >> You received this message because you are subscribed to the Google >> >> >> Groups "Clojure" group. >> >> >> To post to this group, send email to clo...@googlegroups.com >> >> >> Note that posts from new members are moderated - please be patient >> with >> >> >> your first post. >> >> >> To unsubscribe from this group, send email to >> >> >> clojure+u...@googlegroups.com >> >> >> For more options, visit this group at >> >> >> http://groups.google.com/group/clojure?hl=en >> >> >> --- >> >> >> You received this message because you are subscribed to the Google >> >> >> Groups >> >> >> "Clojure" group. >> >> >> To unsubscribe from this group and stop receiving emails from it, >> send >> >> >> an >> >> >> email to clojure+u...@googlegroups.com. >> >> >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > >> >> > >> >> > >> >> > >> >> > -- >> >> > Kornelis Sietsma korny at my surname dot com http://korny.info >> >> > .fnord { display: none !important; } >> >> > >> >> > -- >> >> > You received this message because you are subscribed to the Google >> >> > Groups "Clojure" group. >> >> > To post to this group, send email to clo...@googlegroups.com >> >> > Note that posts from new members are moderated - please be patient >> with >> >> > your >> >> > first post. >> >> > To unsubscribe from this group, send email to >> >> > clojure+u...@googlegroups.com >> >> > For more options, visit this group at >> >> > http://groups.google.com/group/clojure?hl=en >> >> > --- >> >> > You received this message because you are subscribed to the Google >> >> > Groups >> >> > "Clojure" group. >> >> > To unsubscribe from this group and stop receiving emails from it, >> send >> >> > an >> >> > email to clojure+u...@googlegroups.com. >> >> > For more options, visit https://groups.google.com/groups/opt_out. >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "Clojure" group. >> > To post to this group, send email to clojure@googlegroups.com >> > Note that posts from new members are moderated - please be patient with >> your >> > first post. >> > To unsubscribe from this group, send email to >> > clojure+unsubscr...@googlegroups.com >> > For more options, visit this group at >> > http://groups.google.com/group/clojure?hl=en >> > --- >> > You received this message because you are subscribed to the Google >> Groups >> > "Clojure" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> an >> > email to clojure+unsubscr...@googlegroups.com. >> > For more options, visit https://groups.google.com/groups/opt_out. >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.