A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 4 years ago
Create a Scheme function inorder? that consumes a list of numbers numlist and
produces true if the numbers in the list appear in nondecreasing order and false
otherwise. Nondecreasing order means each number in the list is not smaller than the
previous number in the list. Your function will produce true for a list of length 0 or
1. Numbers in the list can be repeated as long as they appear consecutively.
anonymous
 4 years ago
Create a Scheme function inorder? that consumes a list of numbers numlist and produces true if the numbers in the list appear in nondecreasing order and false otherwise. Nondecreasing order means each number in the list is not smaller than the previous number in the list. Your function will produce true for a list of length 0 or 1. Numbers in the list can be repeated as long as they appear consecutively.

This Question is Closed

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0It's been waaay too long since I last used Scheme, but I think this is good approximation to the answer, maybe a few minor tweaks could make it right? Hopefully it points you in the right direction. (define (inorder? numlist) (if (null? (cdr numlist) #t (if (> (car numlist) (cadr numlist)) #f (inorder? (cdr numlist)))))

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Thank u very much. But i didn get that. becuase i am new in scheme and our prof said that in assignment we can just use what we learned from lecture. but i am completely lost in it. Is there any way to do this with cond? can this be fine? (define (inorder numlist) (cond ((empty? numlist)true) ((>=(first numlist)(first (rest numlist)))true) ( (< (first numlist) (first(rest numlist)) ) false)))

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0Yeah, if I recall correctly, cond is an 'extended if' basically: (define (inorder? numlist) (cond ((empty? (cdr numlist)) #t) //if 'empty?' doesn't work, try with 'null?' ((> (car numlist) (cadr numlist)) #f) //i don't recall a 'first', but 'car' retrieves first element of a list (else (inorder? (cdr numlist)))))

anonymous
 4 years ago
Best ResponseYou've already chosen the best response.0oh i get that Thank you )
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.