"Andrew Tarr" <arc@stuff.gen.nz> wrote in message
87u1pe9mq7.fsf@stuff.gen.nz">news:87u1pe9mq7.fsf@stuff.gen.nz...
>
> I figured out how to do conditional variable binding in a schemey way:
>
>
> (let ((filtering-rx ((lambda ()
> (if (string=? ".css" (file-name-extension fromfile))
> (rx (: (submatch "\"" (* any))
> ,source-root
> (submatch (* any) "\"" )))
> (rx (:
> (submatch (:"<" (* any) "\"" (* any)))
> ,source-root
> (submatch (: (* any) "\"" (* any) ">"))))
> )))))
> ;body of let
> )
>
That ought to be equivalent to:
(let ((filtering-rx
(if (string=? ".css" (file-name-extension fromfile))
(rx (: (submatch "\"" (* any))
,source-root
(submatch (* any) "\"" )))
(rx (:
(submatch (:"<" (* any) "\"" (* any)))
,source-root
(submatch (: (* any) "\"" (* any) ">"))))
)))
;body of let
)
I'm not familiar with RX, but if it is a procedure (and the `(:' is
doing the funny quoting) you ought to be able to do this:
(let ((filtering-rx
(rx (if (string=? (file-name-extension fromfile) ".css")
(: (submatch "\"" (* any))
,source-root
(submatch (* any) "\"" ))
(: (submatch (:"<" (* any) "\"" (* any)))
,source-root
(submatch (: (* any) "\"" (* any) ">")))))))
;body of let
)
> but this seems a little clumsy --- what with the use of the lambda form
> plus an extra set of brackets
It is. I don't think they are necessary.
--- when you consider that a C-like
> language would just do it thus:
>
> if (condition)
> {x = true;}
> else
> {x = false;}
x = condition ? true : false;
C has conditional expressions, no one uses them much.
|