Re: Breaking a table of record rows into an array

Liste des GroupesRevenir à cl awk 
Sujet : Re: Breaking a table of record rows into an array
De : 433-929-6894 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.awk
Date : 14. Mar 2024, 01:22:56
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20240313171753.836@kylheku.com>
References : 1 2 3 4 5 6 7 8
User-Agent : slrn/pre1.0.4-9 (Linux)
On 2024-03-13, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
That describes what happens if NF is modified by assignment, but I don't
see that it implies that such an assignment is allowed.

Here is a problem. In numerous implementations, when you set NF, not
only does that set the number of fields, but $0 is recomputed.
So instead of $1=$1 you can use NF=NF.

  $ echo '1 2 3 4' | awk -v OFS=: '{ NF=NF; print $0; }'
  1:2:3:4

  $ echo '1 2 3 4' | awk -v OFS=: '{ NF=2; print $0; }'
  1:2


We can continue to infer that if setting NF causes certain fields to
exist, and not others, then $0 must be reconstituted accordingly,
just like when a field is assigned, according to the idea that Awk
implements a kind of "reactive programming" paradigm whereby $0
and the fields are kept in sync.

But that's going a little unconfortably far on the proverbial limb,
without assurance from the text.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Date Sujet#  Auteur
11 Mar 24 * Re: Breaking a table of record rows into an array19Mr. Man-wai Chang
11 Mar 24 +- Re: Breaking a table of record rows into an array1Keith Thompson
12 Mar 24 +- Re: Breaking a table of record rows into an array1Janis Papanagnou
13 Mar 24 `* Re: Breaking a table of record rows into an array16Ed Morton
13 Mar 24  `* Re: Breaking a table of record rows into an array15Aharon Robbins
13 Mar 24   +* Re: Breaking a table of record rows into an array13Keith Thompson
13 Mar 24   i+* Re: Breaking a table of record rows into an array7Kaz Kylheku
13 Mar 24   ii`* Re: Breaking a table of record rows into an array6Keith Thompson
13 Mar 24   ii +* Re: Breaking a table of record rows into an array4Kaz Kylheku
14 Mar 24   ii i+* Re: Breaking a table of record rows into an array2Ed Morton
14 Mar 24   ii ii`- Re: Breaking a table of record rows into an array1Kaz Kylheku
14 Mar 24   ii i`- Re: Breaking a table of record rows into an array1Keith Thompson
14 Mar 24   ii `- Re: Breaking a table of record rows into an array1Kaz Kylheku
14 Mar 24   i`* Re: Breaking a table of record rows into an array5Aharon Robbins
14 Mar 24   i +- Re: Breaking a table of record rows into an array1Keith Thompson
14 Mar 24   i `* Re: Breaking a table of record rows into an array3Ed Morton
14 Mar 24   i  `* Re: Breaking a table of record rows into an array2Ed Morton
14 Mar 24   i   `- Re: Breaking a table of record rows into an array1Ed Morton
14 Mar 24   `- Re: Breaking a table of record rows into an array1Ed Morton

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal