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 :...
-
The net promoter score (NPS) is a key indicator of customer satisfaction and loyalty. Use data on employees in the software product group with a college degree to develop the logistic regression...
-
Diagnostic Services Inc. (DSI) is a new company. It has been in business for only one year, offering diagnostic services to physicians in the Tampa/St. Petersburg, Miami, and Orlando markets. DSI...
-
1. You are in charge of strategic planning for Grand Casinos. The company wants to open and manage a casino in rural Iowa. Community residents have asked you and your strategic planning team to...
-
Clair is a soccer player that just signed a 3-year contract with a new team. The contract will pay her as follows: $58,000 today $67,000 at the end of year 1 $73,000 at the end of year 2 $89,000 at...
-
Which of the graphs in Fig. Q25.12 best illustrates the current I in a real resistor as a function of the potential difference V across it? Explain. Figure Q25.12 (a) (b) (c) (d)
-
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?
-
The momentum of an object with mass m and speed v is p = mv. A photon has zero mass, so it should have zero momentum. Correct or incorrect?
-
At a minimum, your Word report and PPT presentation should include: the names of all team members who contributed to the work, the date of your analysis; a table of contents (PPT agenda); an overview...
-
Caesar's information system can be used to access whether the placement of slot machines affects profitability. Who would use this information?
-
ABC corporation is manufacturing one product and uses standard cost system to evaluate performance. The manager who is responsible of buying the needed quantity of raw materials was able to buy a...
-
Canadian Tire purchases BBQ accessories from several different wholesellers/manufacturers. When the BBQ accessories arrive at CT distribution centres, containers are reduced to amounts that are...
-
Who of you have worked in an environment where there are high expectations and management has expected you to perform at the same level as more seasoned employees? When this is a nurse on the floor...
-
Redfern Limited reported the following information in its December 31, 2013, annual report: Shareholders' Equity Preferred shares, $2.75, cumulative; 600,000 shares authorized; 100,000 shares issued...
-
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 .
-
You observe the price of a latte changes from $4 to $5. Instructions: Round your answer to one decimal place. If you are entering a negative number include a minus sign. a. What is the percentage...
-
Layer 2 switches work at a simple level for communication and switching. With technology advancing and routers being able to make more complex decisions, why is this method still used?
-
Explore the significance of intermedial allusions in multimedia storytelling, such as in graphic novels or hypertext fiction, and their implications for narrative coherence and interpretation.
Study smarter with the SolutionInn App