## Who is right, me or my professor?

## Who is right, me or my professor?

(OP)

In a test i got this question:

Define a stream of all numbers in pascal triangle.

My answer was:

(define (pascal a b)

(cons-stream a (pascal(+a b)(b))

Knowing that it will give me a stream of all Natural numbers.

(and pascal triangle is basically all natural numbers..)

I didn't got one point on that question. Who do you think is right, me or my professor?

Thanks

Define a stream of all numbers in pascal triangle.

My answer was:

(define (pascal a b)

(cons-stream a (pascal(+a b)(b))

Knowing that it will give me a stream of all Natural numbers.

(and pascal triangle is basically all natural numbers..)

I didn't got one point on that question. Who do you think is right, me or my professor?

Thanks

## RE: Who is right, me or my professor?

## RE: Who is right, me or my professor?

## RE: Who is right, me or my professor?

I don't understand why should your function have 2 arguments, i.e. (pascal a b) ?

IMHO it should depend only of one argument n, i.e. (pascal n).

For example for n=0..4.. the Pascal-triangle is:

## CODE

1.row: 1 1

2.row: 1 2 1

3.row: 1 3 3 1

4.row: 1 4 6 4 1

...

IMHO, your professor probably wants to have a function which delivers for given n either

1. the numbers contained in triangle of order n, i.e:

## CODE

for n=1: (1)

for n=2: (1 2)

for n=3: (1 2 3)

for n=4: (1 2 3 4 6)

...

2. only the n-th row of Pascal triangle, i.e:

## CODE

for n=1: (1 1)

for n=2: (1 2 1)

for n=3: (1 3 3 1)

for n=4: (1 4 6 4 1)

...

## CODE

C(4,1)=4 is the 1-th element of (1 4 6 4 1)

C(4,2)=6 is the 2-nd element of (1 4 6 4 1)

...