Why do I keep getting this error???
;Can't define name; already free: ratio code
(define (min-ratio list) ;;Pivot row
(let ((r-list (ratio list)))
(last-element (cons 0 (iter 1 (car r-list) (r-list)))))
(define (ratio list)
(if (null? (cdr list)) '()
(let ((row (car list)))
(cons (/ (last-element row) (list-ref row pivot-column))
(ratio (cdr list))))))
(define (iter position value list)
(if (null? (cdr list)) '()
(if (negative? value)
(iter (+ position 1) (cadr list) (cdr list))
(if (or (negative? (cadr list)) (<= vlaue (cadr list)))
(iter (+ position 1) value (cdr list))
(cons position (iter (+ position 1) (cadr list) (cdr list))))))))
Just the "ratio" function works fine, and "iter" function also works fine, but the min-ratio doesn't. I get the error, Can't define name, ratio, already free.
Here you link
ratiowith some upper definition (maybe primitive/library one). If the implementation does not find it defined, it can be marked asfreeand put somewhere in the global scope, hoping for you to define it later (this is implementation defined behavior).Next, you define
ratioinside the scope oflet, where you alrealy referenced it and the system marked its binding asfree.It is implementation defined behavior when you use
defineinside a scope.You should decide whether
ratiofromletis enclosed, or you want to define it, and, if so, putdefine ratioabove let, or you can use something likeletrec (ratio ...) (r-list ...).