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