(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.
(define (transpose y) (cond ((null? y) ()) ((null? (cdr y)) (map list (car y))) (else (
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am