From 93b855b22cb4edb89a1a4bf3a215010b1d6a02f1 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 19 Aug 2016 23:05:01 -0400 Subject: [PATCH] Fix problems with compilation --- srfi/1.scm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/srfi/1.scm b/srfi/1.scm index ad447154..36a10548 100644 --- a/srfi/1.scm +++ b/srfi/1.scm @@ -208,6 +208,13 @@ ;;; ;;; The SRFI discussion record contains more discussion on this topic. +(define-syntax :optional + (syntax-rules () + ((:optional rest default-exp) + (let ((maybe-arg rest)) + (cond ((null? maybe-arg) default-exp) + ((null? (cdr maybe-arg)) (car maybe-arg)) + (else (error "too many optional arguments" maybe-arg))))))) ;;; Constructors ;;;;;;;;;;;;;;;; @@ -271,7 +278,13 @@ (define (iota count . maybe-start+step) (check-arg integer? count iota) (if (< count 0) (error "Negative step count" iota count)) - (let-optionals maybe-start+step ((start 0) (step 1)) + (let ((start 0) + (step 1)) + (cond + ((not (null? maybe-start+step)) + (set! start (car maybe-start+step)) + (if (not (null? (cdr maybe-start+step))) + (set! step (cadr maybe-start+step))))) (check-arg number? start iota) (check-arg number? step iota) (let loop ((n 0) (r '()))