Handbook
Glossary
ppop ( seq -- seq' )
Persistent sequence protocol
Prev:
ppush ( val seq -- seq' )
Vocabulary
persistent
.
sequences
Inputs
seq
a
sequence
Outputs
seq'
a
sequence
Generic word contract
Persistent analogue of
pop*
. Outputs a new sequence with all elements of
seq
except for the final element.
Definition
IN:
persistent.sequences
GENERIC:
ppop
( seq -- seq' )
Methods
USING:
accessors
combinators
kernel
math
persistent.sequences
persistent.vectors
persistent.vectors.private
sequences
;
M:
persistent-vector
ppop
dup
count>>
{
{
0
[
empty-error
]
}
{
1
[
drop
PV{
}
]
}
[
[
clone
dup
tail>>
children>>
length
1
>
[
ppop-tail
]
[
ppop-new-tail
]
if
]
dip
1
-
>>count
]
}
case
;
USING:
persistent.sequences
sequences
;
M:
sequence
ppop
but-last
;
USING:
accessors
kernel
math
persistent.sequences
sequences
vlists
;
M:
vlist
ppop
[
empty-vlist-error
]
[
[
length>>
1
-
]
[
vector>>
]
bi
vlist
boa
]
if-empty
;