Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is for Dr Racket, i\'m not sure where to begin, so i possible please explai

ID: 669647 • Letter: T

Question

This is for Dr Racket, i'm not sure where to begin, so i possible please explain the answers to me

*NEEDS TO BE IN RACKET LANGUAGE*

Function 9 Write an even and an odd function. Each function is passed a list. The even function returns the list of elements at positions 2, 4 , 6, ... as a list. The odd function returns the list of elements at positions 1, 3, 5, ... as a list. For example (even (list 8 3 5 4 6 9 1)) would return the list (3 4 9) and (odd (list 8 3 5 4 6 9 1) would return the list (8 5 6 1).

Explanation / Answer

Code in racket for the same.

(define (oddevencheck lst)
(if (null? lst)
      (values '() '())
      (let-values (((odds evens) (oddevencheck (cdr lst))))
        (cond ((odd? (car lst)) (values (cons <???> <???>) <???>))
              ((even? (car lst)) (values <???> (cons <???> <???>)))
              (else (values odds evens))))))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote