I've managed to define a struct with one field, how to define multiple fields in one struct or class?
I'm new to R5RS, I can only come up with problematic code, please see it as pseudo code expressing what I'm trying to do.
(define recipe
(let (salt 5)
(sauce "ketchup")))
or
(define recipe
'((let salt 5)
(let sauce "ketchup")))
What's the most concise and common way(s) to do this?
Most Scheme implementations provide records via SRFI 9. So in your case, you can define a
recipe
record type like so:Then you can use it like this:
If you're using Racket, there's an even simpler syntax for defining structs.