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: 50% (8 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 :...
-
How have information and communication technologies caused jobs to change?
-
Although determining gross profit for departments in a department store has some merit, the idea of trying to determine departmental profit is questionable because of all the indirect costs usually...
-
Use the information contained below to compress one time unit per move using the least cost method. Reduce the schedule until you reach the crash point of the network. For each move identify what...
-
How can advanced process control systems be utilized to optimize multivariable operations in a large-scale chemical plant, particularly when dealing with highly nonlinear processes and time-varying...
-
Nucor Corporation produces steel and steel products at its eight mills and is a major recycler of scrap metal. The following data relate to Nucor for four years. Required: 1. Calculate Nucor's ROA...
-
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?
-
Can you conclude that education level is independent of gender? Use the. = 0.01 level of significance. The General Social Survey polled 1280 men and 1531 women to determine their level of education....
-
Which of the following are valid in a Java file, listed in the order in which they are declared? (Choose two.) A. A package-private class declaration and a public interface declaration B. Two package...
-
What is the output of the following when run as java EchoFirst.java seed flower plant? A. 0 B. 1 C. 2 D. The code does not compile. E. The code compiles but throws an exception at runtime. F. The...
-
The partnership of Tasha and Bill shares profits and losses in a 50:50 ratio, and the partners have capital balances of $45,000 each. Prepare a schedule showing how the bonus should be divided if...
-
R and Q form equal partnership RQ on February 15. Partner R has a tax year ending on July 31, whereas partner Qs tax year ends on October 31. What taxable year must the partnership use? a. February...
-
Use your results from question 16 to construct a relative frequency table and a cumulative relative frequency table. Use the goaltenders salaries for the 1991 NHL season given in the following table...
-
Hovak Company has credit sales of $4,500,000 for year 2016. At December 31, 2016, the company's Allowance for Doubtful Accounts has an unadjusted debit balance of $3,400. Hovak prepares a schedule of...
-
What does non-recourse financing mean?
-
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 .
-
A rhino is charging at you, so decide to sedate it with a tranquilizer gun angled at 40 as shown above. The tranquilizer gun can reach a horizontal distance of 49 m when angled at 45. (Assume ideal...
-
What is the definition of motivation and how can the chef foster an environment of motivation in the kitchen? What methods can a chef implement to motivate the kitchen team? What factors contribute...
-
Article Review Read the article. Link is given below: https://www.projecttimes.com/articles/avoid-the-top-three-real-causes-of-scope-creep.html Post your thoughts on this article, add references if...
Study smarter with the SolutionInn App