June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*REXX program implements a priority queue; with insert/display/delete the top task. */
|
||||
#=0; @.= /*0 tasks; nullify the priority queue.*/
|
||||
/*REXX program implements a priority queue with insert/display/delete the top task.*/
|
||||
#=0; @.= /*0 tasks; nullify the priority queue.*/
|
||||
say '══════ inserting tasks.'; call .ins 3 "Clear drains"
|
||||
call .ins 4 "Feed cat"
|
||||
call .ins 5 "Make tea"
|
||||
|
|
@ -11,16 +11,12 @@ say '══════ showing tasks.'; call .show
|
|||
say '══════ deletes top task.'; say .del() /*delete the top task. */
|
||||
exit /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
.del: procedure expose @. #; parse arg p; if p=='' then p=.top(); x=@.p; @.p=; return x
|
||||
/*delete the top task entry. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
.del: procedure expose @. #; arg p; if p='' then p=.top(); y=@.p; @.p=; return y
|
||||
.ins: procedure expose @. #; #=#+1; @.#=arg(1); return # /*entry, P, task.*/
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
.show: procedure expose @. #; do j=1 for #; _=@.j; if _=='' then iterate; say _; end
|
||||
return /* [↑] show whole list or just one. */
|
||||
.show: procedure expose @. #; do j=1 for #; _=@.j; if _\=='' then say _; end; return
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
.top: procedure expose @. #; top=; top#=
|
||||
do j=1 for #; _=word(@.j,1); if _=='' then iterate
|
||||
if top=='' | _>top then do; top=_; top#=j; end
|
||||
do j=1 for #; _=word(@.j, 1); if _=='' then iterate
|
||||
if top=='' | _>top then do; top=_; top#=j; end
|
||||
end /*j*/
|
||||
return top#
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue