laurent.orseau
2022-3-25 12:37:26

A little puzzle (a better one this time, I promise, but still pretty easy): Find a sequence of characters to write in place of <X> so that (begin ( <X> ) <do stuff> ...+) is equivalent to (begin <do stuff> ...+) but also so that (let ( <X> ) <do stuff> ...+) is equivalent to (let () <do stuff> ...+) Reply in thread to avoid spoilers. (edited as per @sorawee’s comments below)


sorawee
2022-3-25 12:42:51

@laurent.orseau I’m confused. Your main question is, how to convert

(let () <do stuff> ...+) to

(begin ( <X> ) <do stuff> ...+) right?

I don’t understand anything at all in:

so that this is equivalent to (begin <do stuff> ...+) and also this (let ( <X> ) <do stuff> ...+) is equivalent to (let () <do stuff> ...+) SInce

(let () <do stuff> ...+) and

(begin <do stuff> ...+) are not equivalent.


laurent.orseau
2022-3-25 12:44:14

(edited, yes it was ambiguous)


sorawee
2022-3-25 12:45:33

Still confused :disappointed:


sorawee
2022-3-25 12:47:06

Your main code is:

(let () <do stuff> ...+) But then, you ask: you want (begin ( <X> ) <do stuff> ...+) so that this is equivalent to (begin <do stuff> ...+) Why suddenly talking about two begins? What happens to the main code?


laurent.orseau
2022-3-25 12:47:41

Your task is to find a sequence of characters to put in place of <X> so that (begin ( <X> ) body ...+) is equivalent to (begin body ...+) and also so that (let ( <X> ) body ...+) is equivalent to (let () body ...+)


sorawee
2022-3-25 12:48:21

oh, ok, so I should disregard

(let () <do stuff> ...+) right?


laurent.orseau
2022-3-25 12:48:45

Because that’s where I came from. I had the original code, and I wondered how to replace let with begin while not commenting out ()


laurent.orseau
2022-3-25 12:48:50

Yes, I’ll edit


laurent.orseau
2022-3-25 12:49:48

better?


sorawee
2022-3-25 12:53:21

yep!


laurent.orseau
2022-3-25 12:53:50

Thanks for helping to clarify!


sorawee
2022-3-25 12:57:35

Not sure if this is an intended solution:

(let ([values values]) 1) ;== (let () 1) ;----------------------------- (begin ([values values]) 1) ;== (begin 1)


laurent.orseau
2022-3-25 12:58:07

It is indeed, well done :slightly_smiling_face:


laurent.orseau
2022-3-25 13:09:18

and now you can see on Discourse why this puzzle came up :slightly_smiling_face:


sorawee
2022-3-25 13:12:50

ah


capfredf
2022-3-25 14:22:15

application of any named unary function to itself?


laurent.orseau
2022-3-25 14:26:08

@capfredf Like ([+ +])? :wink:


capfredf
2022-3-25 14:28:17

“which will not raise a type error”


capfredf
2022-3-25 14:28:20

:stuck_out_tongue:


laurent.orseau
2022-3-25 14:30:15

Like ([displayln displayln]) ? :stuck_out_tongue: (though ok, you did say ‘function’)


laurent.orseau
2022-3-25 14:32:43

It also doesn’t work with parameters either: ([current-label current-label]) is ok with let, but with begin (current-label) returns the procedure current-label instead of whatever label it was containing before


capfredf
2022-3-25 14:52:37

Ah, I forgot there was an extra pair of parens


capfredf
2022-3-25 14:55:25

then any f : (-> Any (-> Any))


capfredf
2022-3-25 16:59:07

I get gtk warnings when running slideshow programs on gnome 42. I don’t think they are slideshow issues per se. Which repository should I post an issue to? racket/gui?


capfredf
2022-3-25 16:59:56

(I didn’t get them yesterday when I was on gnome 41)


laurent.orseau
2022-3-25 17:04:46

That might be correct, surprisingly. I thought only identity functions would work (I need to give it some more thought)


sorawee
2022-3-25 17:05:57

There is a further complication. Consider:

(begin ([const const]) 1) This works everywhere except at the module / top-level context, where the application is spliced out, resulting in

#<procedure:const> 1


sorawee
2022-3-25 17:06:50

@laurent.orseau it must be variadic identity, too. Otherwise, you will have arity error and/or incorrect results.


sorawee
2022-3-25 17:08:23

Perhaps

f : (-> Any (-> (values))) ?


mflatt
2022-3-25 18:22:31

racket/gui sounds right