[seqfan] Re: Mathematica code for trimming a sequence to the correct length
peter.luschny
peter.luschny at googlemail.com
Thu Apr 21 03:05:55 CEST 2011
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);
More information about the SeqFan
mailing list