# format_V.txt kernelopts(printbytes=false): with(share): with(gfun): # Last modified Nov 30 1998 # Maple V procedure that takes a sequence of integers in Maple "list" # format and converts it to the format I use in the # Integer Sequences Table. # MEMO to other users: # YOU MUST EDIT THIS FILE AND REPLACE EVERY INSTANCE OF # "ampersand amp;" by an "ampersand" # "ampersand lt;" by a "less than" # "ampersand gt;" by a "greater than" # # Also replace "njas" # by your name and email address # Preferred format for this is # Mary Smith (ms@math.univ.edu) # using parens () not pointed brackets because the latter # cause trouble with html # The second argument , e.g. 2632, is the sequence ID number. # Best to use 0,1,2,3 ... since I assign ID numbers as the sequences arrive. # Send new sequences to me at this address: njas@research.att.com # Thanks! Neil Sloane # EXAMPLES: (Call this file "format") # There is a finished example a bit further down. # Note that that includes a %H line with a link to a web site # where more information about the sequence can be found. # Please add such links if appropriate! # $ maple # > read format; # > seq1:=[1,2,5,16,73,538]; # > format(seq1,2632); # %I A002632 # %S A002632 1,2,5,16,73,538 # %N A002632 # please describe sequence in %N line # %O A002632 0,2 # offset line (see help file for details) # %K A002632 nonn # keywords (see help file for details) # %A A002632 njas # put your name here - see above # %D A002632 # Give detailed references in 1 or more %D lines # %p A002632 # give Maple commands here if appropriate # > seq2:=[seq(2^n,n=0..50)]: # > format(seq2,79); # %I A000079 # %S A000079 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384, # %T A000079 32768,65536,131072,262144,524288,1048576,2097152,4194304, # %U A000079 8388608,16777216,33554432,67108864,134217728,268435456 # %N A000079 # %O A000079 0,2 # %K A000079 nonn # %A A000079 njas # %D A000079 # %p A000079 # It handles signed sequences too: # > seq3:=[seq( (-1)^n*2^n,n=0..50) ]: # > format(seq3,10059); # %I A010059 # %S A010059 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384, # %T A010059 32768,65536,131072,262144,524288,1048576,2097152,4194304, # %U A010059 8388608,16777216,33554432,67108864,134217728,268435456 # %V A010059 1,-2,4,-8,16,-32,64,-128,256,-512,1024,-2048,4096,-8192,16384, # %W A010059 -32768,65536,-131072,262144,-524288,1048576,-2097152,4194304, # %X A010059 -8388608,16777216,-33554432,67108864,-134217728,268435456 # %N A010059 # %O A010059 0,2 # %K A010059 sign,done # %A A010059 njas # %D A010059 # %p A010059 # > quit # Here is a typical example of a finished sequence: # %I A000745 # %S A000745 1,5,18,57,180,617,2400,10717,54544,312353,1988104,13921501, # %T A000745 106350816,880162337,7844596536,74910367309,763030711936, # %U A000745 8257927397569,94628877364936,1144609672707741,14573622985067744 # %N A000745 Boustrophedon transform of squares. # %O A000745 0,2 # %K A000745 nonn # %A A000745 njas # %p A000745 # %D A000745 J. Millar, N. J. A. Sloane and N. E. Young, A new operation on sequences: the Boustrophedon transform, J. Comb. Theory, Series A, Vol. 76 (1996), 44-54. # %H A000745 Link to reference format:=proc(s,n) global A; local ___A___,pnum,poo,maxn,i,aa,nn,chaineI,chaineN,chainep,chaineD,chaineS,chaineT,\ offset,flg,chaineA,chaineO,chaineU,pn,pa,pi,po,ps,pt,pu,pv,pw,px,pk,pp,pd,\ blanc,chaineV,chaineW,chaineX,ls,lt,lu,lv,lw,lx,sig,chaineK,t1; # save old A ___A___:=A; A:='A'; t1:=1000000000+n; maxn:=64; offset:=1; flg:=0; pn:=`%N `; pa:=`%A `; pi:=`%I `; po:=`%O `; ps:=`%S `; pt:=`%T `; pu:=`%U `; pv:=`%V `; pw:=`%W `; px:=`%X `; pk:=`%K `; pp:=`%p `; pd:=`%D `; pnum:=convert(t1,string); pnum:=substring(pnum,5..10); pnum:=cat(`A`,pnum); aa:=s; nn:=nops(aa); blanc:=` `; chaineS:=` `; chaineT:=` `; chaineU:=` `; chaineV:=` `; chaineW:=` `; chaineX:=` `; chaineA:=cat(pa,pnum,blanc,`njas`); chaineI:=cat(pi,pnum); chaineN:=cat(pn,pnum); chaineK:=cat(pk,pnum); chainep:=cat(pp,pnum); chaineD:=cat(pd,pnum); i:=1; chaineS:=cat(ps,pnum,blanc,abs(op(i,aa))); chaineV:=cat(pv,pnum,blanc, op(i,aa) ); if i 1 and flg=0 then offset:=i:flg:=1 fi; chaineT:=cat(pt,pnum,blanc); chaineU:=cat(pu,pnum,blanc); chaineW:=cat(pw,pnum,blanc); chaineX:=cat(px,pnum,blanc); while length(chaineS) <= maxn and i 1 and flg=0 then offset:=i:flg:=1 fi; od; while i < nn and length(chaineT) <= maxn do i:=i+1; chaineT:=cat(chaineT,abs(op(i,aa)),`,`); chaineW:=cat(chaineW, op(i,aa) ,`,`); od; while i < nn and length(chaineU) <= maxn do i:=i+1; chaineU:=cat(chaineU,abs(op(i,aa)),`,`); chaineX:=cat(chaineX, op(i,aa) ,`,`); od; poo:=cat(` 0,`,convert(offset,string)); chaineO:=cat(po,pnum,poo); ls:=length(chaineS); lt:=length(chaineT); lu:=length(chaineU); lv:=length(chaineV); lw:=length(chaineW); lx:=length(chaineX); if lt = 11 then chaineS:=substring(chaineS,1..ls-1); chaineV:=substring(chaineV,1..lv-1); fi; if lu = 11 then chaineT:=substring(chaineT,1..lt-1); chaineW:=substring(chaineW,1..lw-1); fi; chaineU:=substring(chaineU,1..lu-1); chaineX:=substring(chaineX,1..lx-1); sig:=1: for i from 1 to nn do if op(i,aa)<0 then sig:=-1: fi: od: lprint(chaineI); lprint(chaineS); if lt>11 then lprint(chaineT); fi: if lu>11 then lprint(chaineU); fi: if sig<0 then lprint(chaineV); if lt>11 then lprint(chaineW); fi: if lu>11 then lprint(chaineX); fi: chaineK:=cat(chaineK,blanc,`sign,done`): else chaineK:=cat(chaineK,blanc,`nonn`): fi: A:=___A___; lprint(chaineN); lprint(chaineO); lprint(chaineK); lprint(chaineA); lprint(chaineD); lprint(chainep); end: # END OF PROGRAM