Transpose of an nxm matrix using Scheme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | (define transpose
(lambda (blist)
(cond
[(null? (car blist)) empty]
[else
(cons (calc car blist) (transpose (calc cdr blist)))])))
(define calc
(lambda (operation alist)
(cond
[(null? alist) empty]
[else
(cons (operation (car alist)) (calc operation (cdr alist)))])))
(display "The output is: " )
(transpose '((1 2 3 4)(4 5 6 7)(7 8 9 0)))
|