Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Ninety percent of baseball is half mental." -- Yogi Berra


devel / comp.lang.awk / Re: Bellied numbers: From pipeline to awk

SubjectAuthor
* awk functionality not in ksh93Axel Reichert
+* Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in ksh93Kenny McCormack
|`- Re: Is ksh93 (or 2020) really better than bash? (Was: awk functionality not in kJohn McCue
+* Re: awk functionality not in ksh93Ed Morton
|`- Re: awk functionality not in ksh93Axel Reichert
`* Re: awk functionality not in ksh93Janis Papanagnou
 `* Re: awk functionality not in ksh93Axel Reichert
  `* Re: awk functionality not in ksh93Janis Papanagnou
   +* Re: awk functionality not in ksh93Ben Bacarisse
   |`- Re: awk functionality not in ksh93Janis Papanagnou
   `* Bellied numbers: From pipeline to awk (was: awk functionality not in ksh93)Axel Reichert
    +* Re: Bellied numbers: From pipeline to awk (was: awk functionality not in ksh93)Kenny McCormack
    |`* Re: Bellied numbers: From pipeline to awkAxel Reichert
    | `* Re: Bellied numbers: From pipeline to awkKenny McCormack
    |  `- Re: Bellied numbers: From pipeline to awkAxel Reichert
    +* Re: Bellied numbers: From pipeline to awk (was: awk functionality notEd Morton
    |`- Re: Bellied numbers: From pipeline to awk (was: awk functionality notEd Morton
    +* Re: Bellied numbers: From pipeline to awk (was: awk functionality notEd Morton
    |`* Re: Bellied numbers: From pipeline to awkAxel Reichert
    | +- Re: Bellied numbers: From pipeline to awkEd Morton
    | `- Re: Bellied numbers: From pipeline to awkKpop 2GM
    +* Re: Bellied numbers: From pipeline to awkJanis Papanagnou
    |`* Re: Bellied numbers: From pipeline to awkAxel Reichert
    | +* Re: Bellied numbers: From pipeline to awkJanis Papanagnou
    | |`- Re: Bellied numbers: From pipeline to awkAxel Reichert
    | `- Re: Bellied numbers: From pipeline to awkJanis Papanagnou
    `* Re: Bellied numbers: From pipeline to awk (was: awk functionalityKaz Kylheku
     `* Re: Bellied numbers: From pipeline to awkAxel Reichert
      `- Re: Bellied numbers: From pipeline to awkJanis Papanagnou

Pages:12
Re: Bellied numbers: From pipeline to awk

<svl1ok$npa$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1128&group=comp.lang.awk#1128

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: Bellied numbers: From pipeline to awk
Date: Tue, 1 Mar 2022 12:58:11 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <svl1ok$npa$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de> <sumf8m$ld9$1@dont-email.me>
<874k4vyemj.fsf@axel-reichert.de> <surlhe$n78$1@dont-email.me>
<87v8x9baba.fsf_-_@axel-reichert.de> <20220224123918.235@kylheku.com>
<87wnheli5a.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 1 Mar 2022 11:58:12 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="407795fdaf525aa634160d0c628594f5";
logging-data="24362"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mKEikwm6+ZHJBglzcQMGh"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:3yylbpFpLpCU+6rNdysCoHKmWx8=
In-Reply-To: <87wnheli5a.fsf@axel-reichert.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 1 Mar 2022 11:58 UTC

On 28.02.2022 23:51, Axel Reichert wrote:
> Kaz Kylheku <480-992-1380@kylheku.com> writes:
>
>> 1> (flow (range 1000 9999)
>> (keep-if [chain digits (ap > (+ @2 @3) (+ @1 @4))])
>> (partition-if (op neq 1 (- @2 @1)))
>> (find-max @1 : len))
>
> Interesting, how close a Lisp can get to my original pipeline. Thanks!

I'm unfamiliar with this syntax, but this looks a lot like the general
approach to tackle the task, the one that I had (informally) described
with

seq 1000 9999 | awk '
{ gsub(/./,"& ") }
{ r=r ($1+$4 < $2+$3) }
{ split(r,a,/0+/) }
END { ...sorting of or maximum in array a... }
'

and not so much like this band-worm (your "original pipeline")

seq 1000 9999 \
| sed 's/\(.\)/\1 /g' \
| awk '{if ($1+$4 < $2+$3) {print 1} else {print 0}}' \
| tr -d '\n' \
| tr -s 0 '\n' \
| sort \
| tail -n 1 \
| tr -d '\n' \
| wc -c

which is full of primitive text processing tools (tail, many tr) that
have no counterpart in the high-level-language lisp code.

Opinions obviously differ.

Janis

>
> Axel
>

Re: Bellied numbers: From pipeline to awk

<svl32t$22p$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1129&group=comp.lang.awk#1129

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: Bellied numbers: From pipeline to awk
Date: Tue, 1 Mar 2022 13:20:45 +0100
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <svl32t$22p$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de> <sumf8m$ld9$1@dont-email.me>
<874k4vyemj.fsf@axel-reichert.de> <surlhe$n78$1@dont-email.me>
<87v8x9baba.fsf_-_@axel-reichert.de> <sv5ash$6j4$1@dont-email.me>
<87h78pmf58.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 1 Mar 2022 12:20:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="407795fdaf525aa634160d0c628594f5";
logging-data="2137"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Lei77pA9b6AsKo2wMqTXZ"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:FjidXzUzHQCKBkxjLJ29FGLiv78=
In-Reply-To: <87h78pmf58.fsf@axel-reichert.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 1 Mar 2022 12:20 UTC

On 23.02.2022 22:44, Axel Reichert wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>> On 20.02.2022 20:35, Axel Reichert wrote:
>
>> I'd nonetheless had used 'sort -r' and 'head -n 1'
>
> Understood, great: "sort" does not care about the "-r", because it just
> negates the "predicate", but printing the first line is both cheaper and
> easier for awk. It seems you have learned a thing or two about Big Oh
> notation. (-;

Since you mention "Big Oh"; note that sorting (O(N log N) or O(N^2))
is more expensive than a linear find (O(N)). In case of your sample
application that you proposed in this sub-thread it may be practically
irrelevant (nowadays) to consider that, since we process only 9000
data lines. But if I want to handle larger data sets that's another
reason to prefer a simple maximum determination instead of sorting.
Just BTW. (Yes, "Big Oh" is crucial. I've heared that in interviews
for Google jobs it's also a central and important element.)

>
> I tend to neglect this, being used to much larger number crunching
> efforts than the modest 10^4 numbers here. Thanks for reminding me.
>
>> build binary string r=r ($1+$4 < $2+$3)
>
> Great, another feature that I tend to forget, the default string
> concatenation. Very elegant in combination with the C-style boolean.
>
>> seq 1000 9999 | awk '
>> { gsub(/./,"& ") }
>> m=($1+$4 < $2+$3) { if (++c>max) max=c }
>> !m { c=0 }
>> END { print max }
>
> Great. That kind of stuff I was after and eager to learn!
>
>> (Ah, okay, you want the numbers also generated by awk. I assumed that
>> 'seq' was just an example input source that could be in principle any
>> process or file as data source.
>
> In general I agree, but here it is one of the conceptual obstacles in my
> way of thinking. So far I believe there did not come up any post in this
> thread that shows how to "feed" output from the BEGIN block to the rest
> of the "awk" program. Or did I miss something?

I'm not sure I understand what you wrote here. If you are saying that
you want to generate the sequence numbers in the BEGIN block and pass
them to the implicit awk-processing-loop then yes, that's not possible.
You would then do the whole processing in the BEGIN block using a loop;
I think I've seen someone in this sub-thread posting such a loop-based
awk-solution.

Personally I tend to and intuitively separate data generation from the
data processing as consequence of a design and usability experience;
that's why it didn't occur to me (before I saw your post) that it was
part of the "code puzzle".

Janis

Re: Bellied numbers: From pipeline to awk

<svl3ub$8bf$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1130&group=comp.lang.awk#1130

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_papanagnou@hotmail.com (Janis Papanagnou)
Newsgroups: comp.lang.awk
Subject: Re: Bellied numbers: From pipeline to awk
Date: Tue, 1 Mar 2022 13:35:22 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <svl3ub$8bf$1@dont-email.me>
References: <87fsohxmuc.fsf@axel-reichert.de> <sumf8m$ld9$1@dont-email.me>
<874k4vyemj.fsf@axel-reichert.de> <surlhe$n78$1@dont-email.me>
<87v8x9baba.fsf_-_@axel-reichert.de> <sv5ash$6j4$1@dont-email.me>
<87h78pmf58.fsf@axel-reichert.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 1 Mar 2022 12:35:23 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="407795fdaf525aa634160d0c628594f5";
logging-data="8559"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/azUHeSKEEM9+T5i809NDS"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:lTboo6rjitZZEKT9J1s9FHlpRt8=
In-Reply-To: <87h78pmf58.fsf@axel-reichert.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Tue, 1 Mar 2022 12:35 UTC

On 23.02.2022 22:44, Axel Reichert wrote:
> Janis Papanagnou <janis_papanagnou@hotmail.com> writes:
>
>> build binary string r=r ($1+$4 < $2+$3)

(I forgot to comment on that. - A caveat for the general case here.)

> Great, another feature that I tend to forget, the default string
> concatenation. Very elegant in combination with the C-style boolean.

Since we were talking about "Big Oh"... - Note that in case of large
strings or data sets such concatenations can be expensive (depending
on the Awk version you use). GNU Awk has a built-in optimization for
the x = x ... cases of concatenations, though, so it's cheap here.

Janis

Re: Bellied numbers: From pipeline to awk

<87fso1lb92.fsf@axel-reichert.de>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1132&group=comp.lang.awk#1132

  copy link   Newsgroups: comp.lang.awk
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mail@axel-reichert.de (Axel Reichert)
Newsgroups: comp.lang.awk
Subject: Re: Bellied numbers: From pipeline to awk
Date: Tue, 01 Mar 2022 20:32:25 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <87fso1lb92.fsf@axel-reichert.de>
References: <87fsohxmuc.fsf@axel-reichert.de> <sumf8m$ld9$1@dont-email.me>
<874k4vyemj.fsf@axel-reichert.de> <surlhe$n78$1@dont-email.me>
<87v8x9baba.fsf_-_@axel-reichert.de> <sv5ash$6j4$1@dont-email.me>
<87h78pmf58.fsf@axel-reichert.de> <svl32t$22p$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="022f7eff28c73cc4a017ef13a5c7ab87";
logging-data="2286"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183VbqDrFXsfvW6SUwM30yfMLjdWa0WepU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:y0OYpWRO2V8Va9KM6TnahxJvYDU=
sha1:XUDVTIAgoBO91/iH0csKp2VjRac=
 by: Axel Reichert - Tue, 1 Mar 2022 19:32 UTC

Janis Papanagnou <janis_papanagnou@hotmail.com> writes:

> If you are saying that you want to generate the sequence numbers in
> the BEGIN block and pass them to the implicit awk-processing-loop

Yes.

> then yes, that's not possible.

O. K., thanks.

> You would then do the whole processing in the BEGIN block using a loop;
> I think I've seen someone in this sub-thread posting such a loop-based
> awk-solution.

Yes, you maybe right.

> Personally I tend to and intuitively separate data generation from the
> data processing as consequence of a design and usability experience

Makes sense.

Best regards

Axel

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor