Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #6655
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: generating permutations |
| Date | 2016-05-24 12:56 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <ni1fah$3bi$1@dont-email.me> (permalink) |
| References | <86298170-5592-40fa-a275-7e90d472e2ce@googlegroups.com> <6d8de1c0-c835-4a67-b115-25249177e717@googlegroups.com> <ad4f7ce6-2699-42e3-815e-3ccce7c0200c@googlegroups.com> <nhuv7g$s2i$1@dont-email.me> <d8c7fea2-8b8d-4cf4-883b-c02b47c49081@googlegroups.com> |
On 24/05/2016 05:36, luser droog wrote: > On Monday, May 23, 2016 at 8:09:33 AM UTC-5, Bart wrote: >> For example, take this is 2D array A of 3 rows of 5 columns: >> >> ((3 1 4 1 5) >> (9 2 6 5 3) >> (5 8 9 7 9) >> So adding ;2 4 might yield: >> >> ((1 1) >> (8 7) >> (2 8)) >> >> Nice and compact, perhaps the shape of your RHS on an assignment. But >> take a look at the original with just these highlighted: >> >> ((- 1 - 1 -) >> (- - - - -) >> (- 8 - 7 -) >> (- 2 - 8 -)) >> >> You selected 4 sub-arrays of the original: 2 individual elements, and 2 >> column vectors of two elements each, arranged as a 2x2 array of >> sub-arrays; this is what I meant before. You're defining a rectangular >> matrix of sub-arrays using this slicing scheme. > Yes, all correct. And other APLs already have this power AFAIUI. I tried adding this feature on one of my languages, using functions to do the slicing rather than changing the language. It was surprisingly difficult! As I chose to implement it (bear in mind I only spent an hour or so): * It only handles rvalues (lvalues require language changes) * The selection set for each dimension doesn't allow duplicates (they are ignored) and the indices are always sorted * For a 2D array, the row-selector highlights a set of rows, and the column-selector highlights a set of columns. Where those intersect, those are the elements that are selected. * Selected elements are copied (using a shallow copy in this case) to form a new 2D array consisting of the chosen elements in a compact non-sparse format. * It needs a dedicated routine for each number of dimensions. (The best I can do with lvalues, without changing anything deep, is to instead return a compact selection array consisting of /pointers/ to each element, but then code must explicitly dereference those pointers.) -- Bartc
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
generating permutations luser droog <mijoryx@yahoo.com> - 2016-05-22 02:46 -0700
Re: generating permutations bart4858@gmail.com - 2016-05-22 05:36 -0700
Re: generating permutations luser droog <mijoryx@yahoo.com> - 2016-05-22 14:40 -0700
Re: generating permutations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-05-22 22:58 +0100
Re: generating permutations BartC <bc@freeuk.com> - 2016-05-23 14:09 +0100
Re: generating permutations luser droog <mijoryx@yahoo.com> - 2016-05-23 21:36 -0700
Re: generating permutations BartC <bc@freeuk.com> - 2016-05-24 12:56 +0100
Re: generating permutations luser droog <mijoryx@yahoo.com> - 2016-05-25 19:03 -0700
Re: generating permutations BartC <bc@freeuk.com> - 2016-05-26 13:08 +0100
Re: generating permutations luser droog <mijoryx@yahoo.com> - 2016-05-26 08:35 -0700
csiph-web