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.
ratioanditersupposed to be internal definitions? or did you just forget to close a)in the last line ofmin-ratio? :) if that's the case, close it and delete the extra)at the end ofiter. - Óscar Lópezdefinecan only be the first expressions in a lambda or derived (define,let,letrec, ...) and then you can have expression that actually use these. Notice that you are callingratiofrom the value ofr-listand that is before it exists. Also I see you are appling (calling)r-listin last argument oflast-element, but it looks as ifratioretuns a list and not a procedure and will most likely fail. - Sylwester