Scheem example programs

Once your Scheem interpreter seems somewhat solid, start writing some interesting example programs in it. As you need small features to make an example work, go ahead and add them into your Scheem implementation along with some quick tests.

Ideas for examples

Here are some ideas for simple example programs. You don't have to do all these, these are just ideas for inspiration.

Compute factorial.

Compute Fibonacci numbers.

Reverse a list.

Find if an element is in a list.

Apply a function to every element of a list.

Flatten a nested list of lists into a single list.

Write binary search tree functions insert and find. Binary search trees might be represented in list form as (value _left _right).

Implement a dictionary data structure with lookup and update.

Write a function that does symbolic derivatives. The input (diff '(* x x) 'x) should evaluate to (+ (* 1 x) (* x 1)). Do you remember the product rule?

Make a Scheem interpreter in Scheem. Yo dawg I heard you like interpeters...

Outside testing

As you work on examples in Scheem, it might help you to test them in a full-featured Scheme. BiwaScheme is a convenient online Scheme interpreter that is quick to jump in and use. If you get an example working in Scheme but it doesn't work in your version of Scheem, investigate why. See if you can track down the bug. As you find bugs, remember to add a test for that particular problem so you don't have to fix it again.

Brag

Once you have lambdas working in your Scheem with an example, show it off to the world in the class forum! You don't need everything working to be brag-worthy.



Prev Next