io.pipes: allow "|" separated strings in run-pipeline.

char-rename
John Benediktsson 2016-11-09 09:56:34 -08:00
parent 2e326498a4
commit 816d1e31d5
1 changed files with 8 additions and 5 deletions

View File

@ -1,9 +1,9 @@
! Copyright (C) 2008, 2009 Slava Pestov. ! Copyright (C) 2008, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: io.encodings io.backend io.ports io.streams.duplex USING: accessors combinators concurrency.combinators destructors
io splitting grouping sequences namespaces kernel fry grouping io io.backend io.ports io.streams.duplex kernel
destructors math concurrency.combinators accessors fry math namespaces quotations sequences simple-tokenizer splitting
arrays continuations quotations system vocabs combinators ; strings system vocabs ;
IN: io.pipes IN: io.pipes
TUPLE: pipe in out ; TUPLE: pipe in out ;
@ -52,10 +52,13 @@ M: integer <pipes> ( n -- pipes )
M: sequence <pipes> M: sequence <pipes>
[ { } ] [ length 1 - <pipes> ] if-empty ; [ { } ] [ length 1 - <pipes> ] if-empty ;
: pipeline-args ( seq -- args )
dup string? [ tokenize { "|" } split ] when ;
PRIVATE> PRIVATE>
: run-pipeline ( seq -- results ) : run-pipeline ( seq -- results )
[ <pipes> ] keep pipeline-args [ <pipes> ] keep
[ [
[ [ first in>> ] [ second out>> ] bi ] dip [ [ first in>> ] [ second out>> ] bi ] dip
run-pipeline-element run-pipeline-element