Ex. 1. a Write a function that receives an unlimited number of parameters and computes the product of all of them that are numbers (some may not be). The non-numerical elements should be ignored. If none of the arguments is a number the function should return 0. You will have to use the appropriate type-checking predicate here.
b. Show a few examples of testing this function, both directly and using the built-ins apply and funcall.
Reference. The tree structure and the print in pre-order functions discussed in class: tree.el.
Ex. 2 In this exercise you will write two functions that print the tree in symmetric order: the left subtree, then the root, and then the right subtree. For example, for the tree discussed in class the symmetric order would be:
18 51 5 33 23 7 10
a. Write a simple recursive function.
b. Transform the function into an iterative one using a number of states (probably 3) as in the example shown in class.
c. (optional, 5 extra credit points) Optimize the function written at point b to avoid storing the states on the stack.
Ex. 3 Follow the execution of the iterative function written at point b showing the content of the stack, the current frame, the root of the current tree, and state at each iteration. There are two options for doing this:
Alt. a Write it yourself on paper (or in a text file) "by hand".
Alt. b. Modify the function itself so that it outputs this information instead of printing out the tree only. You can just send in the code of the function instead.
Reference. The Lisp implementation of the first grammar shown in class : grammar1.el.
Ex. 1. a Write a regular grammar to recognize a comment in a C++ program. A comment starts with /* and ends with */ and anything else in between can be ignored. We won't consider the case of nested comments. Draw the finite state machine for this grammar.
b. Draw a table for the finite state machine in the slides, found in the slide marked Example following the slide titled NFA to DFA. The machine is the one at the bottom of the slide containing the state VW. Consider that the arrow going from VW to end is marked by anything else than an a or a b.
c. Consider the regular grammar in the slides that recognizes a real number. Draw a finite state machine for it.
Ex. 2. Considering the finite state machine refered in Ex. 1 b, write the equivalent regular grammar and a Lisp program recognizing lists composed of symbols that are accepted by the grammar / automaton. Show some examples of lists recognized/not recognized by the grammar.
Send the file(s) by email as attachment(s). You can turn in the written part you on paper.