Page 1 of 1

(define (transpose y) (cond ((null? y) ()) ((null? (cdr y)) (map list (car y))) (else (

Posted: Fri May 20, 2022 3:19 pm
by answerhappygod
(define (transpose y)
(cond ((null? y) ())
((null? (cdr y))
(map list (car y)))
(else (map cons (car y)
(transpose (cdr y))))))
(define (symmetric x )
(cond ((null? x) ())
(equal? (car (transpose x)) (car
x))
(symmetric (cdr x))))
(symmetric '((1 2 3)(4 5 6)(7 8 9)))
I am trying to define a function in scheme that check if a
matrix (list of list) is symmetric or not, by checking vectors of
the matrix with its transpose one using recursive . but
the function symmetric does not produce the correct output which
should be either true of false.