Paste: =permutatio
Author: | prunedtree |
Mode: | factor |
Date: | Fri, 21 Nov 2008 07:25:41 |
Plain Text |
: (=permutation-static-array) ( -- array ) { 0 1 2 3 4 5 6 7 8 9 } ; inline
: =permutation ( x y -- ? )
(=permutation-static-array)
{
[ [ drop 0 ] change-each ]
[ '[ 10 /mod _ [ 1+ ] change-nth dup 0 > ] loop drop ]
[ '[ 10 /mod _ [ 1- ] change-nth dup 0 > ] loop drop ]
[ ]
} cleave
[ 0 = ] all? ;
Author: | prunedtree |
Mode: | factor |
Date: | Fri, 21 Nov 2008 07:31:35 |
Plain Text |
: (=permutation-static-array) ( -- array ) B{ 0 1 2 3 4 5 6 7 8 9 } ; inline
: =permutation ( x y -- ? )
(=permutation-static-array)
{
[ [ drop 0 ] change-each ]
[ '[ 10 /mod _ [ 1+ ] change-nth dup 0 fixnum> ] loop drop ]
[ '[ 10 /mod _ [ 1- ] change-nth dup 0 fixnum> ] loop drop ]
[ ]
} cleave
[ 0 = ] all? ; inline
Author: | slava |
Mode: | factor |
Date: | Fri, 21 Nov 2008 07:37:41 |
Plain Text |
{ /mod fixnum/mod } [
\ /i \ mod
[ "outputs" word-prop ] bi@
'[ _ _ 2bi ] "outputs" set-word-prop
] each
New Annotation