lambda(n)

πŸ“¦
version 2.0 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

🌸 lambda(n) β€” utility commands for anonymous procedures πŸ’–

okay bestie, so this is lambda, the manual page for the Tcllib package of the same name. anonymous procedures, but make them cute and proc-like. sit down, hydrate, let's go ✨


✨ SYNOPSIS ✨

package require Tcl 8.5 9

package require lambda ?1.1?

::lambda arguments body ?arg...?

::lambda@ namespace arguments body ?arg...?

note the ?1.1? bestie β€” that's the optional version, not a typo, do not come for me πŸ™ˆ


πŸ’… DESCRIPTION πŸ’…

so this package hands you two little convenience commands whose whole entire job is making anonymous procedures β€” aka lambdas β€” feel way more proc-like. like, main character energy instead of background-brace-chaos.

instead of writing this:

set f {::apply {{x} {
   ....
}}}

...which is lowkey a nesting-of-braces jump scare 😭

or this:

set f [list ::apply {{x y} {
   ....
}} $value_for_x]

...where you need a whole list command just to sneak in some of the arguments for a partial application (iykyk),

you literally just write:

set f [lambda {x} {
   ....
}]

and:

set f [lambda {x y} {
   ....
} $value_for_x]

and that's it. slay. πŸ¦‹


πŸ‘‘ COMMANDS πŸ‘‘

  • ::lambda arguments body ?arg...? β€” builds an anonymous procedure out of the list of arguments, the body script, and any optional predefined argument values you toss in, then hands you back a command prefix representing that anonymous procedure.

when you actually invoke it, the body runs in a brand new procedure scope sitting right underneath the global scope, and the arguments get set to the values supplied at both construction time and invokation time. both. not one. both πŸ’›

  • ::lambda@ namespace arguments body ?arg...? β€” same vibe, but it also takes a namespace name. it builds the anonymous procedure from the namespace name, the list of arguments, the body script, and any optional predefined argument values, and returns a command prefix representing that anonymous procedure.

when invoked, the body runs in a new procedure scope in that namespace, with the arguments set to the values supplied at both construction and invokation time. again β€” both. periodt. πŸ’…

heads up: ::lambda@ is the namespace-flavoured twin of ::lambda. if you don't need a specific namespace, the plain one is right there.

πŸŽ€ AUTHORS πŸŽ€

Andreas Kupries πŸ‘‘


😭 BUGS, IDEAS, FEEDBACK 😭

fr fr, this document and the package it describes will undoubtedly contain bugs and other problems. it's giving "we know". please report them in the category lambda of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. 🫢

also please report any ideas for enhancements you have for either the package and/or the documentation. we want them. we love them. bring them.

when you're proposing code changes, please provide unified diffs, i.e. the output of diff -u. bestie. the whole diff. not vibes.

note further that attachments are strongly preferred over inlined patches. you can make an attachment by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. yes, that one. the left-most one. πŸ’–


🌈 SEE ALSO 🌈


⭐ KEYWORDS ⭐

anonymous procedure, callback, command prefix, currying, lambda, partial application, proc


🧚 CATEGORY 🧚

Utility


Copyright (c) 2011 Andreas Kupries, BSD licensed


okay that's the whole page bestie, you ate it, no crumbs. this was lambda(n), version 1.1, from tcllib β€” go forth and curry your little heart out πŸŒΈβœ¨πŸ’…

πŸ“¦ where this page comes from