From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: tantalum@gmx.net Newsgroups: gmane.lisp.guile.user Subject: Re: I/O, modules Date: Tue, 13 Nov 2012 12:45:49 +0100 Message-ID: <20121113114549.279070@gmx.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1352826865 31409 80.91.229.3 (13 Nov 2012 17:14:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Nov 2012 17:14:25 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Nov 13 18:14:34 2012 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TYK4H-0002uO-4h for guile-user@m.gmane.org; Tue, 13 Nov 2012 18:14:33 +0100 Original-Received: from localhost ([::1]:38381 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYK47-0002pW-EO for guile-user@m.gmane.org; Tue, 13 Nov 2012 12:14:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TYEwH-0007QO-3s for guile-user@gnu.org; Tue, 13 Nov 2012 06:46:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TYEwE-0006aa-2N for guile-user@gnu.org; Tue, 13 Nov 2012 06:45:57 -0500 Original-Received: from mailout-de.gmx.net ([213.165.64.22]:51790) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TYEwD-0006a9-NQ for guile-user@gnu.org; Tue, 13 Nov 2012 06:45:53 -0500 Original-Received: (qmail 7161 invoked by uid 0); 13 Nov 2012 11:45:51 -0000 Original-Received: from 84.134.101.62 by www003.gmx.net with HTTP; Tue, 13 Nov 2012 12:45:49 +0100 (CET) X-Authenticated: #12123172 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX1/R/CMOcDXRJJKa/o5o26E1BQHMcJ8HmuS6s0vSl5 iwwHH3LmXzHdbpEtEWk+A5TFq4JX9UtnbdcA== X-GMX-UID: ulfQcGcMeSEqR0Wf03Qhui1+IGRvb8Bo X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 213.165.64.22 X-Mailman-Approved-At: Tue, 13 Nov 2012 12:14:11 -0500 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:9672 Archived-At: Hi The (ice-9 streams) module could be interesting, too. http://www.gnu.org/software/guile/manual/html_node/Streams.html Example: ------------- (import (ice-9 streams) (ice-9 rdelim)) (define (port->line-stream port handle-delim) (port->stream port (lambda (port) (read-line port handle-delim)))) (define (file-upcase source-path target-path) (call-with-input-file source-path (lambda (source-file) (call-with-output-file target-path (lambda (target-file) (stream-for-each (lambda (line) (display (string-upcase line) target-file)) (port->line-stream source-file (quote concat)))))))) ;test (system "echo test >/tmp/file-upcase-test") (file-upcase "/tmp/file-upcase-test" "/tmp/file-upcase-test-out") -------------- Where - Handle-delim specifies what should happen with the newline character. Default is to remove it - And display is Schemes standard string write procedure I don't know of any existing generic file to string procedure. Something similar to what I have used is: --------------- (import (ice-9 streams) (ice-9 rdelim)) (define (port->line-stream port handle-delim) (port->stream port (lambda (port) (read-line port handle-delim)))) (define (file->string file) (apply string-append (stream->list (port->line-stream file (quote concat))))) (define (file-from-path->string path) (call-with-input-file path file->string)) (display (file-from-path->string "/home/jkalbhenn/temp/temp.scm")) ------------- Julian