Cool, elegant approach. I think we could trim off the merge using A., but I do
not have an interpreter in front of me, and Oleg's brinkster interpreter has
gone away :(
Anyway if you apply monad A. to Henry's output, or the output of the original
foo, you'll find out what the LHA to dyad A. would need to permute i. in that
fashion. If the tranformation function turns out to be simpler than the merge,
then you could use a fork of the form:
foo=: transform@[ A. i.@]
I'm still bad at predicting the behavior of A. without experiments, but it's
possible the transformation function could be as simple as [ .
-Dan
Please excuse typos; composed on a handheld device.
-----Original Message-----
From: Henry Rich <[email protected]>
Sender: [email protected]
Date: Fri, 29 Apr 2011 08:22:29
To: Programming forum<[email protected]>
Reply-To: Programming forum <[email protected]>
Subject: Re: [Jprogramming] A permutation of i.y
3 /:@(0} i.) 9
1 2 0 3 4 5 6 7 8
Henry Rich
On 4/29/2011 8:03 AM, Ian Clark wrote:
> My brain's a mess this morning...
>
> Let foo be a dyadic verb which simply returns i.y with the zero
> floated up to position x .
> (Forget the cases of x<1 and x>y)
>
> foo=: 4 : '(1|.i.x) , (x}.i.y)'
> 3 foo 9
> 1 2 0 3 4 5 6 7 8
>
> That's a distressing way of doing it, but it's the best I can manage.
> There's got to be a neater solution. Using # maybe?
> ----------------------------------------------------------------------
> 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