[seqfan] Re: Computing sequences up to first non-distinct element: re-inventing the wheel?

Alonso Del Arte alonso.delarte at gmail.com
Thu Feb 16 00:19:10 CET 2012


My wheel reinvention did use MemberQ. But once I figured out how to take
what Hans did for Collatz the Collatz function and apply it to any other
problem, I chucked my convoluted new wheel.

Al

On Wed, Feb 15, 2012 at 4:04 PM, RGWv <rgwv at rgwv.com> wrote:

> I think that MemberQ is the function you are looking for.
>
> -----Original Message----- From: Alonso Del Arte
> Sent: Wednesday, February 15, 2012 12:01 PM
> To: Sequence Fanatics Discussion list
> Subject: [seqfan] Computing sequences up to first non-distinct element:
> re-inventing the wheel?
>
>
> I started writing a function in Mathematica that at the addition of
> each element to a list tests whether that element has already shown up
> on the list before and stops when that occurs. But it really felt like
> I was reinventing the wheel, though I don't know what would be the
> built-in command that does this.
>
> A good example of this are Collatz sequences, though conjecturally you
> just have to test for the occurrence of 1 to know when to stop, e.g.,
>
> 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1,
> 4, 2, 1, 4, ... (no need to keep going).
>
> FixedPointList doesn't work for this purpose, unless you hard-code
> f(1) = 1 (I think I have done that for one or two programs in the
> OEIS).
>
> My question is: is there a built-in Mathematica command that in this
> example would stop at the second occurrence of 4?
>
> Al
>
> --
> Alonso del Arte
> Author at SmashWords.com<https://www.**smashwords.com/profile/view/**
> AlonsoDelarte <https://www.smashwords.com/profile/view/AlonsoDelarte>>
> Musician at ReverbNation.com <http://www.reverbnation.com/**alonsodelarte<http://www.reverbnation.com/alonsodelarte>
> >
>
> ______________________________**_________________
>
> Seqfan Mailing list - http://list.seqfan.eu/
>
> ______________________________**_________________
>
> Seqfan Mailing list - http://list.seqfan.eu/
>



-- 
Alonso del Arte
Author at SmashWords.com<https://www.smashwords.com/profile/view/AlonsoDelarte>
Musician at ReverbNation.com <http://www.reverbnation.com/alonsodelarte>



More information about the SeqFan mailing list