Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 43 |
Nodes: | 6 (0 / 6) |
Uptime: | 107:26:50 |
Calls: | 290 |
Files: | 905 |
Messages: | 76,676 |
I updated my 'seq' code because of this thread:
https://wiki.tcl-lang.org/page/seq
Luc <luc@sep.invalid> wrote:
I updated my 'seq' code because of this thread:
https://wiki.tcl-lang.org/page/seq
And, line one of the proc contains the common Tcl bug of "applying a
string operator" to a tcl list.
So thanks to you, I have updated the code once again.
On Sun, 5 Jan 2025 21:04:46 -0000 (UTC), Rich wrote:
Luc <luc@sep.invalid> wrote:
I updated my 'seq' code because of this thread:
https://wiki.tcl-lang.org/page/seq
And, line one of the proc contains the common Tcl bug of "applying a
string operator" to a tcl list.
**************************
While I admit that I never took the list to string conversion into consideration (I am repeat offender at that), you explore certain possibilities in your exposition that I did take into consideration,
and I decided that those don't matter.
Anyone who has ever used seq (or just merely understands it in spite
of never having used it) knows what the input is supposed to be: two
or three integers.
I improved on it by adding the ability to produce alphabetic sequences.
About your examples, being atypically blunt, no programmer is stupid
enough to input 08 and 08. Even I wouldn't that. Likewise, no programmer
will be stupid enough to input #08. And if anyone actually does that,
they will get the empty string. The code intentionally refuses to
produce output when the input is incorrect.
In article <vletuv$17djb$1@dont-email.me>, saito <saitology9@gmail.com> wrote:
...
I can't help but think that this may be related to your post regarding
time calculation. I had left this quote in my reply:
There is an interesting "octal" problem left as an exercise
This was exactly the exercise as well. "clock format" leaves leading
zeros in the result depending on what time it was. It is missing "string >>trimleft" calls which I'd discovered after some test runs before posting.
It is, in fact, related to that other thread. In fact, I had developed an entirely different solution to that problem (very short, in fact) which had been running fine for a few weeks until it happened to hit the dreaded "08" and crashed. I fixed that basically by adding code using "regsub" to
remove any leading zero before doing the calculations.
I'll have to take a look at "string trimleft".
And, if you are willing to use lmap, the above four lines can become
this single line:
set args [lmap arg $args {scan $arg %d}]
On Mon, 6 Jan 2025 03:12:48 -0000 (UTC), Rich wrote:
And, if you are willing to use lmap, the above four lines can become**************************
this single line:
set args [lmap arg $args {scan $arg %d}]
You are not going to believe this:
I never knew that lmap existed.
I've known lassign for a very long time.
Never knew about lmap until today.
The canonical Tcl way to handle decimal number strings with leading
zeros is to filter them through [scan] using the %d scan pattern.
$ rlwrap tclsh
% scan 08 %d
8
% scan 00000000000000000000008 %d
8
%