Email list hosting service & mailing list manager

Comments on SRFI-1. Harvey J. Stein (04 Jan 1999 10:35 UTC)
Comments on SRFI-1. Shriram Krishnamurthi (04 Jan 1999 15:41 UTC)
Comments on SRFI-1. Shriram Krishnamurthi (04 Jan 1999 15:56 UTC)
Re: Comments on SRFI-1. hjstein@xxxxxx (04 Jan 1999 16:05 UTC)
Re: Comments on SRFI-1. Shriram Krishnamurthi (04 Jan 1999 16:24 UTC)
Re: Comments on SRFI-1. Dave Mason (04 Jan 1999 16:30 UTC)

Comments on SRFI-1. Shriram Krishnamurthi 04 Jan 1999 15:56 UTC

I wrote:

> (define (list-split n l)
>   (define (helper index before after)
>     (cond
>       ((null? after) (error 'list-split
> 		       "list ~s too small to be split at position ~s"
> 		       l n))
>       ((= index 0) (values (reverse before) after))
>       (else (helper (sub1 index) (cons (car after) before) (cdr after)))))
>   (cond
>     ((< n 0) (error 'list-split "index ~s must be >= 0" n))
>     (else (helper n '() l))))

Oh, I just noticed that this demands a non-empty list argument.  I
guess you could define things either way, but a more forgiving
implementation would swap the first two clauses of the cond.

'shriram