Pascal Line in Haskell

Ketil Z. Malde
22 Aug 2003 07:05:03 +0200

"Job L. Napitupulu" <> writes:

> Can anyone help me how to make a function which takes an integer n >
> 0 and returns the list of integers in Line of Pascal's Triangle.

Yes, I imagine a lot of people can, but you're supposed to do your own
homework.  Here's a rough outline, though:

1. write a function that, given a line from the triangle, produces the
   next line in the triangle
2. write a function that, using the above function and an integer n,
   produces the nth line of the triangle.
   For extra credit, do this in three ways:
        a) using recursion
        b) generating the entire (infinite!) triangle as a list of
           lines, and returning the appropriate one
        c) using a fold

If I haven't seen further, it is by standing in the footprints of giants