Re: The "leading zero means octal" thing...

Liste des GroupesRevenir à cl tcl 
Sujet : Re: The "leading zero means octal" thing...
De : rich (at) *nospam* example.invalid (Rich)
Groupes : comp.lang.tcl
Date : 06. Jan 2025, 04:12:48
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vlfhng$1ande$2@dont-email.me>
References : 1 2 3 4
User-Agent : tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Luc <luc@sep.invalid> wrote:
So thanks to you, I have updated the code once again.

You do know about the "foreach" loop, that specifically iterates across
each element of a list, right?

Even if you don't want to use lmap (which does require 8.6 IIRC) you
don't need a C style "for" loop to iterate a list.  Your "for {set x 0}
loop could be something like:

  set cleanargs {}
  foreach arg $args {
    if {[string length $arg] > 1} {
      lappend cleanargs [string trimleft $arg 0]
    } else {
      lappend cleanargs $arg
    }
  }

Alternately, since you are recreating seq, which only expects numbers
as args, you could do:

  set cleanargs {}
  foreach arg $args {
    lappend cleanargs [scan $arg %d]
  }

Which will handle any number of leading zeros (while producing decimal
output) and will error out on non-numeric inputs.

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}]


Date Sujet#  Auteur
4 Jan 25 * The "leading zero means octal" thing...23Kenny McCormack
4 Jan 25 +* Re: The "leading zero means octal" thing...2Janis Papanagnou
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
5 Jan 25 +* Re: The "leading zero means octal" thing...2Rich
5 Jan 25 i`- Re: The "leading zero means octal" thing...1Kenny McCormack
5 Jan 25 +* Re: The "leading zero means octal" thing...5Eli the Bearded
5 Jan 25 i`* Re: The "leading zero means octal" thing...4Kenny McCormack
5 Jan 25 i `* Re: The "leading zero means octal" thing...3Kenny McCormack
5 Jan 25 i  +- 'nf' in VIM (Was: The "leading zero means octal" thing...)1Kenny McCormack
5 Jan 25 i  `- Re: The "leading zero means octal" thing...1Janis Papanagnou
5 Jan 25 +- Re: The "leading zero means octal" thing...1Joe Makowiec
5 Jan 25 +* Re: The "leading zero means octal" thing...7Luc
5 Jan 25 i`* Re: The "leading zero means octal" thing...6Rich
6 Jan 25 i `* Re: The "leading zero means octal" thing...5Luc
6 Jan 25 i  +- Re: The "leading zero means octal" thing...1Rich
6 Jan 25 i  `* Re: The "leading zero means octal" thing...3Rich
6 Jan 25 i   `* Re: The "leading zero means octal" thing...2Luc
6 Jan 25 i    `- Re: The "leading zero means octal" thing...1Rich
5 Jan 25 +* Re: The "leading zero means octal" thing...4saito
5 Jan 25 i`* Re: The "leading zero means octal" thing...3Kenny McCormack
6 Jan 25 i `* Re: The "leading zero means octal" thing...2Rich
6 Jan 25 i  `- Re: The "leading zero means octal" thing...1Kenny McCormack
6 Jan 25 `- Re: The "leading zero means octal" thing...1Eric Pozharski

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal