I've been looking over the syntax for defining a syntax rule however I am still stuck.
I want to define a rule with this signature: (define-syntax-rule (for {val in lst} return res).
Basically it simply applies map given a val and a lst. But I am struggling with the syntax. This is what I've come up with so far.. .... (syntax-rules () ((for val in lst) (map (val lst)))) ...
The input would be something like:
(for {val in '(0 1 2 3 4)} return (- val 1) )
and output (-1 0 1 2 3), as if map were called on the list.
define-syntax-rulesince you have literals in the definition (ie theinandreturn). @GoZoner's answer (if you add parens around the(val in list)) gives you what you want. (And in Racket, curly braces are the same as regular parens.) - stchangfor/listwhich does the same thing as what you are trying to define.(for/list ([val '(0 1 2 3 4)]) (- val 1))=>'(-1 0 1 2 3)- stchang