tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
27
Task/Priority-queue/Axiom/priority-queue-1.axiom
Normal file
27
Task/Priority-queue/Axiom/priority-queue-1.axiom
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
)abbrev Domain ORDKE OrderedKeyEntry
|
||||
OrderedKeyEntry(Key:OrderedSet,Entry:SetCategory): Exports == Implementation where
|
||||
Exports == OrderedSet with
|
||||
construct: (Key,Entry) -> %
|
||||
elt: (%,"key") -> Key
|
||||
elt: (%,"entry") -> Entry
|
||||
Implementation == add
|
||||
Rep := Record(k:Key,e:Entry)
|
||||
x,y: %
|
||||
construct(a,b) == construct(a,b)$Rep @ %
|
||||
elt(x,"key"):Key == (x@Rep).k
|
||||
elt(x,"entry"):Entry == (x@Rep).e
|
||||
x < y == x.key < y.key
|
||||
x = y == x.key = y.key
|
||||
hash x == hash(x.key)
|
||||
if Entry has CoercibleTo OutputForm then
|
||||
coerce(x):OutputForm == bracket [(x.key)::OutputForm,(x.entry)::OutputForm]
|
||||
)abbrev Domain PRIORITY PriorityQueue
|
||||
S ==> OrderedKeyEntry(Key,Entry)
|
||||
PriorityQueue(Key:OrderedSet,Entry:SetCategory): Exports == Implementation where
|
||||
Exports == PriorityQueueAggregate S with
|
||||
heap : List S -> %
|
||||
setelt: (%,Key,Entry) -> Entry
|
||||
Implementation == Heap(S) add
|
||||
setelt(x:%,key:Key,entry:Entry) ==
|
||||
insert!(construct(key,entry)$S,x)
|
||||
entry
|
||||
7
Task/Priority-queue/Axiom/priority-queue-2.axiom
Normal file
7
Task/Priority-queue/Axiom/priority-queue-2.axiom
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
pq := empty()$PriorityQueue(Integer,String)
|
||||
pq(3):="Clear drains";
|
||||
pq(4):="Feed cat";
|
||||
pq(5):="Make tea";
|
||||
pq(1):="Solve RC tasks";
|
||||
pq(2):="Tax return";
|
||||
[extract!(pq) for i in 1..#pq]
|
||||
3
Task/Priority-queue/Axiom/priority-queue-3.axiom
Normal file
3
Task/Priority-queue/Axiom/priority-queue-3.axiom
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[[5,"Make tea"], [4,"Feed cat"], [3,"Clear drains"], [2,"Tax return"],
|
||||
[1,"Solve RC tasks"]]
|
||||
Type: List(OrderedKeyEntry(Integer,String))
|
||||
Loading…
Add table
Add a link
Reference in a new issue