[racket] Are there any functional structs in Racket

From: Richard Cleis (rcleis at mac.com)
Date: Thu Oct 21 11:29:53 EDT 2010

On Oct 20, 2010, at 11:16 PM, Nikita B. Zuev wrote:

> Thank you all for your replies. I somehow missed `struct-copy', this
> is exactly what I wanted. Bad thing I can't pass lambda to it like:
> (struct-copy person
>             myperson
>             (age (lambda (age) (+ age 1))))

struct-copy expects an expression, so the lambda isn't necessary. It doesn't require id's in the expression to be from the same structure (or to be part of a structure at all). If you are writing a lot of code that requires a special form like the above, then you can write a function or macro to do it. The following expression is just as short and easy (easier?) to read, anyway.

(struct-copy person myperson (age (+ 1 (person-age myperson))))

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101021/d204d580/attachment.html>

Posted on the users mailing list.