Михаил Бахтерев schreef op zo 24-10-2021 om 11:49 [+0500]: > Greetings! > > I wondering, if is it possible to implement something like > this? > > (define-syntax R (syntax-rules () ((_ r v l) #(red r v l)))) > (define-syntax B (syntax-rules () ((_ r v l) #(black r v l)))) > > (define red-black-set-balance > (match-lambda > ((or (B (R (R a x b) y c) z d) > (B (R a x (R b y c)) z d) > (B a x (R (R b y c) z d)) > (B a x (R b y (R c z d)))) (R (B a x b) y (B c z d))) > (node node)))
Not exactly what you were looking for, but maybe use quasisyntax / unsyntax #` #, something like (untested): ;; define, not define-syntax! (define R (syntax-rules () ((_ r v l) #(red r v l)))) (define B (syntax-rules () ((_ r v l) #(black r v l)))) (define-syntax red-black-set-balance-m (lambda (s) #`(match-lambda ((or #,(B (R (R a x b) y c) z d) #,(B (R a x (R b y c)) z d) ...)) (node node)))) (define red-black-set-balance red-black-set-balance-m) Greetings, Maxime