Transpose a matrix in racket (list of lists

前端 未结 3 510
既然无缘
既然无缘 2020-12-10 18:26

I got a list of lists in racket and have to transpose them.

(: transpose ((list-of(list-of %a)) -> (list-of (list-of %a))))

(check-expect (transpose (lis         


        
3条回答
  •  旧时难觅i
    2020-12-10 19:05

    (define (tr ls)
      (if (empty? (car ls)) empty
     (if (null? ls) empty
         (cons (map car ls) (tr (map cdr ls))))))
    

提交回复
热议问题