This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

matrix'


Hi,

is there a function in Guile that does this?

(define (matrix' m)
  (if (pair? m)
      (if (pair? (car m))
	  (cons (map car m) (matrix' (map cdr m)))
	  '())
      (throw 'not-a-pair m)))

guile> (define a '((1 2 3) (a b c) (x y z)))
guile> (matrix' a)
=> ((1 a x) (2 b y) (3 c z))

If not I think there should be one. Probably a more robust one ;-)