Handbook
Glossary
find-nth-last-from ( nth from seq quot: ( obj -- ? ) -- i/f obj/f )
Vocabulary
sequences
.
extras
Inputs
nth
an
object
from
an
object
seq
an
object
quot
a
quotation
with stack effect
( obj -- ? )
Outputs
i/f
an
object
obj/f
an
object
Definition
USING:
kernel
math
sequences
shuffle
;
IN:
sequences.extras
:
find-nth-last-from
( nth from seq quot: ( obj -- ? ) -- i/f obj/f )
reach
0
<
[
[
neg
1
-
]
3dip
[
1
+
]
2dip
find-nth-from
]
[
[
0
]
4dip
[
2swap
[
call
]
2dip
rot
[
[
1
+
]
dip
2dup
>
]
[
f
]
if
]
curry
find-last-from
2nipd
]
if
;
inline
recursive