Good point Raul/Ari(RE). allsubsets is a true “brute force” set generation, but as and as2 target the consecutive runs as per Quora.
> On 29 Oct 2019, at 6:46 am, Raul Miller <rauldmil...@gmail.com> wrote: > > Then again, since the quora problem asked for squares of consecutive > integers, your choosing the smaller set of values was the right > choice. > > The current issue seems to be about naming. > > "All sets" suggests the larger intermediate value. > > "All prefixes of suffixes" is valid, but maybe too specific? > > I would be tempted to go with "all consecutive [sub]sequences". > > Thanks, > > -- > Raul > > > > On Mon, Oct 28, 2019 at 3:38 PM R.E. Boss <r.e.b...@outlook.com> wrote: >> >> Notice the difference: >> >> #L:_1(allsubsets;as;<@as2)'abcdef' >> +--+--+--+ >> |64|21|21| >> +--+--+--+ >> >> (as) and (as2) give only the (2!n+1) consecutive subsets, not all (2^n) >> subsets. >> >> >> R.E. Boss >> >> >>> -----Oorspronkelijk bericht----- >>> Van: Programming <programming-boun...@forums.jsoftware.com> >>> Namens 'Rob Hodgkinson' via Programming >>> Verzonden: zondag 27 oktober 2019 22:26 >>> Aan: jonghough via Programming <programm...@jsoftware.com> >>> Onderwerp: Re: [Jprogramming] Quora problem >>> >>> Using RE’s and Henry’s suggestions, a slight generalisation to your #3 … >>> >>> as2=: ;(#\ <@<"1@([\) ]) ‘abcdef' >>> >>> Rob >>> >>>> On 26 Oct 2019, at 7:36 am, Skip Cave <s...@caveconsulting.com> wrote: >>>> >>>> Roger, >>>> >>>> Nice! It seems there are many different approaches: >>>> >>>> allsubsets=: #:@i.@(2&^)@# #"_1 _ ] >>>> as=.3 :';<@(<\.)\y' >>>> ;(>:i.5) (|.@[ <@{."0 1 <\) 'abcde' >>>> >>>> Even if the result is to be integers, It seems it is easier to start >>>> with literals and then convert to integers later, if at all. >>>> >>>> My next challenge is to generate all *permutations* of all subsets. >>>> >>>> Skip >>>> >>>> >>>> >>>> Skip Cave >>>> Cave Consulting LLC >>>> >>>> >>>> On Thu, Oct 24, 2019 at 1:54 PM Roger Hui <rogerhui.can...@gmail.com> >>> wrote: >>>> >>>>> allsubsets=: #:@i.@(2&^)@# #"_1 _ ] >>>>> allsubsets 'abcd' >>>>> >>>>> d >>>>> c >>>>> cd >>>>> b >>>>> bd >>>>> bc >>>>> bcd >>>>> a >>>>> ad >>>>> ac >>>>> acd >>>>> ab >>>>> abd >>>>> abc >>>>> abcd >>>>> allsubsets ;:'animal vegetable mineral' >>>>> ┌─────────┬─────────┬───────┐ >>>>> │ │ │ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │mineral │ │ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │vegetable│ │ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │vegetable│mineral │ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │animal │ │ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │animal │mineral │ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │animal │vegetable│ │ >>>>> ├─────────┼─────────┼───────┤ >>>>> │animal │vegetable│mineral│ >>>>> └─────────┴─────────┴───────┘ >>>>> >>>>> >>>>> >>>>> On Thu, Oct 24, 2019 at 11:30 AM Skip Cave <s...@caveconsulting.com> >>>>> wrote: >>>>> >>>>>> I find R. E. Boss' function quite useful in many instances. I call >>>>>> it >>>>> "all >>>>>> sets". Is this a standard idiom in J? Is there a more efficient >>>>>> construction that does this? Is there a primitive that does this? >>>>>> >>>>>> as=.3 :';<@(<\.)\y' NB. All Sets >>>>>> >>>>>> as i.5 >>>>>> >>>>>> │0│0 1│1│0 1 2│1 2│2│0 1 2 3│1 2 3│2 3│3│0 1 2 3 4│1 2 3 4│2 3 4│3 >>>>>> 4│4│ >>>>>> >>>>>> >>>>>> Skip >>>>>> >>>>>> >>>>>> >>>>>> On Thu, Oct 24, 2019 at 12:30 PM R.E. Boss <r.e.b...@outlook.com> >>> wrote: >>>>>> >>>>>>> Obviously the squares >2018 don't play any role whatsoever, so you >>>>>>> can restrict yourself to %:2018 >>>>>>> >>>>>>>> a#~2018=>+/ each a=.;<@(<\.)\2^~i.>.%:2018 >>>>>>> 49 64 81 100 121 144 169 196 225 256 289 324 >>>>>>> >>>>>>> R.E. Boss >>>>>>> >>>>>>> >>>>>>>> -----Oorspronkelijk bericht----- >>>>>>>> Van: Programming <programming-boun...@forums.jsoftware.com> >>>>>>>> Namens Skip Cave >>>>>>>> Verzonden: donderdag 24 oktober 2019 19:12 >>>>>>>> Aan: programm...@jsoftware.com >>>>>>>> Onderwerp: Re: [Jprogramming] Quora problem >>>>>>>> >>>>>>>> To me it seems that R. E. Boss provided the simplest approach. >>>>>>>> Don't know about efficiency, but the results appear instantly: >>>>>>>> >>>>>>>>> a#~2018=>+/ each a=.;<@(<\.)\2^~i.100 >>>>>>>> >>>>>>>> 49 64 81 100 121 144 169 196 225 256 289 324 >>>>>>>> >>>>>>>> Skip >>>>>>>> >>>>> --------------------------------------------------------------------- >>>>> - >>>>>>>> For information about J forums see >>>>> http://www.jsoftware.com/forums.htm >>>>>>> ------------------------------------------------------------------- >>>>>>> --- For information about J forums see >>>>>>> http://www.jsoftware.com/forums.htm >>>>>>> >>>>>> -------------------------------------------------------------------- >>>>>> -- For information about J forums see >>>>>> http://www.jsoftware.com/forums.htm >>>>>> >>>>> --------------------------------------------------------------------- >>>>> - For information about J forums see >>>>> http://www.jsoftware.com/forums.htm >>>>> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see >>> http://www.jsoftware.com/forums.htm >>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm