Your explanation of "lambda _" jogged my memory. I'm remembering long ago
Haskell learnings where the underscore is used in much the same way.

I'll take a look at the two references you shared. This is a really useful
starting point. Thank you again, Laurent.


On Tue, Nov 2, 2021 at 5:35 AM Laurent <[email protected]> wrote:

> On Mon, Nov 1, 2021 at 11:14 PM James Zollinger <[email protected]> wrote:
>
>> Thanks for the info, Laurent. I tried the trick outlined in the link you
>> sent me on Debian 11 versions of Gnome 3.38.5 (just to test this) and MATE
>> 1.24.1-2 (my preferred environment) without any success.
>>
>
> I haven't tried myself. For what it's worth, I wrote another quickscript
> called "command palette" that does exactly that, but of course specifically
> for DrRacket (*):
> https://gist.github.com/Metaxal/d06f50a2534ca229309e71a2d244a912
>
> Again it doesn't look into context (right click) menus as they are not
> easily accessible.
>
> (*) Actually, it could be used with any Racket GUI app!
>
>
>> My LISP/scheme/racket skills are maturing but I'm not quite ready to
>> tackle:
>>                (when (cons? stat)
>>                  (make-object menu-item%
>>                    "Print return value to console" menu
>>                    (lambda _ (send (get-tab) print-to-console
>>                                    (string-append "return val = "
>> rendered-value)))))
>> and friends! (What is "lambda _"?!)
>>
>
> Yeah, that can seem weird, but it will make sense. Let me explain in
> examples:
>
> (define f (lambda (x) (displayln x)))
> (f 3) ; ok
> (f 3 4 5) ; not ok
> (f) ; not ok
>
> (define g (lambda (x . rst) (displayln (list x rst))))
> (g 3) ; ok, equiv to (displayln '(3 ()), rst is the empty list
> (g 3 4 5) ; ok, equiv to (displayln '(3 (4 5)))
> (g) ; not ok, needs at least 1 argument
>
> (define h (lambda lst (displayln lst)))
> (h 3) ; equiv to (displayln '(3))
> (h 3 4 5) ; equiv to (displayln '(3 4 5))
> (h) ; equiv to (displayln '())
>
> Now, `_` is just an identifier like any other, like `lst`, but by (untold)
> convention it means "I won't use this argument". So
> (define k (lambda _ (displayln "hoy")))
> (k) ; equiv to (displayln "hoy")
> (k 3 4 5) ; equiv to (displayln "hoy")
>
>
>> Any suggestions on how to quickly get up to speed to
>> modify debug-tool.rkt beyond reading all of the Racket Documentation
>> <https://docs.racket-lang.org/>?
>>
>
> debug-tool.rkt is probably not the best first encounter with Racket. It
> draws on many concepts (macros, classes, gui, etc.). Though if you do
> manage to make sense of it you may learn a lot :)
>
> For this particular task, even though the file contains "units", I think
> you shouldn't have to understand units, but you will certainly have to
> understand Racket classes:
> https://docs.racket-lang.org/guide/classes.html
> and part of the GUI:
> https://docs.racket-lang.org/gui/index.html
>
> HTH,
> Laurent
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAN-sgtKa_3HNU1UNQnyhU3Hu3K7Lz%3D_WvFY-n5fbyf2eLFhvjw%40mail.gmail.com.

Reply via email to