Handbook
Glossary
(node>subalist) ( from-key to-key node start-comparator: ( key1 key2 -- ? ) end-comparator: ( key1 key2 -- ? ) -- )
Vocabulary
trees
.
private
Inputs
from-key
an
object
to-key
an
object
node
an
object
start-comparator
a
quotation
with stack effect
( key1 key2 -- ? )
end-comparator
a
quotation
with stack effect
( key1 key2 -- ? )
Outputs
None
Definition
USING:
accessors
kernel
;
IN:
trees.private
::
(node>subalist)
( from-key to-key node start-comparator: ( key1 key2 -- ? ) end-comparator: ( key1 key2 -- ? ) -- )
node
[
node
key>>
from-key start-comparator
call
:>
node-right? node
key>>
to-key end-comparator
call
:>
node-left? node-right?
[
from-key node
left>>
node-left?
[
start-comparator
(node>subalist-left)
]
[
[
to-key
]
dip
start-comparator end-comparator
(node>subalist)
]
if
]
when
node-right? node-left?
and
[
node
entry,
]
when
node-left?
[
to-key node
right>>
node-right?
[
end-comparator
(node>subalist-right)
]
[
[
from-key
]
2dip
start-comparator end-comparator
(node>subalist)
]
if
]
when
]
when
;
inline
recursive