Hmm..
In the current J902 release, if your 50 element list was unboxed in L
and your pairs were boxes in P, you could do
;C.&.(a:`>) ::]/|. L;P
or
L ] F..(C. ::]) P
(Caution: lately I've been getting spelling errors, copying and
pasting from email into a J session -- this is because when I've got
more than one adjacent space, some of them come through as 192 160{a.
instead of as 32 {a.)
In earlier versions of J, I guess I'd do that this way:
;C.&.> ::]/|. L;<"0 P
I hope this helps,
--
Raul
On Sat, May 30, 2020 at 10:12 AM Hauke Rehr <[email protected]> wrote:
>
> As I said, y is a boxed list the first item of which
> contains some vector V which needs permutation.
> All the other items contain a list of two values,
> that’s why I said they represent transpositions.
> I could as well have built their product and
> then applied that permutation to the vector.
>
> I only mentioned it as an example of /’s usage.
> There are some other places where I use it with
> a single transposition.
>
> @raul: yes, they’re the same length but they
> have been built iteratively (^:)
> it was easiest just ;~ing them to the
> partial result
> and boxing the first was necessary since
> the very first item (not a permutation,
> it had a different meaning) V would be
> computed from has a different shape
> @both: as you asked for an example, in one case
> V (aka 'buildVfrom > {. y') had shape 50
> and the start of > }. y looked like
> 0 0
> 1 2
> 2 12
> 3 12
> 4 49
> 5 5
> 6 26
> 7 12
> 8 37
> 9 37
> 10 18
> 11 49
> so there are even identity “transpositions”
> that have to be dealt with (no-ops)
>
>
> Am 30.05.20 um 15:39 schrieb Brian Schott:
> > Could you please give a sample of your use of your swap.
> > I can't understand your description or the input(s).
> >
> > Thanks,
> >
> > On Sat, May 30, 2020 at 3:27 AM Hauke Rehr <[email protected]> wrote:
> >
> > [snip]
> >
> > My last use case was a boxed list consisting of
> >> a 1-d array and a set of transpositions I produced.
> >> I wrote (I bet there are better ways to do it)
> >> swap =: ] {~ ~.@[ C.@; <:@#@]
> >> and applied it on that boxed list.
> >> That actually looked something like 'swap&.>/@:|.' .
> >>
> >> --
> > (B=)
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
> --
> ----------------------
> mail written using NEO
> neo-layout.org
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm