Respuesta :
We can use the code for IntPQ to implement the priority queue construction:
functor PQUEUE(type Item
val > : Item * Item -> bool
):QueueSig =
struct
type Item = Item
exception Deq
fun insert e [ ] = [e]:Item list
| insert e (h :: t) =
if e > h then e :: h :: t
else h :: insert e t
abstype Queue = Q of Item list
with
val empty = Q []
fun isEmpty (Q []) = true
| isEmpty _ = false
fun enq(Q q, e) = Q(insert e q)
fun deq(Q(h :: t)) = (Q t, h)
| deq _ = raise Deq
end
end;
What is SML?
The capital asset pricing model (CAPM), which displays varying levels of systematic, or market risk, of various marketable securities plotted against the projected return of the entire market at any one time, is represented graphically by the security market line (SML), a line drawn on a chart.
- The supplied predicate, which we consider to be a total ordering, can be used as the priority order in a priority queue.
- The end result is a structure with a new type for the queue and a number of operations that work with it.
- We create a new structure from a group of types and values (a structure), and we represent this creation as an ML functor.
- A functor takes a structure and produces a new structure, much as how a function takes a value and makes a new value.
- To accomplish the formation of the priority queue, we can utilize the IntPQ code.
Learn more about SML here https://brainly.com/question/15901527
#SPJ10