$SPAD/src/input heap.input

Timothy Daly December 3, 2016

Abstract

Contents

2

1 License

— license —

--Copyright The Numerical Algorithms Group Limited 1991.

———-

— * —

)set break resume
)spool heap.output
)set message test on
)set message auto off
)clear all
--S 1 of 8
h := heap [-4,9,11,2,7,-7]
--R
--R
--R   (1)  [11,7,9,- 4,2,- 7]
--R                                                          Type: Heap(Integer)
--E 1
--S 2 of 8
insert!(3,h)
--R
--R
--R   (2)  [11,7,9,- 4,2,- 7,3]
--R                                                          Type: Heap(Integer)
--E 2
--S 3 of 8
extract! h
--R
--R
--R   (3)  11
--R                                                        Type: PositiveInteger
--E 3
--S 4 of 8
h
--R
--R
--R   (4)  [9,7,3,- 4,2,- 7]
--R                                                          Type: Heap(Integer)
--E 4
--S 5 of 8
[extract!(h) while not empty?(h)]

--R
--R
--R   (5)  [9,7,3,2,- 4,- 7]
--R                                                          Type: List(Integer)
--E 5
--S 6 of 8
heapsort(x) == (empty? x => []; cons(extract!(x),heapsort x))
--R
--R                                                                   Type: Void
--E 6
--S 7 of 8
h1 := heap [17,-4,9,-11,2,7,-7]
--R
--R
--R   (7)  [17,2,9,- 11,- 4,7,- 7]
--R                                                          Type: Heap(Integer)
--E 7
--S 8 of 8
heapsort h1
--R
--R   Compiling function heapsort with type Heap(Integer) -> List(Integer)
--R
--R
--R   (8)  [17,9,7,2,- 4,- 7,- 11]
--R                                                          Type: List(Integer)
--E 8
)spool
)lisp (bye)

———-

References^{[1] nothing}

5