Question: Write more example programs in the functional language, and test them in the same way as in Exercise 4.1: Compute the sum of the numbers

Write more example programs in the functional language, and test them in the same way as in Exercise 4.1:

Compute the sum of the numbers from 1000 down to 1. Do this by defining a function sum n that computes the sum n + (n 1) ++ 2 + 1. (Use straightforward summation, no clever tricks.) Compute the number 38, that is, 3 raised to the power 8. Again, use a recursive function. Compute 30 + 31 ++ 310 + 311, using a recursive function (or two, if you prefer). Compute 18 + 28 ++ 108, again using a recursive function (or two).

Exercise 4.1:

Get archive fun.zip from the homepage and unpack to directory Fun. It contains lexer and parser specifications and interpreter for a small firstorder functional language. Generate and compile the lexer and parser as described in README.TXT; parse and run some example programs with ParseAndRun.fs.

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 Programming Questions!