Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,22 @@
/*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"
call .ins 1 "Solve RC tasks"
call .ins 2 "Tax return"
call .ins 6 "Relax"
call .ins 6 "Enjoy"
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 @. #; 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 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
end /*j*/
return top#

View file

@ -0,0 +1,42 @@
/*REXX pgm implements a priority queue; with insert/show/delete top task*/
n=0
task.=0 /* for the sake of task.0done.* */
say '------ inserting tasks.'; call ins_task 3 'Clear drains'
call ins_task 4 'Feed cat'
call ins_task 5 'Make tea'
call ins_task 1 'Solve RC tasks'
call ins_task 2 'Tax return'
call ins_task 6 'Relax'
call ins_task 6 'Enjoy'
say '------ Showing tasks.'; call show_tasks
say '------ Show and delete top task.'
todo=n /* tasks to be done */
do While todo>0
Say top()
End
exit
ins_task: procedure expose n task.
n=n+1
Parse Arg task.0pri.n task.0txt.n
Return
show_tasks: procedure expose task. n
do i=1 To n
Say task.0pri.i task.0txt.i
End
Return
top: procedure expose n task. todo /* get top task and mark it 'done' */
high=0
Do i=1 To n
If task.0pri.i>high &,
task.0done.i=0 Then Do
j=i
high=task.0pri.i
End
End
res=task.0pri.j task.0txt.j
task.0done.j=1
todo=todo-1
return res