Re: [racket] idioms for abstracting over definitions

2012-05-08 Thread Laurent
Not sure this answers exactly to the specs, but it does avoid the duplication: (define get-pos (lambda (pos a-grid-plane a-cell) (match-define (cell row-pos col-pos) a-cell) (define cell-size (grid-plane->cell-size a-grid-plane)) (match-define (size cell-w cell-h) cell-size)

Re: [racket] idioms for abstracting over definitions

2012-05-08 Thread William James
--- On Mon, 5/7/12, Patrick Mahoney wrote: > Hello all, in a quest for greater concision, I'm looking for a > way to abstract over the following code containing mostly > definitions. Is there an accepted practice for abstraction over > definition introduction? > > > (define top-right-x > (la

Re: [racket] idioms for abstracting over definitions

2012-05-08 Thread Patrick Mahoney
Thank you all, you have given me much to think on here. I had versions that used a generic function as suggested, but I wasn't sure if the cognitive overhead in understanding the generic strategy outweighed the benefits to concision. I think it probably does in some cases, probably related to how d

Re: [racket] idioms for abstracting over definitions

2012-05-08 Thread Vincent St-Amour
Here's one way to do it: (define-values (top-right-x top-right-y) (let () (define (mk x?) (lambda (a-grid-plane a-cell) (match-define (cell row-pos col-pos) a-cell) (define cell-size (grid-plane->cell-size a-grid-plane)) (match-define (size cell-w cell-h) cell-s

Re: [racket] idioms for abstracting over definitions

2012-05-08 Thread Matthias Felleisen
On May 7, 2012, at 5:41 PM, Patrick Mahoney wrote: > #| > Hello all, in a quest for greater concision, I'm looking for a way to > abstract over the following code containing mostly definitions. Is there an > accepted practice for abstraction over definition introduction?|# > > (define top-ri

Re: [racket] idioms for abstracting over definitions

2012-05-08 Thread Nikita B. Zuev
On Mon, 07 May 2012 19:43:37 -0400 users-requ...@racket-lang.org wrote: > #| > Hello all, in a quest for greater concision, I'm looking for a way to > abstract over the following code containing mostly definitions. Is > there an accepted practice for abstraction over definition > introduction?|# >

[racket] idioms for abstracting over definitions

2012-05-07 Thread Patrick Mahoney
#| Hello all, in a quest for greater concision, I'm looking for a way to abstract over the following code containing mostly definitions. Is there an accepted practice for abstraction over definition introduction?|# (define top-right-x (lambda (a-grid-plane a-cell) ;;The next three definitions a