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 :...
-
Relevant and irrelevant costs. Answer the following questions.1. DeCesare Computers makes 5,200 units of a circuit board, CB76 at a cost of $280 each. Variable cost per unit is $190 and fixed cost...
-
The IRS categorizes non-governmental organizations into various types. Organizations that qualify for 501c3 status are charitable, educational, and benefi cial. Contributions to these organizations,...
-
The stockholders' equity accounts of Castle Corporation on January 1, 2015, were as follows. Preferred Stock (8%, $50 par, cumulative, 10,000 shares authorized) ....$ 400,000 Common Stock ($1 stated...
-
Zod Company has determined that its Eagle division is a cash-generating unit. The carrying amounts at December 31, 2021 are as follows: Factory building 500,000 Equipment 250,000 Land 300,000...
-
How many bits will it take to represent the decimal number 3,175,000? How many bytes will it take to store this number?
-
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?
-
A company revised the estimated useful lives of its fixed assets, which resulted in an increase in the remaining lives of several assets. Can the company include, as income of the current period, the...
-
1). An audio speaker producing a steady sound at an outdoor concert is 28 ft away from you. If you move to a position where the speaker is 64 ft distant, by what factor will the amplitude of the...
-
Builtrite is considering the purchase of a machine with the following cash flow diagram: year 0 spend $80,000 year 1 $40,000 year 2 $20,000 year 3 $10,000 year 4 $15,000 What is the payback period?
-
P was hit by an automobile driven by D. P brought a federal diversity action against D alleging negligence. P claimed that he suffered serious whiplash in the accident and that he has been physically...
-
FB Company is preparing its December 3 1 , 2 0 2 3 statement of financial position. The following items may be reported as either current or non - current liability: On December 1 5 , 2 0 2 3 , FB...
-
You are thinking about investing in one of the two mutual funds, MassMutual and Vanguard. You have obtained the following information based on their performance over the last five years. Of course,...
-
Flawless Cosmetic Company manufactures and distributes several different products. The company currently uses a plantwide allocation method for allocating overhead at a rate of $6 per direct labor...
-
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 .
-
In chapter 23, what did France's Financial Markets Authority give Socit Gnrale Bouton on January 20, 2008? Question 6 options: A) The authorization to implement the final adjustments necessary to...
-
The rule of 72: Multiple choice question. is so inaccurate it is rarely used. is an accurate calculation of the years needed to double. does not provide answers that are 100% accurate related to the...
-
The following formula is representative of the sales comparison approach: Sales Price of Comparable Property +/- Adjustments = Indicated Value of the Subject Property. true or false
Study smarter with the SolutionInn App