mer, 17 Mar 2010, Zsbán Ambrus skribis:
> On Wed, Mar 17, 2010 at 1:01 PM, Collin Monahan <[email protected]> wrote:
> > How can I define a function f such that
> >
> >  f 0 1 2 4 5
> > 3
> >  f 1 3 5 7
> > 0 2 4 6
> >
> > It should scale to a list of 6000 integers whose maximum element is 60000.
> 
> My solution at "http://www.perlmonks.org/?node=388321"; hints that the
> solution should use 2&(f0\) where f0 lists the missing numbers between
> two numbers, eg. f0 3 6 should give the list 4 5.
> 
>    f=: [: ; 2 ([:<[>:@+[:i.<:@-~)/\ _1&,
>    f 1 3 5 7
> 0 2 4 6
>    f 0 1 2 4 5
> 3
>    f 1 3 4 6 10
> 0 2 5 7 8 9
> 
> Ambrus

Does it assume the original list pre-sorted?
   f 0 2 3 6
 1 4 5
   f 2 0 6 3
 0 1 5 4 3 1 2 3 4 5 10 9 8 7

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to