(Arne Babenhauserheide)
2014-11-20: added self-referencial function test, because that’s really crazy added self-referencial function test, because that’s really crazy (and nice).
diff --git a/tests/self-referencial.scm b/tests/self-referencial.scm new file mode 100644 --- /dev/null +++ b/tests/self-referencial.scm @@ -0,0 +1,21 @@ +; http://stackoverflow.com/questions/23167464/scheme-self-reference-lambda-macro +; because this is as cool as things get +(define-syntax slambda + (lambda (x) + (syntax-case x () + ((slambda formals body0 body1 ...) + (with-syntax + ((self (datum->syntax #'slambda 'self))) + #'(letrec ((self (lambda formals body0 body1 ...))) + self)))))) + + + +( + (slambda (x) (+ x 1)) + 10) + +((slambda () self)) + + + diff --git a/tests/self-referencial.w b/tests/self-referencial.w new file mode 100644 --- /dev/null +++ b/tests/self-referencial.w @@ -0,0 +1,19 @@ +; http://stackoverflow.com/questions/23167464/scheme-self-reference-lambda-macro +; because this is as cool as things get +define-syntax slambda + lambda : x + syntax-case x : + : slambda formals body0 body1 ... + with-syntax + : self : datum->syntax #'slambda 'self + #' letrec : : self : lambda formals body0 body1 ... + . self + + + +: + slambda (x) : + x 1 + . 10 + +: slambda () self +