RACKET Scheme prog
$10-30 USD
Paid on delivery
list has two equal elements recursively in scheme
These are the elements initially pointed by REF and REST. If they are the same, we return #t. If not, we can make a recursive call on the list from which we have removed the second element (in Java, we change REST to [login to view URL] and by doing so we skip the second element pointed by REST). If the recursive call returns #t, the whole function returns #t. This recursive call will recursively compare the first element of the list with all subsequent elements by removing the elements that are not equal to the first element until the end of the list is reached. Otherwise (if the first recursive call fails), we need to make one more recursive call in which we delete the first element of the list (in Java, we change REF to [login to view URL], therefore skipping the first element). Obviously, the first element does not have a match if the first recursive call failed.
Examples
(two ‘(7 7)) returns #t
(two ‘(5 3 3 4)) returns #t
(two ‘(11 3 5 11)) returns #t
(two ‘(1 2 3 4 5 6 10)) returns #f
(two ‘(24 14 11 4 6)) returns #f
The whole solution must be packed in one recursive function two which must look as follows: (define two (lambda (list)
(cond
...
)))
In other words, you have to define a single COND statement. Nested COND statements are not
allowed.
Inside COND, you can use ONLY the following constructs: - null?
- car
- cdr
- cons
- else
- =
- #t
- #f
- two
- list
Project ID: #32192739
About the project
4 freelancers are bidding on average $25 for this job
HI..i am familiar and good at Racket/Scheme/Lisp programming and can help you write functions for completing a puzzle or any problem using DrRacket.
- previous experience in such topics ; - eager to discuss a lot in this chat stream; - degree stats -maths ;