The Maple computer algebra system has a command seq(f, i = m..n, step), which re
ID: 3661666 • Letter: T
Question
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.
Explanation / Answer
Good wishes,
seq( seq( ( if( ( ( start+n*step ) <= end) , (start+n*step) , exit(1) ) ) , (start, step,end)), (1,1,n) )
here a seq is embedded inside a sequence
the outer sequence produces sequence of integers (1,2,3,4,....) and each value is given as input to inner sequence.
the inner sequence uses this value and the values of start,step and end to evaluate the sequence
start + n*step
this sequence stops when
start + n*step > end
then it just exits
Hope this is clear.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.