Hi, <br><br>something I seem to often do is use list as structures, (and have lists of these)<br><br>eg<br><br>#lang scheme<br>(define people '(("Guy" 40 man) ("Maddona" 50 woman)))<br><br>I am often doing something like;<br>
<br>
(map (λ (person) <br>(let ((name (car person))<br> (age (car person))<br> (gender (car person))) <br> (blah-fn name age gender)<br> ) people)<br>
<br>I could, but don't often, do (map (λ (name age gender) (blah-fn name age gender) ) (map car people) (map cadr people) (map caddr people))<br>
<br>I realise this is a bit rubbish and have thought of a better way; <br><br>(map (λ (person) <br>
(let-values ([(name age gender) (apply values person)])<br>
(blah-fn name age gender)<br>
)) people)<br>
<br>I sort of suspect that a macro might be the ticket - like; <br><br><br>(define-syntax-rule (lambda-apply-values-person1 values-list blah-fn x y z)<br> (λ (values-list)<br> (let-values ([(x y z) (apply values values-list)])<br>
(blah-fn x y z)<br> )))<br><br>(map (lambda-apply-values-person1 person (lambda args (display args)) x y z) people)<br><br>which works but doesn't handle multiple identifiers; <br><br>(define-syntax lambda-apply-values-person2<br>
(syntax-rules ()<br> (lambda-apply-values-person2 values-list ...)<br> (λ (values-list) <br> (let-values ([(...) (apply values values-list)])<br> (list ...)<br> ))))<br>of course this doesn't work. I suspect I can't do this with syntax-rules and need to look at syntax-case and the syntax form.<br>
<br>Because I do this all the time I'm sure that others have a better way. What do you do?<br><br>Cheers,<br><br>Stephen<br><br><br>