
Hi all, I'm pleased to announce the release of a somewhat silly -- yet perhaps somewhat useful -- library module, Math.OEIShttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/oeis-0.1, intended for the enjoyment of combinatorial dilettantes, Project Euler addicts, and the merely curious alike. It provides a Haskell interface to the Online Encyclopedia of Integer Sequences, with support for looking up sequences by ID number or partial list. You can use it to look up any and all information on a sequence (references, formulas, comments, keywords...), or just return the sequence data as a list. My favorite feature -- and the initial impetus for the library -- is that it can "guess" the rest of a sequence by using the first search result from the OEIS to extend it. Some examples of use: Prelude Math.OEIS> extendSequence [5,7,11,13,17] [5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71... Prelude Math.OEIS> extendSequence [2,4,8,16,32] [2,4,8,16,32,64,128,256,512,1024,2048,4096,8192... Prelude Math.OEIS> description `fmap` lookupSequence [1,2,5,14,42] Just "Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). Also called Segner numbers." Math.OEIS can be obtained from hackagehttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/oeis-0.1, and additional documentation is included with the module in Haddock form. Features planned for future versions include: * support for returning multiple search results instead of just one. * support for automatically returning additional terms if available in a b****.txt file. * hack GHC to provide [1,2,5,14,42..] syntax for extendSequence. * returning a lazy infinite list for infinite sequences via an embedded general AI and Mathematica interpreter. Enjoy! -Brent (byorgey)

On Mon, 22 Oct 2007, Brent Yorgey wrote:
Hi all,
I'm pleased to announce the release of a somewhat silly -- yet perhaps somewhat useful -- library module, Math.OEIShttp://hackage.haskell.org/cgi-bin/hackage-scripts/package/oeis-0.1, intended for the enjoyment of combinatorial dilettantes, Project Euler addicts, and the merely curious alike. It provides a Haskell interface to the Online Encyclopedia of Integer Sequences, with support for looking up sequences by ID number or partial list. You can use it to look up any and all information on a sequence (references, formulas, comments, keywords...), or just return the sequence data as a list. My favorite feature -- and the initial impetus for the library -- is that it can "guess" the rest of a sequence by using the first search result from the OEIS to extend it. Some examples of use:
Prelude Math.OEIS> extendSequence [5,7,11,13,17] [5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71...
Cute!
Prelude Math.OEIS> extendSequence [2,4,8,16,32] [2,4,8,16,32,64,128,256,512,1024,2048,4096,8192...
Prelude Math.OEIS> description `fmap` lookupSequence [1,2,5,14,42] Just "Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). Also called Segner numbers."
The Online Encyclopedia of Integer Sequences should really contain more Haskell code for describing the sequences.

On 10/22/07, Henning Thielemann
Cute!
+1 http://programming.reddit.com/info/5yuhf/comments/ -- vvv

If someone organized something like that, (or even a more extended version like the ongoing attempts a while back to optimize for the language shootout) I'd be totally in. Seems like a great way for newer foax to take a crack at something useful and interact to get a better handle on the language. --S On Oct 22, 2007, at 10:54 AM, Brent Yorgey wrote:
The Online Encyclopedia of Integer Sequences should really contain more Haskell code for describing the sequences.
Agreed! I propose an "OEIS party" where we all sit around one day and submit Haskell code. =)
(I'm only half joking...)
-Brent _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, 2007-10-22 at 10:54 -0400, Brent Yorgey wrote:
The Online Encyclopedia of Integer Sequences should really contain more Haskell code for describing the sequences.
Agreed! I propose an "OEIS party" where we all sit around one day and submit Haskell code. =)
(I'm only half joking...)
See http://www.sagemath.org/hg/sage-main/file/cf44d55e626b/sage/combinat/sloane_... for the very beginnings of an effort to write OEIS code in Python (for the SAGE computer algebra system). (It looks like currently 130 sequences are implemented.) Maybe this would be useful as a starting point. The above hyperlink is for today's version of the file. I couldn't figure out how to link to the latest version, but this is an RSS feed for updates to that file: http://www.sagemath.org/hg/sage-main/rss-log/tip/sage/combinat/sloane_functi... Carl Witty

Carl Witty wrote:
On Mon, 2007-10-22 at 10:54 -0400, Brent Yorgey wrote: The Online Encyclopedia of Integer Sequences should really contain more Haskell code for describing the sequences.
Agreed! I propose an "OEIS party" where we all sit around one day and submit Haskell code. =)
(I'm only half joking...)
See http://www.sagemath.org/hg/sage-main/file/cf44d55e626b/sage/combinat/sloane_... for the very beginnings of an effort to write OEIS code in Python (for the SAGE computer algebra system). (It looks like currently 130 sequences are implemented.) Maybe this would be useful as a starting point.
This is a bit of a waste of human time, especially since automated methods (like gfun [1]) can automatically find closed-forms for about 1/3 of the sequences on OEIS. Generating code from the output of gfun is an easy task, and leads to rather pretty results [2], in my completely biased opinion. Very very few of the sequences outside of that 1/3 has known "programs" associated with them. Now, using many of Jerzy Karczmarczuk's ideas [3] and Haskell packages, one could rewrite gfun in Haskell, and the end result would likely be extremely elegant, although making it efficient might be rather more challenging. Jacques [1] http://portal.acm.org/citation.cfm?id=178368 and http://algo.inria.fr/libraries/ [2] http://www.cas.mcmaster.ca/~carette/publications/CaretteJanicki.pdf [3] http://users.info.unicaen.fr/~karczma/arpap/

On Mon, Oct 22, 2007 at 07:20:47AM -0400, Brent Yorgey wrote:
* returning a lazy infinite list for infinite sequences via an embedded general AI and Mathematica interpreter.
Assuming you have a licensed copy of Mathematica, get in touch with Cale Gibbard; he has done all the work for interfacing Mathematica with Haskell (cf 'mbot' on freenode). Stefan

Uh, not quite. My code essentially treats mathematica as a function on
strings, (and involves some additional shell wrapping), since there's
essentially no processing to do on the Haskell side there. If you
wanted to do it right, you'd probably want to write an FFI binding to
MathLink.
On 22/10/2007, Stefan O'Rear
On Mon, Oct 22, 2007 at 07:20:47AM -0400, Brent Yorgey wrote:
* returning a lazy infinite list for infinite sequences via an embedded general AI and Mathematica interpreter.
Assuming you have a licensed copy of Mathematica, get in touch with Cale Gibbard; he has done all the work for interfacing Mathematica with Haskell (cf 'mbot' on freenode).
Stefan
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFHHNziFBz7OZ2P+dIRAlPhAJ9HuSDs4Zo40eZfTg2pvx8yo/16ZgCgnQBF Y8QCAH6h8S+Txj7CflXZaK0= =5q11 -----END PGP SIGNATURE-----
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 10/22/07, Cale Gibbard
Uh, not quite. My code essentially treats mathematica as a function on strings, (and involves some additional shell wrapping), since there's essentially no processing to do on the Haskell side there. If you wanted to do it right, you'd probably want to write an FFI binding to MathLink.
On 22/10/2007, Stefan O'Rear
wrote: On Mon, Oct 22, 2007 at 07:20:47AM -0400, Brent Yorgey wrote:
* returning a lazy infinite list for infinite sequences via an embedded general AI and Mathematica interpreter.
Assuming you have a licensed copy of Mathematica, get in touch with Cale Gibbard; he has done all the work for interfacing Mathematica with Haskell (cf 'mbot' on freenode).
well, at any rate, I was mostly joking about the embedded Mathematica interpreter. =) The point is, what you'd *like* (say) extendSequence [1,2,5,14,42] to do is return the *infinite* list of Catalan numbers, but that's very, very difficult to do in general! Interpreting the Mathematica code given for some sequences would require a lot of effort (I'm not even sure that the Mathematica code for different sequences is generally organized in some standard way), and still wouldn't really get you all that much anyway. Now, if the OEIS stored *Haskell* code to generate sequences... -Brent

Brent Yorgey wrote:
The point is, what you'd *like* (say) extendSequence [1,2,5,14,42] to do is return the *infinite* list of Catalan numbers, but that's very, very difficult to do in general!
Actually impossible, since OEIS contains "Busy Beaver" sequences, which are not computable! (although its values becomes large so fast that, even if the answer was computable, the universe would end before you computed it, so it might not make a real difference in this case...) Isaac
participants (9)
-
Brent Yorgey
-
Cale Gibbard
-
Carl Witty
-
Henning Thielemann
-
Isaac Dupree
-
Jacques Carette
-
Stefan O'Rear
-
Sterling Clover
-
Valery V. Vorotyntsev