[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
expression
From: |
Michael Lucy |
Subject: |
expression |
Date: |
Wed, 23 Jun 2010 16:09:30 -0500 |
Hey,
Is there any scheme expression that will just get ignored when the
scheme code is compiled?
I'm generating some code with a function like:
(define (gen-update-ab updatea updateb)
`(begin
,(if updatea `(set! a (+ a 1)) `(donothing))
,(if updateb `(set! b (+ b 1)) `(donothing))))
And ideally I could replace the donothing function with something that
will get discarded during compilation.
There are alternatives, but they're pretty ugly (significantly moreso
in my actual code than they look below):
(define (gen-update-ab-2 updatea updateb)
`(begin
,@(if updatea `((set! a (+ a 1))) `())
,@(if updateb `((set! b (+ b 1))) `())))
(define (gen-update-ab-3 updatea updateb)
(filter (lambda (x) (not (null? x)))
`(begin
,(if updatea `(set! a (+ a 1)) `())
,(if updateb `(set! b (+ b 1)) `()))))
- expression,
Michael Lucy <=