problem1.scm
Published in DevCode 2001. Original code and wording are preserved.
; Problem 1
(define M'((1 2 3) (4 5 6) (7 8 9)))
(define(Row M row_)
(cond
((null? M) 0)
((eq? row_ 1) (car M))
(else(Row (cdr M) (- row_ 1)))
)
)
; Problem 2
(define(Col M col_) ;This works like the example, to get 5, need to call (Col (cdr M) 2))
(cond
((null? M) 0)
((eq? col_ 1) (car M))
(else(Col (cdr(car M)) (- col_ 1) ))
)
)
(define(Reference M row col)
(Col (Row M row) col) ;For some reason only passes the first value in the List to Col
)
;Problem 3
(define(Column M col)
(Helper_Column M col (length M)))
(define(Helper_Column M col times)
;(if(> col 0) (= n 10))
;(if (> times 1)
(cond
((> times 1)(list (Col M col) (Helper_Column (cdr M) col (- times 1))))
)
)