Is there any interest in incorporating an algorithms package into tcllib, which would include command binding (similar to tr1::bind in C++), and generalized algorithm implementations (similar to STL algorithms in C++)? Here is a snippet of documentation for the library I developed for my own needs:
-Andy
*bindcmd*
An argument-binding utility loosely modeled after tr1::bind of C++.
Allows users to generate in-place "callable entities". The user is
able to bind a literal argument list to a particular command, while
discarding or reordering the remaining input arguments. A command in
this context is anything that can be passed to the Tcl interpreter
(i.e. it need not be a built-in command or user proc). Bound
commands have append calling symantics similar to [ namespace code ]
expressions.
The special "placeholder" tokens _1, _2, _3, etc... are used to bind
particular arguments to particular locations in the expression.
For instance, the following statement creates a command stored in
the variable isLt5 that takes one additional parameter (indicated by
_1), and compares it against 5 using the "less than" operator,
returning the result of the comparison.
% set isLt5 [ bindcmd expr _1 < 5 ]
The _1 token represent the first argument in the user's parameter
list, which will be passed in later.
To call the function stored in isLt5, simply dereference the
variable at the beginning of a statement, where the Tcl interpreter
expects to find a command, and append the additional argument(s).
For example:
% $isLt5 4; # 1
% $isLt5 8; # 0
*bindcmd* is useful when paired with general algorithms (similar to
the way tr1::bind is often used with STL standard algorithms in
C++). For instance, $isLt5 could be used with the copy_if algorithm
to select elements from a list:
% set L [ list 9 3 5 8 1 2 1 ]
% set ans [ copy_if $L $isLt5 ]; # 3 1 2 1
The bound command is always called in the global scope, although
"namespace code" can be used to tie it to a different scope. For
instance:
% namespace eval foo {
proc bar {x y} { return [ expr $x + $y ] }
set bar1 [ bindcmd bar _1 1 ]; # wrong! No proc "bar" in global scope
set bar1 [ bindcmd [ namespace code bar ] _1 1 ]; # correct
}
% $foo::bar1 5; # 6
It is acceptable to supply more or fewer arguments than the highest
placeholder. For instance, the functions defined below can each be
called with 1, 2, 3 or more arguments, however, if more than 2
arguments are supplied, then only the first two will be used:
% set eqStr [ bindcmd string equal _1 _2 ]
% set list2 [ bindcmd list _1 _2 ]
Any missing arguments will be omitted from the function call:
% $eqStr {} {}; # 1
% $eqStr {}; # Error! Wrong # args.
% $list2 ; # empty list.
% $list2 a; # a
% $list2 a b c; # a b
The argument order can be modified by changing the order of the
placeholder arguments, as shown below:
% set doublet [ bindcmd list _1 _1 ]
% $doublet a; # a a
The placeholder numbers need not be sequential, and any argument
corresponding to an unused placeholder will be discarded. For
example:
% set doublet2nd [ bindcmd list _2 _2 ]
% $doublet2nd a; # empty list
% $doublet2nd a b; # b b
There is no upper bound on the placeholder ordinals:
% set get1000000 [ bindcmd format %s _1000000 ]; # valid, but not recommended
Command nesting can be achieved by using the helper function *infix*
within a bindcmd statement. For instance, the function $get2nd below
gets element 2 from a list, and the function $less2nd compares the
2nd elements of two lists with the < operator. This is accomplished
by infixing $get2nd within $less2nd:
Here, the placeholders _1 and _2 within the infix expressions still
refer to positions in the argument list for $less2nd (i.e. these
parameter locations are forwarded to the outermost expression).
Lists containing any of the placeholder tokens are not allowed in
the bindcmd declaration (they are fine in the input data list);
instead, infix the list command:
% set get_1of3 [ bindcmd lindex {_2 _3 _4} _1 ]; # wrong!
% set get_1of3 [ bindcmd lindex [ infix list _2 _3 _4 ] _1 ]; # ok
% $get_1of3 0 a b c; # a
% $get_1of3 1 _1 _2 _3; # _2 (ok)
Placeholders are treated as separate terms of the command, and
whitespace will be added as needed to disambiguate expressions. In
particular, positioning a placeholder next to other characters does
not cause concatenation. For instance, the following two definitions
of F are identical, which might not be what you expect:
% set F [ bindcmd string match _1* _2 ]; # wrong
% $F ab abc; # error!
% set F [ bindcmd string match _1 * _2 ]; # same thing (wrong)
% $F ab abc; # error!
To perform concatenation, infix the format command, like so:
% set F [ bindcmd string match [ infix format %s* _1 ] _2 ]; # correct
% $F ab abc; # 1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Your proposal to integrate an algorithms package into tcllib sounds promising, especially with the introduction of a bindcmd utility. This would greatly enhance the flexibility and efficiency of command manipulation in Tcl, similar to how tr1::bind and STL algorithms function in C++. Your detailed examples illustrate its potential to streamline tasks that involve argument binding and algorithmic operations. I believe this could be a valuable addition to tcllib, fostering more powerful and expressive code. It would be interesting to see how the community responds to this idea.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Honista is a lifestyle brand dedicated to enhancing the everyday moments that matter. With a commitment to quality, sustainability, and style, Honista offers a curated selection of products designed to inspire and uplift. https://honistaapk.me/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For those interested in an algorithms package or similar tech tools, finding the right apps to support coding, learning, and optimization can be essential. https://goapks.com/ provides a vast collection of APKs, including utilities and educational apps that could be valuable for anyone working with algorithms or programming.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When exploring an algorithms package, having the right tools to manage and test sensitive data becomes crucial. texto invisible provides a secure platform to handle confidential information, making it an ideal companion for algorithm development and collaboration. Its user-friendly interface ensures privacy while facilitating seamless communication, perfect for projects that require data security and precision.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Pelisplus APK is an application designed for Android devices that provides users with access to a vast library of movies and TV shows. It serves as a third-party streaming service, offering content that users can watch for free. The platform is particularly popular among users looking for a wide array of entertainment options without the need for subscriptions or rentals https://pelisplusapk.mx/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Game Vaults are a vital part of the future of video games. As the gaming industry continues to grow and evolve, it is crucial to maintain a sense of history and preserve the games that have shaped the medium. https://game-vault.us/download/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The main benefit of using Zefoy Followers is the instant increase in credibility. When visitors see a TikTok profile with a higher follower count, they’re more likely to engage, follow, or share the content. More followers also signal to TikTok’s algorithm that your content is worth promoting, increasing your chances of landing on the For You Page.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Delta Executor is a free and efficient Roblox script executor that allows users to run custom Lua scripts within the Roblox platform. It is commonly used by gamers to unlock in-game features, automate actions, or experiment with mods.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Delta Executor is a popular and free Roblox script executor that lets users run custom Lua scripts within the Roblox platform. It's widely used by players to unlock hidden features, automate tasks, or explore game mechanics beyond what's normally allowed.
If you're looking for the latest stable version, you can download delta 2.675 for Android — it's updated for better compatibility and performance.
For iOS users, there's also a mobile-friendly version available. You can get delta 2.675 ipa to run scripts directly on your iPhone or iPad without needing a PC.
Crafted for creators who love bold personality and vibrant style, this tool blends cute aesthetics with playful attitude. At its heart, brat generator pink brings a burst of sassy, bubblegum-bright energy, transforming ordinary ideas into lively characters full of charm and confidence. Perfect for adding flair, personality, and a touch of mischief to any project, it turns creativity into something irresistibly fun and stylish.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Is there any interest in incorporating an algorithms package into tcllib, which would include command binding (similar to tr1::bind in C++), and generalized algorithm implementations (similar to STL algorithms in C++)? Here is a snippet of documentation for the library I developed for my own needs:
-Andy
*bindcmd*
An argument-binding utility loosely modeled after tr1::bind of C++.
Allows users to generate in-place "callable entities". The user is
able to bind a literal argument list to a particular command, while
discarding or reordering the remaining input arguments. A command in
this context is anything that can be passed to the Tcl interpreter
(i.e. it need not be a built-in command or user proc). Bound
commands have append calling symantics similar to [ namespace code ]
expressions.
The special "placeholder" tokens _1, _2, _3, etc... are used to bind
particular arguments to particular locations in the expression.
For instance, the following statement creates a command stored in
the variable isLt5 that takes one additional parameter (indicated by
_1), and compares it against 5 using the "less than" operator,
returning the result of the comparison.
% set isLt5 [ bindcmd expr _1 < 5 ]
The _1 token represent the first argument in the user's parameter
list, which will be passed in later.
To call the function stored in isLt5, simply dereference the
variable at the beginning of a statement, where the Tcl interpreter
expects to find a command, and append the additional argument(s).
For example:
% $isLt5 4; # 1
% $isLt5 8; # 0
*bindcmd* is useful when paired with general algorithms (similar to
the way tr1::bind is often used with STL standard algorithms in
C++). For instance, $isLt5 could be used with the copy_if algorithm
to select elements from a list:
% set L [ list 9 3 5 8 1 2 1 ]
% set ans [ copy_if $L $isLt5 ]; # 3 1 2 1
The bound command is always called in the global scope, although
"namespace code" can be used to tie it to a different scope. For
instance:
% namespace eval foo {
proc bar {x y} { return [ expr $x + $y ] }
set bar1 [ bindcmd bar _1 1 ]; # wrong! No proc "bar" in global scope
set bar1 [ bindcmd [ namespace code bar ] _1 1 ]; # correct
}
% $foo::bar1 5; # 6
It is acceptable to supply more or fewer arguments than the highest
placeholder. For instance, the functions defined below can each be
called with 1, 2, 3 or more arguments, however, if more than 2
arguments are supplied, then only the first two will be used:
% set eqStr [ bindcmd string equal _1 _2 ]
% set list2 [ bindcmd list _1 _2 ]
Any missing arguments will be omitted from the function call:
% $eqStr {} {}; # 1
% $eqStr {}; # Error! Wrong # args.
% $list2 ; # empty list.
% $list2 a; # a
% $list2 a b c; # a b
The argument order can be modified by changing the order of the
placeholder arguments, as shown below:
% set divides [ bindcmd expr fmod(_2, _1) == 0 ]
% $divides 3 6; # 1
% $divides 7 10; # 0
Duplicate placeholders are allowed, for example:
% set doublet [ bindcmd list _1 _1 ]
% $doublet a; # a a
The placeholder numbers need not be sequential, and any argument
corresponding to an unused placeholder will be discarded. For
example:
% set doublet2nd [ bindcmd list _2 _2 ]
% $doublet2nd a; # empty list
% $doublet2nd a b; # b b
There is no upper bound on the placeholder ordinals:
% set get1000000 [ bindcmd format %s _1000000 ]; # valid, but not recommended
Command nesting can be achieved by using the helper function *infix*
within a bindcmd statement. For instance, the function $get2nd below
gets element 2 from a list, and the function $less2nd compares the
2nd elements of two lists with the < operator. This is accomplished
by infixing $get2nd within $less2nd:
% set get2nd [ bindcmd lindex _1 1 ]
% set less2nd [ bindcmd expr [ infix $get2nd _1 ] < [ infix $get2nd _2 ] ]
% $less2nd [ list 1 9 1 ] [ list 2 1 2 ]; # 0 (9 < 1)
Here, the placeholders _1 and _2 within the infix expressions still
refer to positions in the argument list for $less2nd (i.e. these
parameter locations are forwarded to the outermost expression).
Lists containing any of the placeholder tokens are not allowed in
the bindcmd declaration (they are fine in the input data list);
instead, infix the list command:
% set get_1of3 [ bindcmd lindex {_2 _3 _4} _1 ]; # wrong!
% set get_1of3 [ bindcmd lindex [ infix list _2 _3 _4 ] _1 ]; # ok
% $get_1of3 0 a b c; # a
% $get_1of3 1 _1 _2 _3; # _2 (ok)
Placeholders are treated as separate terms of the command, and
whitespace will be added as needed to disambiguate expressions. In
particular, positioning a placeholder next to other characters does
not cause concatenation. For instance, the following two definitions
of F are identical, which might not be what you expect:
% set F [ bindcmd string match _1* _2 ]; # wrong
% $F ab abc; # error!
% set F [ bindcmd string match _1 * _2 ]; # same thing (wrong)
% $F ab abc; # error!
To perform concatenation, infix the format command, like so:
% set F [ bindcmd string match [ infix format %s* _1 ] _2 ]; # correct
% $F ab abc; # 1
That above sounds a bit like apply in Tcl 8.5.
A better place to discuss this would probably be the Tcllib mailing list or the newsgroup comp.lang.tcl.
Michael
Your proposal to integrate an algorithms package into tcllib sounds promising, especially with the introduction of a bindcmd utility. This would greatly enhance the flexibility and efficiency of command manipulation in Tcl, similar to how tr1::bind and STL algorithms function in C++. Your detailed examples illustrate its potential to streamline tasks that involve argument binding and algorithmic operations. I believe this could be a valuable addition to tcllib, fostering more powerful and expressive code. It would be interesting to see how the community responds to this idea.
Honista is a lifestyle brand dedicated to enhancing the everyday moments that matter. With a commitment to quality, sustainability, and style, Honista offers a curated selection of products designed to inspire and uplift.
https://honistaapk.me/
For those interested in an algorithms package or similar tech tools, finding the right apps to support coding, learning, and optimization can be essential. https://goapks.com/ provides a vast collection of APKs, including utilities and educational apps that could be valuable for anyone working with algorithms or programming.
When exploring an algorithms package, having the right tools to manage and test sensitive data becomes crucial. texto invisible provides a secure platform to handle confidential information, making it an ideal companion for algorithm development and collaboration. Its user-friendly interface ensures privacy while facilitating seamless communication, perfect for projects that require data security and precision.
Pelisplus APK is an application designed for Android devices that provides users with access to a vast library of movies and TV shows. It serves as a third-party streaming service, offering content that users can watch for free. The platform is particularly popular among users looking for a wide array of entertainment options without the need for subscriptions or rentals
https://pelisplusapk.mx/
Game Vaults are a vital part of the future of video games. As the gaming industry continues to grow and evolve, it is crucial to maintain a sense of history and preserve the games that have shaped the medium.
https://game-vault.us/download/
The main benefit of using Zefoy Followers is the instant increase in credibility. When visitors see a TikTok profile with a higher follower count, they’re more likely to engage, follow, or share the content. More followers also signal to TikTok’s algorithm that your content is worth promoting, increasing your chances of landing on the For You Page.
Delta Executor is a free and efficient Roblox script executor that allows users to run custom Lua scripts within the Roblox platform. It is commonly used by gamers to unlock in-game features, automate actions, or experiment with mods.
Delta Executor is a popular and free Roblox script executor that lets users run custom Lua scripts within the Roblox platform. It's widely used by players to unlock hidden features, automate tasks, or explore game mechanics beyond what's normally allowed.
If you're looking for the latest stable version, you can download delta 2.675 for Android — it's updated for better compatibility and performance.
For iOS users, there's also a mobile-friendly version available. You can get delta 2.675 ipa to run scripts directly on your iPhone or iPad without needing a PC.
Crafted for creators who love bold personality and vibrant style, this tool blends cute aesthetics with playful attitude. At its heart, brat generator pink brings a burst of sassy, bubblegum-bright energy, transforming ordinary ideas into lively characters full of charm and confidence. Perfect for adding flair, personality, and a touch of mischief to any project, it turns creativity into something irresistibly fun and stylish.