|
|
Subscribe / Log in / New account

Alternative syntax for Python's lambda

Alternative syntax for Python's lambda

Posted Mar 5, 2021 19:39 UTC (Fri) by cpitrat (subscriber, #116459)
In reply to: Alternative syntax for Python's lambda by aeline
Parent article: Alternative syntax for Python's lambda

Stupid question: how do you type it? Do you configure your editor to have a special shortcut? Do you know the char code by heart?


to post comments

Alternative syntax for Python's lambda

Posted Mar 5, 2021 21:35 UTC (Fri) by nybble41 (subscriber, #55106) [Link] (4 responses)

I type λ using the XCompose input method. That's with this entry in my custom .XCompose file[0]:

<Multi_key> <g> <r> <l> : "λ" U03BB # GREEK SMALL LETTER LAMBDA

Here are the equivalents for lowercase a-z: αβ_δεφγηιθκλμνοπχρστυ_ωξψζ ('c' and 'v' have no corresponding entries and so were replaced with '_').
And the equivalents for uppercase A-Z: ΑΒ_ΔΕΦΓΗΙΘΚΛΜΝΟΠΧΡΣΤΥ_ΩΞΨΖ.
Also many useful symbols: → ⇒ ↑ ↓ × ÷ « » ⋄ ⊛ Ⓧ ¾ ⅞ ☺ € ₡ ¢ ∀ ∃ ±

Unfortunately Windows doesn't have any built-in equivalent to XCompose. I have a few char codes memorized for that, but λ isn't one of them.

To make this work under Linux with X11 you need to create the file ~/.XCompose, set GTK_IM_MODULE=xim and QT_IM_MODULE=xim, and assign some key to the Multi_key function in your keyboard settings. I use the Menu key for Multi_key but you might prefer something else.

[0] https://jessemcdonald.info/gogs/nybble/compose-config/raw...

Alternative syntax for Python's lambda

Posted Mar 5, 2021 21:43 UTC (Fri) by mpr22 (subscriber, #60784) [Link]

I use LeftWin for Compose myself. It's a lot easier to reach fluidly than Menu on a standard-pitch 104/105 key keyboard.

Alternative syntax for Python's lambda

Posted Mar 5, 2021 23:58 UTC (Fri) by mbunkus (subscriber, #87248) [Link]

While not built-in, I've been using the nice little Open Source program WinCompose[1] for quite a while now on Windows. It's easily configurable, both regarding the sequences as well as the key to use as the compose key, and it comes pre-configured with a wide range of sequences, a lot of which match the traditional XCompose sequences.

[1] http://wincompose.info

Alternative syntax for Python's lambda

Posted Mar 6, 2021 9:55 UTC (Sat) by LtWorf (subscriber, #124958) [Link] (1 responses)

On KDE, systemsettings allows you to pick a key to use as XComposeKey.

I don't think the env vars you are exporting are needed. I do not have them.

It used to be that GTK did not support longer sequences than 2 so I had to write them in kwrite and copy paste, but it seems to be working now for a while.

Alternative syntax for Python's lambda

Posted Mar 8, 2021 23:17 UTC (Mon) by nybble41 (subscriber, #55106) [Link]

> On KDE, systemsettings allows you to pick a key to use as XComposeKey.

Yes, that's how I have it configured. In other desktop environments you can use "setxkbmap -option compose:menu" (plus your normal model/layout options) for the same effect.

> I don't think the env vars you are exporting are needed.

If you don't set them then both Gtk and Qt will pick a default input method. If that happens to be XIM then everything will work just fine. If not, the .XCompose file might be ignored; it depends on which input method was chosen. IBUS has some support for reading .XCompose in recent versions. I'm not sure about the others.

Alternative syntax for Python's lambda

Posted Mar 6, 2021 1:49 UTC (Sat) by aeline (guest, #144768) [Link] (1 responses)

In emacs and DrRacket that hotkey Cmd-\

Alternative syntax for Python's lambda

Posted Mar 6, 2021 1:54 UTC (Sat) by aeline (guest, #144768) [Link]

DrRacket also allows most unicode, by typing \latexcode and pressing Cmd-Enter.
This is really nice for following mathematics/language papers. A snippet from a recent project:
;; Values
(v ::= n
b
∅ ;; Unit
(λ (x : t) e) ;; Value Abstraction
(Λ x e)) ;; Type Abstraction

Alternative syntax for Python's lambda

Posted Mar 10, 2021 3:50 UTC (Wed) by pj (subscriber, #4506) [Link] (1 responses)

I use kitty as a terminal and have a hotkey for unicode input where I can then type in the long name and choose it from a list. This brings up... which lambda?

U+39b is greek capital lambda
U+3bb is greek small letter lambda
U+1d27 is greek letter small capital lambda

...or one of the other 10ish mathematical lambda characters? (list at https://unicode-table.com/en/search/?q=lambda )

Is there a convention for this? is one more canonical than the others?

Alternative syntax for Python's lambda

Posted Mar 10, 2021 9:12 UTC (Wed) by mpr22 (subscriber, #60784) [Link]

.... personally, I think the answer should be "the ugaritic cuneiform one" :D

Alternative syntax for Python's lambda

Posted Mar 10, 2021 11:28 UTC (Wed) by fredrik (subscriber, #232) [Link]

In Gnome, and terminals like Alacritty, you use the generic unicode character shortcut, which is Ctrl + Shift + u followed by the unicode code point for lambda which is 03BB, which can be abreviated to 3bb, so basically:
Ctrl + Shift + u 3 b b Space
Easy as pie! 🙂

Alternative syntax for Python's lambda

Posted Mar 22, 2021 16:11 UTC (Mon) by hummassa (subscriber, #307) [Link]

<Ctrl+k>*l

:help digraphs


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds