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