For Programmers: Free Programming Magazines  


Home > Archive > Scheme > November 2005 > Retrieving elements from a matrix









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Retrieving elements from a matrix
witt

2005-11-13, 11:12 am

Hello, I'm doing some exercises on scheme programming, and I could use some help with this one.

I'm trying to create a function that takes a 9x9 matrix, and retrieves a list with the linear representation of each 3x3 square contained in the matrix; the order is irrelevant.

I have to use the following code, which returns the first square:

(define topleft-square
(lambda (grid)
(append (first-3 (car grid))
(first-3 (cadr grid))
(first-3 (caddr grid)))))

(define first-3
(lambda (l)
(list (car l) (cadr l) (caddr l))))

I have banged my head around with this, and still couldn't get it to work. A few hints would be really helpful. Thanks;)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com