Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help for Racket Write a mutually recursive function named (n-list? obj) that takes one argument, which can be any Racket value. n-list? returns true if
Help for Racket
- Write a mutually recursive function named (n-list? obj) that takes one argument, which can be any Racket value. n-list? returns true if and only if obj is an n-list. For example:
> (n-list? '(2019 2015 2011)) #t > (n-list? '(1 (2 (3 4) 5) 6)) #t > (n-list? '(1 (2 (3 a) 5) 6)) ; oops, there's an 'a #f
n-list? should be mutually recursive with the function num-expr?, which returns true if its argument is a number expression and false if not. Even though the argument to this function can be any Racket object, you can still use the definition of n-list to design your function. An n-list must either be an empty list or a pair whose first is a number-expression and whose rest is an n-list. Similarly for number expressions. So your functions must follow the definition in order to tell if their arguments do!
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