Add mnswap macro

db4
Slava Pestov 2008-11-27 21:07:50 -06:00
parent 95bf38f5ee
commit 5402162df5
2 changed files with 7 additions and 0 deletions

View File

@ -38,3 +38,7 @@ IN: generalizations.tests
[ "a" ] [ { "a" } 1 firstn ] unit-test
[ [ 1 2 ] ] [ 1 2 2 [ ] nsequence ] unit-test
[ 4 5 1 2 3 ] [ 1 2 3 4 5 2 3 mnswap ] unit-test
[ 1 2 3 4 5 6 ] [ 1 2 3 4 5 6 2 4 mnswap 4 2 mnswap ] unit-test

View File

@ -73,3 +73,6 @@ MACRO: napply ( n -- )
2 [a,b]
[ [ 1- ] [ ] bi '[ _ ntuck _ nslip ] ]
map concat >quotation [ call ] append ;
MACRO: mnswap ( m n -- )
1+ '[ _ -nrot ] <repetition> spread>quot ;