[seqfan] Re: Mathematica code for trimming a sequence to the correct length

Olivier Gerard olivier.gerard at gmail.com
Thu Apr 21 09:14:42 CEST 2011

```I propose that these various codes be collected on a Wiki page
for sequence tools.

Here is a first version at

http://oeis.org/wiki/Sequence_Tools

Olivier

On Thu, Apr 21, 2011 at 03:31, Robert Gerbicz <robert.gerbicz at gmail.com>wrote:

> 2011/4/21 peter.luschny <peter.luschny at googlemail.com>
>
> > T. D. Noe: ".. or translate this code to your
> > favorite language and share."
> >
> > If you are not a Maple user, please ignore...
> >
> > OEIStrim := proc(f, offset)
> > local L, n, len, fn;
> > L := NULL; len := 0;
> > n := `if`(whattype(f)=list,1,offset);
> > do
> >  fn := `if`(whattype(f)=list,f[n],f(n));
> >  len := len + 2 + length(fn);
> >  if len > 260 then break fi;
> >  L := L,fn;
> >  n := n + 1;
> > od;
> > L end:
> >
> > Usage:
> > OEIStrim(n -> n, 0);
> >
> > f := n -> n:
> > OEIStrim(f, 0);
> >
> > F := [seq(n, n = 0..100)]:
> > OEIStrim(F, ignore);
> >
> > _______________________________________________
> >
> > Seqfan Mailing list - http://list.seqfan.eu/
> >
> In PARI-GP:
> OEISTrim(v)=L=260;len=0;w=[];for(i=1,length(v),\
> len+=3+(v[i]<0);x=abs(v[i])\10;while(x,len++;x\=10);\
> if(len>L,break);w=concat(w,v[i]));return(w)
>
>
> try: OEISTrim(vector(100,i,i)) returns by the first 67 positive integers.
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/
>

```