guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pipelines


From: Ludovic Courtès
Subject: Re: pipelines
Date: Wed, 01 Apr 2009 00:56:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux)

Hello!

"Marijn Schouten (hkBst)" <address@hidden> 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'.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]