This is done in racket/scheme. *Cannot use the built-in map function The Maple c
ID: 3661692 • Letter: T
Question
This is done in racket/scheme. *Cannot use the built-in map function
The Maple computer algebra system has a command seq(f, i = m..n, step), which returns the sequence fm,...,fnfm,...,fn, where fifi is the expression f with all occurrences of the symbol i replaced by the numeric value of i in the sequence of integers from m to n.
Implement a scheme function (seq f (start step end)) which produces a list of values (f(start),f(start+step),...,f(start+n*step)), where n is the largest integer such that start+n×stependstart+n×stepend and start+(n+1)×step>endstart+(n+1)×step>end.
Example:
You may not use the built-in map function.
(define (seq f rlist)
.........
Explanation / Answer
Answer:
(define (seq f rlist)
(let loop ((k (list-ref rlist 1)))
(cond ((< k (list-ref rlist 3))
(f k)
(loop (+ k (list-ref rlist 2)))))))
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.