Not sure this answers exactly to the specs, but it does avoid the duplication:<br><br>(define get-pos<br> (lambda (pos a-grid-plane a-cell)<br> <br> (match-define (cell row-pos col-pos) a-cell)<br> <br> (define cell-size (grid-plane->cell-size a-grid-plane))<br>
<br> (match-define (size cell-w cell-h) cell-size)<br> <br> (case pos<br> [(top-right-x)<br> (+ cell-w<br> (* col-pos cell-w))]<br> [(top-right-y)<br> (* row-pos cell-w)]<br> ....)))<br>
<br><br>Laurent<br><br><div class="gmail_quote">On Mon, May 7, 2012 at 11:41 PM, Patrick Mahoney <span dir="ltr"><<a href="mailto:paddy.mahoney@gmail.com" target="_blank">paddy.mahoney@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":3q">(define top-right-x <br> (lambda (a-grid-plane a-cell)<br> <br>;;The next three definitions are what I am looking to abstract over, as they show up in many similarly defined functions.|#<br>
(match-define (cell row-pos col-pos) a-cell)<br>
<br> (define cell-size (grid-plane->cell-size a-grid-plane))<br> <br> (match-define (size cell-w cell-h) cell-size)<br> <br> (+ cell-w <br> (* col-pos cell-w))))<br><br>(define top-right-y <br>
(lambda (a-grid-plane a-cell)<br> <br> (match-define (cell row-pos col-pos) a-cell)<br> <br> (define cell-size (grid-plane->cell-size a-grid-plane))<br> <br> (match-define (size cell-w cell-h) cell-size)<br>
<br> (* row-pos cell-w)))<br></div></blockquote></div><br>