Anonymous user
Priority queue: Difference between revisions
→version 1: added/changed whitespace and comments, simplified the program and output.
m (Added Sidef) |
(→version 1: added/changed whitespace and comments, simplified the program and output.) |
||
Line 3,574:
=={{header|REXX}}==
===version 1===
Programming note: this REXX version allows any number (with or without decimals, say, 5.7) for the priority, including negative numbers. The priority number can be up to one hundred digits.
<lang rexx>/*REXX
numeric digits 100; #=0; @.= /*big #
say '══════ inserting tasks.'; call .ins 3 'Clear drains'
call .ins 4 'Feed cat'
Line 3,585:
call .ins 6 'Enjoy'
say '══════ showing tasks.'; call .show
say '══════ deletes top task.'; say .del()
exit /*stick a fork in
/*────────────────────────────────────────────────────────────────────────────*/
end /* [↑] do top first.*/▼
exit /*stick a fork in it, we're done.*/▼
/*────────────────────────────────────────────────────────────────────────────*/
.
/*────────────────────────────────────────────────────────────────────────────*/
.show: procedure expose @. #
do j=1 for #; _=@.j; if _=='' then iterate;
return
/*────────────────────────────────────────────────────────────────────────────*/
do j=1 for #; _=word(@.j,1); if _=='' then iterate
▲.top: procedure expose @. #; top=; top#=
return
'''output'''
<pre>
Line 3,619 ⟶ 3,616:
══════ deletes top task.
6 Relax
</pre>
|