hectometrocuadrado
2021-8-18 12:48:17

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.


soegaard2
2021-8-18 12:52:19

Are you by chance looking for something like this?

https://www.dreamsongs.com/Files/WhyOfY.pdf


soegaard2
2021-8-18 12:54:26

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.


ben.knoble
2021-8-18 12:54:33

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.


soegaard2
2021-8-18 12:54:38

Can anyone remember the title?


hectometrocuadrado
2021-8-18 13:07:52

Yes, maybe a lambda-rec macro using the Z combinator could be nice. Thanks!


soegaard2
2021-8-18 13:19:38

FWIW Goldberg describes a more general version of Z. http://www.ccs.neu.edu/home/shivers/papers/scheme02/article/variadic-y.pdf


chansey97
2021-8-18 18:59:11

It seems to have an introduction about how to derive mutual recursion, which I didn’t realize before. Great paper! Thanks @soegaard2 .


gamburg.m
2021-8-18 19:57:25

@gamburg.m has joined the channel


panduwana
2021-8-19 06:33:11

hello


panduwana
2021-8-19 06:37:06

so it seems that a language cannot have a syntax like #!{something} in it?


panduwana
2021-8-19 06:37:15

I got “Module Language: there can only be one expression in the definitions window”


sorawee
2021-8-19 06:44:13

How do you want to use it?


sorawee
2021-8-19 06:46:03

If you create your own #lang, you can make a new readtable that maps the dispatch macro #\! to something else


sorawee
2021-8-19 06:47:32

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.