Ditutup

Scheme Movie Queue Program

Write a set of Scheme definitions that implement a “movie queue”. A movie queue is a S list of movies each with a priority value that indicates the priority in which you wish to view the movie.( e.g. Netflix queue for sending DVDs to user) You can add and remove movies. You can change the priority value of the movie. If your movie queue has n movies, then the priority values of the movies in your queue must be an integer from 1 to n with no priority value used twice. You are not implementing a data structure queue but rather a list of movies with priorities. Implement and test each of the following functions.

List example:

( (“Star Wars”, 1 ) ( “Revenant” 2) ( “Zootopia” 3 ) ( “Creed” 4) (“Anomalisa” 5) )

Write the following Scheme functions:

a. (name m) // returns the name of the movie m

b. (priority m ) //returns the priority of the movie m

c. (compare m1 m2) returns #t if movie m1 has a lower priority than movie m2. Otherwise return #f.

d. Check that (sort qlst compare ) returns a sorted version of the input movie queue by priority order.

e. (printMovie m ) //prints the movie m

Example: ( “StarWars” 1) will be printed as Star Wars : 1

f. (printQueue qlst ) // prints the movie queue qlst using printMovie. The movies should be printed one movie per line.

g. ( memberMQ? s qlst) // Checks if s is the name of a movie in the movie queue qlst.

Example:

( memberMQ? “Zootopia”

( (“Star Wars”, 1 ) ( “Revenant” 2) ( “Zootopia” 3 ) ) ) returns #t.

h. (getPriority s qlst) returns the priority of the movie named s in qlst. Return #f is s is not in qlst.

Example:

(getPriority “abc” ‘( (“abc” 1) ( “qwerty” 2 ) ( “bobby” 3)) ) returns 1

i. (getName k qlst) returns the name of the movie in qlst with priority k. Return #f if k is out of range.

Example:

(getname 3 ‘( (“abc” 1) ( “qwerty” 2 ) ( “bobby” 3)) ) returns “bobby”

j. (removeByPriority k qlst ) // removes the movie with priority k and updates the priorities of the movies on the list to reflect that the kth priority movie has been removed. Returns the updates list. If no movie has priority k, just return qlst.

Example:

( removeByPriority 2 ‘( (“abc” 1) ( “qwerty” 2 ) ( “bobby” 3)) ) returns

‘( (“abc” 1) ( “bobby” 2) )

k. (removeByName s qlst ) removes the movie with name s and updates the priorities of the movies on the list to reflect that the kth priority movie has been removed. Returns the updates list. If s is not in the list, just return qlst.

Example:

( remove “qwerty” ‘( (“abc” 1) ( “qwerty” 2 ) ( “bobby” 3)) ) returns

‘( (“abc” 1) ( “bobby” 2) )

l. (addMQ s qlst) adds a movie with name s to qlst. It gives this movie the last priority.

Example:

( addMQ “Carol” ( (“Star Wars”, 1 ) ( “Revenant” 2) ( “Zootopia” 3 ) ) ) returns ( (“Star Wars”, 1 ) ( “Revenant” 2) ( “Zootopia” 3 ) (“Carol” 4) )

m. (insertMQ s k qlst) adds a movie (list s k ) to qlist and updates the priorities of the other movies on the list. If the priority is out of range then give the movie the last priority.

Example

( insertMQ “orange” 3 ‘ ( (“Star Wars”, 1 ) ( “Revenant” 2) ( “Zootopia” 3 ) (“Carol” 4) )

returns

( (“Star Wars”, 1 ) ( “Revenant” 2) (“orange” 3) ( “Zootopia” 4 ) (“Carol” 5) )

n. (updatePriority s k qlst) changes the priority of movie with name s to priority q. Updates qlst to reflect new priorities. If s is not in qlst or if k is out of range, return qlst.

Example:

(updatePriority “redmoon” 2 ‘( (“bluemoon” 1 ) (“augustmoon” 2) ( “redmoon” 3)) returns ‘( (“bluemoon” 1 ) (“redmoon” 2) ( “augustmoon” 3) )

o.(validMQ? z) Checks to see if z satisfies the definition and rules of a movie queue.

Full instructions given to winner.

Note: I already did the first half of the functions. Those do not need to be done, and will be provided.

Kemahiran: Scheme

Lihat lagi: sorted data set, set data structure, queue program in data structure, queue in data structure with example, queue in data structure, queue definition in data structure, queue data structure in c, queue data structure, priority queue program in data structure, priority queue in data structure with example, priority queue example in data structure, g star, definition of priority queue in data structure, definition of data structure in c, data structure sort, data structure set, data structure definitions, data structure definition, menu driven program queue using linked list, program adding large integers using array

Tentang Majikan:
( 3 ulasan ) Northridge, United States

ID Projek: #10111997

4 pekerja bebas membida secara purata $49 untuk pekerjaan ini

ahmsak

Hello Sir... I am a computer science tutor, I teach (among others) Scheme and Algorithms. I have done many projects like this, and I'm one of the top Scheme developers, you can check here please: [login to view URL] Lagi

$100 USD dalam sehari
(7 Ulasan)
4.1
briandawney

I did it, it took me all morning : )) I have to write 100 chars, la la la la la, lalala, lalala, (define (consecutive-ns? ns) (letrec ((consecutive? (lambda (a b) (= 1 Lagi

$35 USD dalam sehari
(0 Ulasan)
0.0
carneireiro

I understood what the required functions must return and have scheme knowledge to write them. I don't work with scheme at my day job, it's more around C# and VB.net. Despite that, having read the project description th Lagi

$30 USD dalam sehari
(0 Ulasan)
0.0
Domus123

HI , my name is Lucas Guerra . I'm a computer Engineering student in Federal University of Uberlândia - Brazil I have been working with Scheme/Racket and Common Lisp for a while in my lab (Natural and Artificial int Lagi

$30 USD dalam sehari
(0 Ulasan)
0.0