Question

Define a scheme procedure that produces a sequence of even integers in a given range. For...

Define a scheme procedure that produces a sequence of even integers in a given range.

For example, (enum-interval 1 10) returns ( 2 4 6 8)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Algorithm to produce a sequence of even integers in given range.

Step 1: Read the starting value and ending value of the range and define a list as required_list

Step 2: FOR number=starting value to ending value

Step 3: calculate number_val = number%2

Step 4: IF(number_val==0) add number to required list

Step 5: ENDIF

Step 6: ENDFOR

Step 7: return the required_list(This contains the even numbers)

When we print the required_list it will produce the sequence of even integers in a given range.

I hope you got the answer and understand it.

Thank you:):)

Add a comment
Know the answer?
Add Answer to:
Define a scheme procedure that produces a sequence of even integers in a given range. For...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ Given a sequence of integers, check to see if the sequence constitutes a heap Input:...

    C++ Given a sequence of integers, check to see if the sequence constitutes a heap Input: the first line is an integer n(0 < n < 10000), The second line is n integers Output: If the sequence is a very small heap, that is, the top of the heap is the smallest element, then output "min heap". If the sequence is a very large heap, the top of the heap is the largest element The output includes one line with...

  • 2. Write a scheme function get-even-nums that accepts a list of numbers and returns a new...

    2. Write a scheme function get-even-nums that accepts a list of numbers and returns a new list that contains only the even numbers. (Hint: use reminder function) Sample runs: (get-even-nums ‘(1 2 3 4 5 6 7 8 9)) should return (8 6 4 2). (get-even-nums ‘(1 3 5 7 9)) should return ’( ).

  • Language in Scheme e. (5 marks] Create a procedure (decreasing L) that returns a list of...

    Language in Scheme e. (5 marks] Create a procedure (decreasing L) that returns a list of all of the consecutive decreasing subseqeuences in the input list. E.g., (decreasing (3 6 8 9 7 4 8 6 3)) + ((974) ( (decreasing '(7 6 5 4 8 5 2 5 1 5 2 1)) + (( 7 (decreasing '(1 2 3 4 5)) () 4) (8 6 3) (63)) 5 4)(654) (54)(8 5 2)(5 2) (5 1) (5 2 1) (2...

  • SCHEME [3 marks] Define a procedure called days_in_month that takes as arguments two numbers representing a...

    SCHEME [3 marks] Define a procedure called days_in_month that takes as arguments two numbers representing a month and a year. The procedure should return the number of days in the given month. Note: the procedure should account for leap years. You may assume valid month and year values are passed in as arguments. E.g. (days_in_month 9 2019) → 30 E.g. (days_in_month 2 2019) → 28 E.g. (days_in_month 2 2020) → 29

  • Implement function allEven() that takes a list of integers and returns True if all integers in...

    Implement function allEven() that takes a list of integers and returns True if all integers in the list are even, and False otherwise. >>> allEven([8, 0, -2, 4, -6, 10]) True >>> allEven([8, 0, -1, 4, -6, 10]) False

  • (20 points) You are given an array A of distinct integers of size n. The sequence...

    (20 points) You are given an array A of distinct integers of size n. The sequence A[1], A[2], ..., A[n] is unimodal if for some index k between 1 and n the values increase up to position k and then decrease the reminder of the way until position n. (example 1, 4, 5, 7, 9, 10, 13, 14, 8, 6, 4, 3, 2 where the values increase until 14 and then decrease until 1). (a) Propose a recursive algorithm to...

  • 1. The famous Fibonacci sequence f1, f2, f3, . . . is defined as f1 =...

    1. The famous Fibonacci sequence f1, f2, f3, . . . is defined as f1 = 1, f2 = 1 fn = fn−1 + fn−2, for n > 2 So the sequence begins as 1, 1, 2, 3, 5, 8, 13, 21, 34, . . .. Define a recursive function int fibonacci(int n) which returns the n-th Fibonacci number 2. Define recursive function my_sequence(n) which returns the n-th member of the sequence a1 = 3, a2 = 5, a3 =...

  • In Java IntegerStream: An integer stream produces a continuous sequence of integers, starting at some initial...

    In Java IntegerStream: An integer stream produces a continuous sequence of integers, starting at some initial integer. Each subsequence integer produced should be one more than the previous integer. The class will need the following methods and constructors: The constructor takes an integer that represents the first value returned by the stream. next(): Takes no input and returns the next value of the stream starting at the initial value. Each time next is called, the number returned should be one...

  • Let S be a sequence of n distinct integers stored in an array as array elements...

    Let S be a sequence of n distinct integers stored in an array as array elements S[1], S[2], · · · , S[n]. Use the technique of dynamic programming to find the length of a longest ascending subsequence of entries in S. For example, if the entries of S are 11, 17, 5, 8, 6, 4, 7, 12, 3, then one longest ascending subsequence is 5, 6, 7, 12. Specifically: (a) define a proper function and find the recurrence for...

  • In racket language, define a procedure named build-naturals that returns the list (list 0 .. (-...

    In racket language, define a procedure named build-naturals that returns the list (list 0 .. (- n 1)) for any natural number n. Example: (build-naturals 5) returns (0 1 2 3 4).. The procedure must call build-list. The procedure passed to build-list must be a lambda expression, not a named procedure

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT