Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

;; Dating apps like Tinder and Bumble have become very popular ;; in recent years. Most of these apps allow users to specify their ;;

;; Dating apps like Tinder and Bumble have become very popular ;; in recent years. Most of these apps allow users to specify their ;; name, age, and bio (interests) on their profile. By interacting ;; with other profiles, users can "match" with other users that ;; are interested in them. ;; ;; For Problem Set 5, you will be working with a simplified version of ;; a dating app. Like any program, the first thing to think about is how to ;; represent the user information as data - specifically how to represent ;; a single user as data. ;; ;; For this problem set, each user has a name, age, a list of ;; interests, and a list of other users that they have matched with. ;; ;; Please carefully read through the data definition for a user provided ;; for you below. You should get out a pen and paper to trace out which ;; users match which other users to better visualize the structure of ;; users given in the examples below. ;;

(@htdd User ListOfUser ListOfString) (define-struct user (name age interests matches)) ;; User is (make-user String Natural ListOfString ListOfUser) ;; interp. a user with a name, age, list of interests and a list ;; of others users they have matched with

;; ListOfUser is one of: ;; - empty ;; - (cons User ListOfUser) ;; interp. a list of users

;; ListOfString is one of: ;; - empty ;; - (cons String ListOfString) ;; interp. a list of strings

(define LOS0 empty) (define LOS1 (list "Travelling")) (define LOS2 (list "Cats" "Politics" "Soccer"))

(define LOU0 empty) (define U0 (make-user "Xavier Maxwell" 20 (list "Drawing" "Dogs") empty)) (define U1 (make-user "Sarah Jackson" 19 (list "Cooking" "Rock Music" "Reading") empty)) (define U2 (make-user "Ling Xu" 18 (list "Writing" "Video Games" "Canoeing") empty))

(define LOU1 (list U1 U2)) (define U3 (make-user "Mark Davidson" 17 (list "Volunteering" "Cats" "Singing") LOU1)) (define U4 (make-user "Ella Mason" 30 (list "Painting" "Dogs" "Fashion") (list U3)))

(define U5 (make-user "Ora Jacobson" 20 (list "Gambling" "Comedy" "Video Games" "Cars") empty)) (define U6 (make-user "Sam Hu" 28 (list "Programming" "Dogs" "Surfing" "Piano") empty)) (define U7 (make-user "Mandy Wilson" 17 (list "Gymnastics" "Theatre" "Pizza") empty)) (define U8 (make-user "James Ploshynsky" 45 (list "Ice Hockey" "Cars" "Dogs" "Country Music") (list U5 U6 U7))) (define U9 (make-user "Julia Short" 18 (list "Drawing" "Rap Music" "Cars") (list U0 U4 U8)))

#; (define (user u) (... (user-name u) (user-age u) (fn-for-los (user-interests u)) (fn-for-lou (user-matches u))))

(define (fn-for-lou lou) (cond [(empty? lou) (...)] [else (... (fn-for-user (first lou)) (fn-for-lou (rest lou)))]))

(define (fn-for-los los) (cond [(empty? los) (...)] [else (... (first los) (fn-for-los (rest los)))]))

;; ;; Dating app users may be curious how many people their matches are ;; talking to. ;; ;; Design a function called count--user that consumes a user, and ;; produces a count of the number of others users reachable from that ;; user by going through all of their matches and their matches' matches, etc. ;; ;; Remember that for all functions operating on mutually referential types ;; you must group your function definitions in the new way.

(@htdf count--user count--lou)

;; Perhaps we want to try and present users with other users ;; who have the same interests as them. ;; ;; Design a function called has-interest--user that consumes a user and an ;; interest, and produces a list of names of users with that interest. ;; ;; FYI, there is a built-in function called member that consumes ;; a String and ListOfString and produces true if the String is ;; in the list. (@problem 2) (@htdf has-interest--user has-interest--lou)

;; Perhaps we want to know if a certain user exists in ;; another user's "network". ;; ;; Design a function called find-user--user that consumes a ;; user and a name. ;; Search the given user and all their matches for a user with the ;; given name, and if found, produce that user. (@problem 3) (@htdf find-user--user find-user--lou)

-Use DrRacket program in BSL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago