[Gauche-devel] Fwd: SRFI-60 integer->list and list->integer
R7RS Scheme scripting engine
Status: Beta
Brought to you by:
shirok
From: Sascha Z. <ce...@gm...> - 2012-01-12 08:57:20
|
Gauche list->integer function does not check for negative numbers either: gosh> (integer->list 0) () gosh> (integer->list -1) () gosh> (list->integer (integer->list -1)) 0 ---------- Forwarded message ---------- From: Aubrey Jaffer <ag...@al...> Date: 2012/1/10 Subject: Re: SRFI-60 integer->list and list->integer To: Sascha Ziemann <ce...@gm...> | Date: Tue, 10 Jan 2012 15:56:14 +0100 | From: Sascha Ziemann <ce...@gm...> | | Hello, | | I have a question about the integer->list function in SRFI-60. | | The function list->integer does not seem to be the reverse function | for integer->list: | | $ scm | > (list->integer (integer->list -1)) | 0 | | Is this the intended behavior? integer->list works only for non-negative numbers. The prototype for the first argument, 'k' indicates a non-negative number in the conventions for R4RS and R5RS. Function: integer->list k len Function: integer->list k integer->list returns a list of len booleans corresponding to integer->each bit of the given integer. #t is coded for each 1; integer->#f for 0. The len argument defaults to (integer-length integer->k). SRFI-60 should have explicitly stated this restriction and the implementation should signal an error for negative numbers. |