X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?p=scheme.forth.jl.git;a=blobdiff_plain;f=src%2Fscheme-library.scm;h=14aa6f89d619553bc1c0e21c34db0633e1c31e22;hp=68debca48afbcd9d7b31c15e485338e1acbcbdfb;hb=bc2450b4b29d6bb8ba5422fb9eb7a75d1b6b5a57;hpb=aa76b536aa3e1a90b31a64fd9147b2b16153ec8b diff --git a/src/scheme-library.scm b/src/scheme-library.scm index 68debca..14aa6f8 100644 --- a/src/scheme-library.scm +++ b/src/scheme-library.scm @@ -203,7 +203,7 @@ (define (iter a count) (if (null? a) count - (iter (cdr a) (+ count 1)))) + (iter (cdr a) (fix:+ count 1)))) (iter l 0)) ; Join two lists together @@ -330,18 +330,18 @@ (define (sum n) (define (sum-iter total count maxcount) - (if (> count maxcount) + (if (fix:> count maxcount) total - (sum-iter (+ total count) (+ count 1) maxcount))) + (sum-iter (fix:+ total count) (fix:+ count 1) maxcount))) (sum-iter 0 1 n)) ; Recursive summation. Use this to compare with tail call ; optimized iterative algorithm. (define (sum-recurse n) - (if (= n 0) + (if (fix:= n 0) 0 - (+ n (sum-recurse (- n 1))))) + (fix:+ n (sum-recurse (fix:- n 1))))) ;; MISC