Question
Implement rotate command in DrRacket using only #| Here are some useful built-in list functions, where L is a list and E is some element:
Implement rotate command in DrRacket using only
#| Here are some useful built-in list functions, where L is a list and E is some element: | (null? L) returns #t if L is empty, otherwise #f. | (length L) returns the number of elements in L. | (reverse L) returns L in reverse order. | (cons E L) returns L with E added to the front of the list. | (append L1 L2) returns a list of L1 followed by L2. | (car L) returns the first element of L. It throws an exception when given an empty list. | (cdr L) returns the tail [everything but the first element] of L. It throws an exception when given an empty list.
| Examples: | (rotate '(0 1)) -> ((0 1) (-1 0) (0 -1) (1 0)) | (rotate '(2 3)) -> ((2 3) (-3 2) (-2 -3) (3 -2)) | (rotate '(-5 7)) -> ((-5 7) (-7 -5) (5 -7) (7 5)) |#
;; Type signature: (rotate (int int)) -> ((int int) (int int) (int int) (int int)) ;; 2 PTS (define (rotate c) #implement.code.here)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started