Follow

scheme hacks time

to transpose a matrix (as a list of lists) x

(apply map list x)

scheme hacks time

@IceWolf transpose flips rows and columns yes

(apply) calls the given function expanding the given list arguments

so (apply + '(1 2 3)) is the same as (+ 1 2 3)

map generates a list by running each item of n argument lists through a given function that takes n arguments

(map + '(1 2 3) '(4 5 6))

is (list (+ 1 4) (+ 2 5) (+ 3 6))

and of course list is list

so if x is '((1 2 3) (4 5 6))

(apply map list '((1 2 3) (4 5 6))

(map list '(1 2 3) '(4 5 6))

(list (list 1 4) (list 2 5) (list 3 6))

scheme hacks time

@IceWolf list is a function that creates a list

so (list 1 2 3) is the same as '(1 2 3)

Silver Winter Wolf ❄️@IceWolf@meow.socialscheme hacks time

@haskal What does transpose do, flip rows and columns? What exactly is this doing? (I know what map does...at least, I think I do. Not sure what list does.)