Using Lambda
The goal of this assignment is to give you practice with lambda and built-in list abstractions.
Requirements
-
Use the ISL+Lambda language
-
Do not use
local
-
Do not define helper functions with
(define ...)
-
Do not use
require
However, you may use lambda
and any function that is built-in to
ISL+ (documentation).
Data Designs
Use the following data designs in your code, and do not modify them.
;; A CallType is one of:
;; - "zoom"
;; - "teams"
;; - "phone"
;; Interpretation: a type of call
(define CT-ZOOM "zoom")
(define CT-TEAMS "teams")
(define CT-PHONE "phone")
(define (calltype-temp ct)
(cond
[(string=? ct CT-ZOOM) ...]
[(string=? ct CT-TEAMS) ...]
[(string=? ct CT-PHONE) ...]))
(define-struct call [type duration attendees description])
(define-struct mtg [duration attendees description])
(define-struct alone [duration description])
;; An Event is one of:
;; - (make-call CallType PosInt [NEList-of String] String)
;; - (make-mtg PosInt [NEList-of String] String)
;; - (make-alone PosInt String)
;; Interpretation: an event in some period of time, which is either:
;; - A call using some technology, lasting some number of minutes with attendees
;; (by name), and a description;
;; - An in-person meeting lasting some number of minutes
;; with attendees (by name) and a description; or
;; - Time spent alone for some number of minutes with a description.
(define E-ZOOM-DOC
(make-call CT-ZOOM 22 (list "Dr. Zoidberg")
"Doctor appointment about a stomach ache after some bad seafood :("))
(define E-TEAMS-OH
(make-call CT-TEAMS 7 (list "Mike" "Tajel")
"Office hours with my partner to ask clarifying questions about the Design Recipe!"))
(define E-PHONE-SPAM
(make-call CT-PHONE 1 (list "Unknown")
"Who calls!? I think it was a scam..."))
;; These are characters from a TV show called "Friends", which was popular in
;; the 90s, which is when many of your instructors grew up.
(define E-MTG-STUDY
(make-mtg 62 (list "Rachel" "Ross" "Joey" "Phoebe" "Chandler" "Monica")
"Getting ahead on studying for Exam 2!"))
(define E-MTG-ADVISOR
(make-mtg 28 (list "Ali")
"Meeting with advisor to talk about a combined major"))
(define E-ALONE-LUNCH
(make-alone 34 "Lunch"))
(define E-ALONE-READING
(make-alone 25 "The Three-Body Problem isn't going to read itself!"))
(define LOE-1
(list E-ZOOM-DOC E-ALONE-READING E-PHONE-SPAM
E-ALONE-LUNCH E-TEAMS-OH E-MTG-ADVISOR E-MTG-STUDY))
(define (e-temp e)
(cond
[(call? e)
(... (calltype-temp (call-type e)) ...
(call-duration e) ...
(los-temp (call-attendees e)) ...
(call-description e) ...)]
[(mtg? e)
(... (mtg-duration e) ...
(los-temp (mtg-attendees e)) ...
(mtg-description e) ...)]
[(alone? e)
(... (alone-duration e) ...
(alone-description e) ...)]))
Problems
-
Design the function
weekend
that reminds you to rest. The function consumes an argument – a positive integer – and produces a list of that many alone events. Each of these is 30mins each, with the description “rest”.;; weekend : PosInt -> [NEList-of Event] ;; produces a list of 30min rest alone events of a supplied size
-
Design the function
small-group
that consumes a list of events and only produces those that have fewer than three participants. In all cases, there is an implied attendee (you!) that counts as one person. So, calls and meetings with two or more attendees are not small groups.;; small-group : [List-of Event] -> [List-of Event] ;; produces the list of only those events that have up to 3 participants ;; (including the implied author).
-
Design the function
had-lunch?
that accepts a list of events and determines if it contains an event whose description contains the word"lunch"
(without regard for upper/lower-case).;; had-lunch? : [List-of Event] -> Boolean ;; Is there an event containing the word lunch?
-
Design the function
social-time
that accepts a list of events and produces the total minutes spent on calls or meetings.;; social-time : [List-of Event] -> PosInt ;; how much time was spent on calls and meetings?
-
Design the function
anything-but-phone?
that accepts a list of events and and produces#true
if none of the calls were phone calls. (Zoom and Teams calls are not phone calls.);; anything-but-phone? : [List-of Event] -> Boolean ;; makes sure there were no phone calls
-
Design the function
peeps
that accepts a list of events and produces an alphabetically sorted list of attendees at all the calls/meetings (including any duplicates).;; peeps : [List-of Event] -> [List-of String] ;; alphabetized list from all event attendees