Write a program in your favorite imperative language that has the same input and output as the
Question:
Write a program in your favorite imperative language that has the same input and output as the Scheme program of Figure 11.1. Can you make any general observations about the usefulness of Scheme for symbolic computation, based on your experience?
Figure 11.1
Transcribed Image Text:
(define simulate (lambda (dfa input) (letrec ((helper ; note that helper is tail recursive, ; but builds the list of moves in reverse order (lambda (moves d2 i) (let ((c (current-state d2))) (if (null? i) (cons c moves) (helper (cons c moves) (move d2 (car i)) (cdr i))))))) (let ((moves (helper '() dfa input))) (reverse (cons (if (is-final? (car moves) dfa) 'accept 'reject) moves)))))) ;; access functions for machine description: (define current-state car) (define transition-function cadr) (define final-states caddr) (define is-final? (lambda (s dfa) (memą s (final-states dfa)))) (define move (lambda (dfa symbol) (let ((cs (current-state dfa)) (trans (transition-function dfa))) (list (if (eq? cs 'error) 'error (let ((pair (assoc (list cs symbol) trans))) (if pair (cadr pair) 'error))); new start state trans ; same transition function (final-states dfa))))) same final states
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 44% (9 reviews)
Its not clear what programming language you would like me to write the program in ...View the full answer
Answered By
Churchil Mino
I have been a tutor for 2 years and have experience working with students of all ages and abilities. I am comfortable working with students one-on-one or in small groups, and am able to adapt my teaching style to meet the needs of each individual. I am patient and supportive, and my goal is to help my students succeed.
I have a strong background in math and science, and have tutored students in these subjects at all levels, from elementary school to college. I have also helped students prepare for standardized tests such as the SAT and ACT. In addition to academic tutoring, I have also worked as a swim coach and a camp counselor, and have experience working with children with special needs.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Write a program in your favorite programming language (Python, C, C++, etc.) to implement/simulate a finite automaton that (only) recognizes/accepts the language of: Problem A Binary numbers...
-
Implement Dijkstras algorithm for computing a shortest path from a designated vertex (A) to a designated vertex (B) in a directed graph. Your implementation should use a minimum heap as a supporting...
-
The equation of motion for free vibration of the triple pendulum shown in Fig I are given by: [3 2 1a [3 0 0]e ml 2 2 10,+ mgl 0 2 0 0 0 10, 1 11 Assuming a solution of the form: 0(0) = 0, cos(or),...
-
Repeat the analysis of problem 14.7, but this time focus on the Facebook call and put options in Figure 14.1 that have a strike price of $87.50. If you use put-call parity to find the price of...
-
A detonation pond has the shape of an inverted truncated pyramid, it has a rectangular bottom of dimension 120 ( 80 ft, a maximum depth of 5 ft, and uniform side slopes of 3 : 1 (horizontal :...
-
Check my work 2 Orion Corporation has established the following standards for the prime costs of one unit of its chief product, dartboards Direct material Direct labor Total Standard Ouantity 5.00...
-
Distribution of yellowhammer birds. An article in the Journal of Animal Ecology (July 2006) discussed some of the caveats of using stepwise regression. An example presented used stepwise regression...
-
When a country specializes in the production of a good, this means that it can produce this good at a lower opportunity cost than its trading partner. Because of this comparative advantage, both...
-
(1) Assume that $238,800 of the fixed overhead cost is avoidable. (If an amount reduces the net income then enter with a negative sign preceding the number e.g. - 15,000 or parenthesis, e.g....
-
What is the solution of the recursive equation T (n) = 0.015625T +n?? (1/4) a) O(n') b) O(n' lg n) c) O(n* Ign) d) O(7*)
-
Suppose we wish to remove adjacent duplicate elements from a list (e.g., after sorting). The following Scheme function accomplishes this goal: Write a similar function that uses the imperative...
-
Explain the connection between short-circuit Boolean expressions and normal-order evaluation. Why is cond a special form in Scheme, rather than a function?
-
Translation. How do MNEs translate foreign currency into functional currency when consolidating their financial statements?
-
Use the following data to calculate the requested ratios for Tristar Transport and Logistic Services. Briefly analyse each answer. 1) Days accounts receivable. 2) Inventory turnover. 3) Debt/equity....
-
The following partial information is contained in the variance analysis received from the Western Plant of Eastlawn Company. All plants at Eastlawn apply overhead on the basis of direct labor-hours....
-
The Hudson Company is the sponsor of an IRS qualified defined benefit pension plan for a single employer. The pension plan calculates pension benefits based on factors like age, years of service, and...
-
Find the area enclosed by one loop of the four-leaved rose r = cos(20).
-
Landen Corporation uses a job-order costing system. At the beginning of the year, the company made the following estimates: Direct labor-hours required to support estimated production 65,000...
-
In Problems, solve each equation for x to three decimal places. 3 + 6e -2x = 7
-
What is beacon marketing? What are digital wallets?
-
Describe in detail how to swap two nodes x and y (and not just their contents) in a singly linked list L given references only to x and y. Repeat this exercise for the case when L is a doubly linked...
-
Describe in detail an algorithm for reversing a singly linked list L using only a constant amount of additional space.
-
The number of operations executed by algorithms A and B is 8nlogn and 2n 2 , respectively. Determine n 0 such that A is better than B for n n 0 .
-
In 2019, Sunland Company had a break-even point of $388,000 based on a selling price of $5 per unit and fixed costs of $155,200. In 2020, the selling price and the variable costs per unit did not...
-
11. String Conversion Given a binary string consisting of characters '0's and '1', the following operation can be performed it: Choose two adjacent characters, and replace both the characters with...
-
Consider the table shown below to answer the question posed in part a. Parts b and c are independent of the given table. Callaway Golf (ELY) Alaska Air Group (ALK) Yum! Brands (YUM) Caterpillar...
Study smarter with the SolutionInn App