Different approach by analyzing the sequence

   +/\1,,1,.+/\2,3*2^i.4
1 2 4 5 10 11 22 23 46 47 94



On 28-02-13 23:21, Johann Hibschman wrote:
Thanks, that's interesting. It seems a little cumbersome, but it certainly
works.

It seems to do a lot of appending, but since it's continually building up
the series, it never duplicates work. It can only do odd-length output
sequences, but the even sequences are only a }: away.


On Thu, Feb 28, 2013 at 9:30 AM, Raul Miller <[email protected]> wrote:

Here's one approach:

    (, (, +:)@>:@{:)^:3]1
1 2 4 5 10 11 22

--
Raul

On Thu, Feb 28, 2013 at 10:26 AM, Johann Hibschman <[email protected]>
wrote:
How do you generate a series produced by alternate application of two
monads?

For example, if I alternate >: and +: starting from 1, I get:

     1 2 4 5 10 11 22 ...

I can generate every other item in the series via (+:@>:)^:(i.6) 1, and I
get close with (([: >: ])`([: +: ]))/\6#1, but the ordering of the
operations is wrong. Agenda seems like it's also getting close, but I
can't
quite make it work.

Naively, I'd hoped that (>:`+:)^:(i. 5) 1 would work, but it does not.

Thanks,
Johann
----------------------------------------------------------------------
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

--
Met vriendelijke groet,
@@i = Arie Groeneveld

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to