guile-devel
[Top][All Lists]
Advanced

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

Re: srfi-1 take and drop seriously broken


From: Panicz Maciej Godek
Subject: Re: srfi-1 take and drop seriously broken
Date: Sat, 19 Nov 2016 23:55:41 +0100



2016-11-19 19:34 GMT+01:00 Jan Synáček <address@hidden>:
Hi,

scheme@(guile-user)> ,use (srfi srfi-1)
scheme@(guile-user)> (take (list 1 2 3) 4)
ERROR: In procedure list-head:
ERROR: In procedure list-head: Wrong type argument in position 1
(expecting pair): ()

scheme@(guile-user) [1]> (drop (list 1 2 3) 4)
ERROR: In procedure list-tail:
ERROR: In procedure list-tail: Wrong type argument in position 1
(expecting pair): ()

Please, tell me that this is just a mistake... This can't be true. I
still can't believe it. This is from 2.0.11. Please, tell me that the
implementation is fixed in 2.2.

Yours truly puzzled,

I don't know why you find it so puzzling. You can't take or drop something that "isn't there" (you can't take a car or cdr from an empty list as well, although e.g. in the language of "The Little Prover" (car '()) and (cdr '()) both evaluate to '() to assure their totality). If you need, you can define your own variants that take/drop at most n elements of list.

Or you could use the take-upto/drop-upto functions from the (grand scheme) library that I maintain:
https://github.com/plande/grand-scheme
(check the grand/list.scm file for the definition)



reply via email to

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