1 ! Copyright (C) 2022 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: combinators generalizations kernel math sequences ;
6 MACRO: stack-nth ( n -- quot )
11 MACRO: stack-set-nth ( obj n -- quot )
12 '[ [ drop _ ] _ ndip ] ;
14 MACRO: stack-exchange ( m n -- quot )
15 [ [ stack-nth ] [ '[ _ stack-nth ] dip ] bi* ] 2keep
17 '[ _ _ stack-set-nth _ _ stack-set-nth ] ;
19 MACRO: stack-map ( n quot: ( obj -- obj' ) -- quot' )
20 '[ _ ] replicate '[ _ spread ] ;