Same as let loops, can I create a recursive lambda? Dumb let loop: (let loop ([n 1])
(loop (add1 n)))
Dumb lambda loop?: (lambda loop (n)
(loop (add1 n)))
I can reach that using define, but I think is interesting getting recursion immediately inside the lambda expression.
Are you by chance looking for something like this?
I think, Friedman or Felleisen has an explanation of the y combinator in terms of a series of questions and answers - in the good, old style of The Little Schemer.
That’s a nice read, thanks! Also letrec
as mentioned in the paper. Note that (at least in Racket), you need a strict fixed-point-combinator (I believe the Z is one such), due to a lack of laziness.
Can anyone remember the title?
Yes, maybe a lambda-rec macro using the Z combinator could be nice. Thanks!
FWIW Goldberg describes a more general version of Z. http://www.ccs.neu.edu/home/shivers/papers/scheme02/article/variadic-y.pdf
It seems to have an introduction about how to derive mutual recursion, which I didn’t realize before. Great paper! Thanks @soegaard2 .
@gamburg.m has joined the channel
hello
so it seems that a language cannot have a syntax like #!{something}
in it?
I got “Module Language: there can only be one expression in the definitions window”
How do you want to use it?
If you create your own #lang
, you can make a new readtable
that maps the dispatch macro #\!
to something else
For example:
#lang racket/base
(define my-readtable
(make-readtable
#f
#\!
'dispatch-macro
(λ (ch port source line col pos)
#'1)))
(parameterize ([current-readtable my-readtable])
(read))
If you input (#!{something})
, you will get '(1 (something))
back.