Saturday, 31 July 2010

ADDING HELP TO OEIS SEQUENCES

As I´m working on more than one small projects of programming sequences from The On-Line Encyclopedia of Integer Sequences, and as I always try to document my code the best I can: I like to add comments and help information to it, but after many hours of “copy and paste”, and being aware that when you are trying to do something with a computer: if you feel that everything is repetitive and boring, then it is for sure, that you are using the wrong procedure, so then, I decided to create a very simple tools to make my life easier.

The PHP code of these two on-line applications is almost the same than the one of OEIS2BibTeX, but this time changed to provide the help code for PARI/GP or Mathematica OEIS sequences functions.

Both applications can be used in two different ways:

* Entering the Sequence Id number with a HTML form: in a POST METHOD, or
* With the Id Number supplied to the PHP code within the link, using ?sequence=valid_ID



1) PARI/GP

1.1) HTML POST Method:
http://oeis2bibtex.netai.net/helpPARI_GP/

1.2) PHP Parameter:
http://oeis2bibtex.netai.net/helpPARI_GP/OEIS-PARI_GP-Help.php?sequence=A000200
Here you can change A000200 for the desired Sequence Id Number:


2) WOLFRAM MATHEMATICA

2.1) HTML POST Method:
http://oeis2bibtex.netai.net/helpMathematica/

2.2) PHP Parameter:
http://oeis2bibtex.netai.net/helpMathematica/OEIS-Mathematica-Help.php?sequence=A000200

2.3) Mathematica Code using Import:

As Mathematica can access on-line data, these functions can do the job too inside any Mathematica Notebook or Package:
OEISSequenceDescription[seq_String]:=Module[{dataloaded = StringJoin[Import["http://oeis.org/classic/?q=id%3a" <> seq <> "&fmt=3","Data"]], first, last},
first = Flatten[StringPosition[dataloaded, "%N"], 1][[2]];
last = Select[StringPosition[dataloaded, "%"][[All, 1]], # > first&][[1]];
StringReplace[StringTake[dataloaded, {first + 10, last - 1}], " " ~~ _ -> ""]]


OEISAddHelp[seq_String]:=ToExpression[StringJoin[seq, "::usage=\"",seq, ": ", OEISSequenceDescription[seq], "\""]]


Archives:
[a]-073110-Adding Help to OEIS Sequences.nb


References:

[1]-PARI/GP Development Headquarters - Programming in GP: other specific functions-addhelp
[2]-http://formatmysourcecode.blogspot.com/
[3]-Wolfram Mathematica Documentation Center: Import
[4]-E.PĂ©rez Herrero-OEIS Utilities Page@ OEIS Wiki