Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

Create a Scheme function in-order? that consumes a list of numbers numlist and produces true if the numbers in the list appear in non-decreasing order and false otherwise. Non-decreasing 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.

Computer Science
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly


Get your free account and access expert answers to this and thousands of other questions

It'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 (in-order? numlist) (if (null? (cdr numlist) #t (if (> (car numlist) (cadr numlist)) #f (in-order? (cdr numlist)))))
Thank 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 (in-order numlist) (cond ((empty? numlist)true) ((>=(first numlist)(first (rest numlist)))true) ( (< (first numlist) (first(rest numlist)) ) false)))
Yeah, if I recall correctly, cond is an 'extended if' basically: (define (in-order? 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 (in-order? (cdr numlist)))))

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

oh i get that Thank you )

Not the answer you are looking for?

Search for more explanations.

Ask your own question