generalizations: fix funny mnapply/nspread* bug for n > 3.
It accidentally worked for n <= 3, now it purposefully works.windows-drag
parent
d4fc53f10e
commit
ada81e77f5
|
@ -99,6 +99,12 @@ IN: generalizations.tests
|
|||
{ { 1 2 } { 3 4 } { 5 6 } }
|
||||
[ 1 2 3 4 5 6 [ 2array ] 2 3 mnapply ] unit-test
|
||||
|
||||
{ 1 4 9 16 }
|
||||
[ 1 1 2 2 3 3 4 4 [ * ] 2 4 mnapply ] unit-test
|
||||
|
||||
{ 1 8 27 64 125 }
|
||||
[ 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 [ * * ] 3 5 mnapply ] unit-test
|
||||
|
||||
{ { 1 2 3 } { 4 5 6 } }
|
||||
[ 1 2 3 4 5 6 [ 3array ] 3 2 mnapply ] unit-test
|
||||
|
||||
|
|
|
@ -92,10 +92,10 @@ MACRO: nspread* ( m n -- quot )
|
|||
[ drop [ ] ] [
|
||||
[ * 0 ] [ drop neg ] 2bi
|
||||
<range> rest >array dup length <iota> <reversed>
|
||||
[
|
||||
'[ [ [ _ ndip ] curry ] _ ndip ]
|
||||
] 2map dup rest-slice [ [ compose ] compose ] map! drop
|
||||
[ ] concat-as [ call ] compose
|
||||
[ '[ [ [ _ ndip ] curry ] _ ndip ] ] 2map
|
||||
[ [ ] concat-as ]
|
||||
[ length 1 - [ compose ] <array> concat append ] bi
|
||||
[ call ] compose
|
||||
] if-zero ;
|
||||
|
||||
MACRO: cleave* ( n -- quot )
|
||||
|
|
Loading…
Reference in New Issue