Re: Adding wc to Bournish

2016-06-23 Thread Ludovic Courtès
Hello! Efraim Flashner skribis: [...] >> I prefer the approach Ricardo suggested, I think it’s more concise and >> clearer: >> >> https://lists.gnu.org/archive/html/guix-devel/2016-06/msg00525.html >> >> Also, note that @@ would not be needed here; @@ serves to

Re: Adding wc to Bournish

2016-06-15 Thread Ludovic Courtès
Efraim Flashner skribis: > From 09eef9cd841a7d212e024be0609168611923696b Mon Sep 17 00:00:00 2001 > From: Efraim Flashner > Date: Sun, 22 May 2016 14:56:06 +0300 > Subject: [PATCH] bournish: Add `wc' command. > > * guix/build/bournish.scm

Re: Adding wc to Bournish

2016-06-14 Thread Efraim Flashner
On Tue, Jun 14, 2016 at 01:20:29PM +0300, Efraim Flashner wrote: > On Tue, Jun 14, 2016 at 11:57:26AM +0200, Ricardo Wurmus wrote: > > > > Efraim Flashner writes: > > > > > +(define wc-command-implementation > > > + (lambda files > > > +(let ((files (filter (lambda

Re: Adding wc to Bournish

2016-06-14 Thread Efraim Flashner
On Tue, Jun 14, 2016 at 11:57:26AM +0200, Ricardo Wurmus wrote: > > Efraim Flashner writes: > > > +(define wc-command-implementation > > + (lambda files > > +(let ((files (filter (lambda (file) > > + (catch 'system-error > > +

Re: Adding wc to Bournish

2016-06-14 Thread Ricardo Wurmus
Efraim Flashner writes: > +(define wc-command-implementation > + (lambda files > +(let ((files (filter (lambda (file) > + (catch 'system-error > + (lambda () > + (stat file)) > +

Re: Adding wc to Bournish

2016-06-14 Thread Efraim Flashner
On Wed, Jun 08, 2016 at 05:43:09PM +0200, Ludovic Courtès wrote: > Efraim Flashner skribis: > > > On Sun, Jun 05, 2016 at 10:37:12PM +0200, Ludovic Courtès wrote: > > [...] > > >> I’ll commit a couple of fixes for bugs I just found and that prevent us > >> from doing: >

Re: Adding wc to Bournish

2016-06-08 Thread Ludovic Courtès
Efraim Flashner skribis: > On Sun, Jun 05, 2016 at 10:37:12PM +0200, Ludovic Courtès wrote: [...] >> I’ll commit a couple of fixes for bugs I just found and that prevent us >> from doing: >> >> (compile "ls" #:from %bournish-language #:to 'scheme). (This should be be

Re: Adding wc to Bournish

2016-06-07 Thread Efraim Flashner
On Sun, Jun 05, 2016 at 10:37:12PM +0200, Ludovic Courtès wrote: > Efraim Flashner skribis: > > + > > +(define* (wc-command-implementation file #:optional args) > > + (let-values (((lines chars) > > +(call-with-input-file file lines+chars))) > > +(match

Re: Adding wc to Bournish

2016-06-05 Thread Ludovic Courtès
Efraim Flashner skribis: > I've been working more on this and I think it's much better now. > Currently it checks for `-l' or `-c' flags in the first position and > with some borrowing of code from the ls-command I've worked out > returning an error (out of order) when a

Re: Adding wc to Bournish

2016-06-05 Thread Efraim Flashner
I've been working more on this and I think it's much better now. Currently it checks for `-l' or `-c' flags in the first position and with some borrowing of code from the ls-command I've worked out returning an error (out of order) when a file doesn't exist. And if there's no flag then it attempts

Re: Adding wc to Bournish

2016-05-27 Thread Thompson, David
On Fri, May 27, 2016 at 11:28 AM, Taylan Ulrich Bayırlı/Kammer wrote: > By the way, I prefer SRFI-11 let-values (standardized in R7RS): > > (define (wc-command file) > (let-values (((lines words chars) > (call-with-input-file file

Re: Adding wc to Bournish

2016-05-27 Thread Taylan Ulrich Bayırlı/Kammer
Eric Bavier writes: > On 2016-05-26 14:27, Efraim Flashner wrote: >> Here's where I'm currently at with 'wc'. Currently I'm getting an error >> about having the wrong number of arguments for lambda (I assume) > [...] >> +(define (wc-command file) >> + ((lambda (lines

Re: Adding wc to Bournish

2016-05-27 Thread Eric Bavier
On 2016-05-26 14:27, Efraim Flashner wrote: Here's where I'm currently at with 'wc'. Currently I'm getting an error about having the wrong number of arguments for lambda (I assume) [...] +(define (wc-command file) + ((lambda (lines words chars) ; lambda doesn't like 3 variables + (format

Re: Adding wc to Bournish

2016-05-26 Thread Efraim Flashner
Here's where I'm currently at with 'wc'. Currently I'm getting an error about having the wrong number of arguments for lambda (I assume) ;;; /home/efraim/workspace/guix/guix/build/bournish.scm:143:2: warning: wrong number of arguments to `#' It's not ready as-is, but I wanted to show what I had

Re: Adding wc to Bournish

2016-05-26 Thread Efraim Flashner
On Thu, May 26, 2016 at 10:46:21AM +0200, Ludovic Courtès wrote: > > As Ricardo suggests, you could use ‘port->stream’ and ‘stream-fold’ to > iterate over the characters read from the port. I suspect that’d be > rather slow though, at least on 2.0, so another option is something > like: > >

Re: Adding wc to Bournish

2016-05-26 Thread Ludovic Courtès
Hello! Efraim Flashner skribis: > GSoC just started and so far I have 13 tabs from the guile manual open > on my computer. I almost implemented `du' at the same time as `wc' but > at the time I was getting tripped up with functions returning functions > or returning

Re: Adding wc to Bournish

2016-05-25 Thread Efraim Flashner
On Wed, May 25, 2016 at 11:26:11AM +0200, Ricardo Wurmus wrote: > > Efraim Flashner writes: > > > +(define (wc-l-command file) > > + (let* ((input-file (open-file file "r")) > > + (line (read-line input-file)) > > + (line-count 0)) > > +(while

Re: Adding wc to Bournish

2016-05-25 Thread Efraim Flashner
On Wed, May 25, 2016 at 11:03:34AM +0200, Ricardo Wurmus wrote: > > Efraim Flashner writes: > > > +(define (wc-command file) > > + (if (and (file-exists? file) (access? file 4)) > > + (let* ((wc-l ((@@ (guix build bournish) wc-l-command) file)) > > +(wc-w

Re: Adding wc to Bournish

2016-05-25 Thread Ricardo Wurmus
Efraim Flashner writes: > +(define (wc-command file) > + (if (and (file-exists? file) (access? file 4)) > + (let* ((wc-l ((@@ (guix build bournish) wc-l-command) file)) > +(wc-w ((@@ (guix build bournish) wc-w-command) file)) > +(wc-c ((@@