combinators.smart: Add cleave>array.

db4
Doug Coleman 2012-09-16 17:32:27 -07:00
parent 320efb8bc7
commit 8bfed897a8
2 changed files with 14 additions and 12 deletions

View File

@ -3,7 +3,8 @@
USING: accessors arrays effects fry generalizations kernel
macros math math.order sequences sequences.generalizations
stack-checker stack-checker.backend stack-checker.errors
stack-checker.values stack-checker.visitor words memoize ;
stack-checker.values stack-checker.visitor words memoize
combinators ;
IN: combinators.smart
GENERIC: infer-known* ( known -- effect )
@ -65,6 +66,9 @@ M: object infer-known* drop f ;
: output>array ( quot -- array )
{ } output>sequence ; inline
: cleave>array ( x seq -- array )
'[ _ cleave ] output>array ; inline
: input<sequence ( seq quot -- )
[ inputs firstn ] [ call ] bi ; inline

View File

@ -168,17 +168,15 @@ TUPLE: class-partition integers not-integers simples not-simples and or other ;
class-partition boa ;
: class-partition>sequence ( class-partition -- seq )
[
{
[ integers>> ]
[ not-integers>> ]
[ simples>> ]
[ not-simples>> ]
[ and>> ]
[ or>> ]
[ other>> ]
} cleave
] output>array concat ;
{
[ integers>> ]
[ not-integers>> ]
[ simples>> ]
[ not-simples>> ]
[ and>> ]
[ or>> ]
[ other>> ]
} cleave>array concat ;
: repartition ( partition -- partition' )
! This could be made more efficient; only and and or are effected