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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply