Question: Scheme Expression 3. Write a recursive function to count the number of the elements of a list. Please name the function as count-elements. This function

Scheme Expression

3. Write a recursive function to count the number of the elements of a list. Please name the function as count-elements. This function should tell how many elements are contained in a list. For example, (count-elements '(a (b c) (d (e) f ))) returns 3.

4. Write a recursive function to count the number of the atoms that appear at all levels of an S-expression. Please name the function as count-atoms. This function should tell how many atoms are contained in a s-expression. For example, (count-atoms '(a (b c) (d (e) f))) returns 6.

5. Write a recursive function to get the maximum number from a sequence of numbers. Please name the function as max. This function should tell the maximum number in a given list.

For example, (max ( 5 6 9 3 6)) will result in 9. 6.

Write a Scheme program for Fibonacci numbers.

The Fibonacci numbers are defined as follows:

Fibonacci(n) = 0 if n = 1

= 1 if n = 2 = Fibonacci(n-1) + Fibonacci(n-2) if n > 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!