CS 3304 Midterm: CS 3304 midterm

193 views2 pages
31 Jan 2019
Course
Professor

Document Summary

S where s is a non-terminal, a, b are terminals, and is the empty symbol. Show that this grammar is ambiguous: (20 points) consider the function try written in some mystery" language function try(a,b) = if a=0 return 1 else return b; Assume we employ try in the expression try(0,1/0) Is it advisable that mystery use normal-order evaluation or applicative-order evaluation: (20 points) write a recursive ml function cycle that, given a list l and an integer i, cycles. For instance, if l = [1, 4, 5, 2], then cycle(l,1) returns [4, 5, 2, 1]. Similarly, cycle(l,2) returns returns [5, 2, 1, 4]. That is, given a list [a1, a2, , an] as arguments, produce [a2, a1, a4, a3, a6, a5, ] as the answer. If n is odd, an remains at the end. X (* line 1 *) end; begin end.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents