diff --git a/basis/io/pipes/pipes.factor b/basis/io/pipes/pipes.factor index 8d747086a7..73de6bf1a2 100644 --- a/basis/io/pipes/pipes.factor +++ b/basis/io/pipes/pipes.factor @@ -37,17 +37,22 @@ M: callable run-pipeline-element '[ _ call( -- result ) ] with-streams* ] with-destructors ; -: ( n -- pipes ) +GENERIC: ( obj -- pipes ) + +M: integer ( n -- pipes ) [ [ (pipe) |dispose ] replicate T{ pipe } [ prefix ] [ suffix ] bi 2 ] with-destructors ; +M: sequence + [ { } ] [ length 1 - ] if-empty ; + PRIVATE> : run-pipeline ( seq -- results ) - [ length dup zero? [ drop { } ] [ 1 - ] if ] keep + [ ] keep [ [ [ first in>> ] [ second out>> ] bi ] dip run-pipeline-element