From: ludo@gnu.org (Ludovic Courtès)
To: guile-user@gnu.org
Subject: Re: pipelines
Date: Wed, 01 Apr 2009 00:56:10 +0200 [thread overview]
Message-ID: <87eiwd5mk5.fsf@gnu.org> (raw)
In-Reply-To: 49CE1DCA.8070604@gentoo.org
Hello!
"Marijn Schouten (hkBst)" <hkBst@gentoo.org> writes:
> how would I construct a pipeline with guile?
Here's an idea:
(use-modules (ice-9 popen)
(srfi srfi-1))
(define (input-pipeline . args)
(fold (lambda (program input)
(with-input-from-port input
(lambda ()
(open-input-pipe program))))
(current-input-port)
args))
It can then be used like this:
(read-line (input-pipeline "echo foo" "cat" "cat"
"grep foo" "sed -es/foo/bar/g"))
=> "bar"
Defining `output-pipeline' is left as an exercise to the reader.
Thanks,
Ludo'.
prev parent reply other threads:[~2009-03-31 22:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-28 12:53 pipelines Marijn Schouten (hkBst)
2009-03-29 6:24 ` pipelines Andy Wingo
2009-03-30 9:26 ` pipelines Marijn Schouten (hkBst)
2009-03-30 19:00 ` pipelines Neil Jerram
2009-03-31 22:56 ` Ludovic Courtès [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eiwd5mk5.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).