## CSci 1301: Lab 5

#### What to submit

The lab is done in groups of 2. In the beginning of each file please write (in comments) the names fo all group members.

At the end of the lab please send me and your group partner(s) all your Racket files as e-mail attachments. My e-mail is elenam at morris.umn.edu. The subject of your e-mail must be "1301 Lab 5" followed by "Final" or "Not final", depending on whether this is a final submission or you are still working on it. If you need to finish it, make sure to set up a time with your group partner(s) to finish the lab.

#### Task 1 (12 points)

Problems in this task do not require recursion. You may not use any list functions other than `first, rest, cons, empty?, list`. All functions must have signatures, descriptions, and check-expects.

Question 1 Write a function `has-one-element?` that, given a list, returns `#true` if the list has exactly one element and `#false` otherwise:

``````
(check-expect (has-one-element? (list 2 3 5 6)) #false)
(check-expect (has-one-element? empty) #false)
(check-expect (has-one-element? (list 2)) #true)
``````

Question 2 Write a function `has-more-than-one-element?` that, given a list, returns `#true` if the list has more than one element, and `#false` otherwise:

``````
(check-expect (has-more-than-one-element? (list 2 3 5 6)) #true)
(check-expect (has-more-than-one-element? empty) #false)
(check-expect (has-more-than-one-element? (list 2)) #false)
``````

Question 3 Write a function `order` that, given two numbers, returns a list of them in increasing order. If they are equal, the list just has these two numbers:

``````
(check-expect (order 2 5) (cons 2 (cons 5 empty)))
(check-expect (order 4 1) (cons 1 (cons 4 empty)))
(check-expect (order 2 2) (cons 2 (cons 2 empty)))
``````

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.