From 8ea85b76e5858c2d205301fd02591c2a47cc088d Mon Sep 17 00:00:00 2001 From: Masaya Tojo Date: Sun, 4 Aug 2024 22:48:14 +0900 Subject: Make `maxval` argument optional --- pnm/pgm.scm | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'pnm/pgm.scm') diff --git a/pnm/pgm.scm b/pnm/pgm.scm index 89f4c35..200720f 100644 --- a/pnm/pgm.scm +++ b/pnm/pgm.scm @@ -23,16 +23,20 @@ (scheme case-lambda) (pnm image)) (begin - (define (make-pgm-image width height maxval) - (when (or (< maxval 0) - (< 65536 maxval)) - (error "(pnm pgm) make-pgm: maxval is out of range")) - (let* ((byte-count (* width height - (if (< maxval 256) - 1 - 2))) - (data (make-bytevector byte-count 0))) - (%make-pgm-image width height maxval data))) + (define make-pgm-image + (case-lambda + ((width height) + (make-pgm-image width height 255)) + ((width height maxval) + (when (or (< maxval 0) + (< 65536 maxval)) + (error "(pnm pgm) make-pgm: maxval is out of range")) + (let* ((byte-count (* width height + (if (< maxval 256) + 1 + 2))) + (data (make-bytevector byte-count 0))) + (%make-pgm-image width height maxval data))))) (define (%make-pgm-image width height maxval data) (when (or (< maxval 0) -- cgit v1.2.3