Usagi is a federated image board instance.
I created a hygienic macro called `fork` that creates a lambda function which chains comparison functions together like this. (fork number? and integer?) -> (lambda (x) (and (number? x) (integer? x))) Or more generally, (fork check1 connector check2) -> (lambda (x) (connector (check1 x) (check2 x))) It can take variable terms and it has the same behavior so that you can write more complicated definitions. The macro I wrote has the same behavior as (fork check1 connector1 check2 connector2 check3) -> (lambda (x) (connector2 (connector1 (check1 x) (check2 x)) (check3 x))) But it defines more lambda functions than that. Pic related is the actual definition. I am wondering whether or not it's possible to write a hygienic definition of the fork macro that takes any number of arguments, but only defines one lambda function. I want to use syntax-case or define-syntax, No defmacro macros. Also the reason I defined it as a macro instead of a function was because `and` and `or` are macros in scheme so you can't pass them to functions as parameters (at least to my knowledge).
I think I found out a way to do it that only defines the functions once. (define-syntax fork (syntax-rules () ((_ proc1 connector proc2 ) (lambda (x) (connector (proc1 x) (proc2 x)))) ((_ other other* ... proc1 connector proc2 ) (let ((foo (fork proc1 connector proc2))) (fork other other* ... foo )))))
I just realized I can define syntax rules with accumulators after I accidentally made one. Pretty cool. (define-syntax easy-define-symbols (syntax-rules () ((_ () code ...) (begin code ...)) ((_ ( sym syms ...) code ...) (define-multi (syms ...) code ... (define sym (quote sym) )))))
>>fg-0JHUKZ9K Now I want to try making a macro with two recursive calls.
All trademarks and copyrights on this page are owned by their respective parties.
v0.2.0-c793a28