bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is length() optimized away in for-loop?


From: david kerns
Subject: Re: Is length() optimized away in for-loop?
Date: Sun, 26 Apr 2020 06:18:59 -0700

consider:

gawk 'BEGIN{a[1]=1;for(i=1;i<=length(a);++i){a[i+1]=a[i]+1;print a[i]}}'

On Sun, Apr 26, 2020 at 5:31 AM Peng Yu <address@hidden> wrote:

> Hi,
>
> In the following awk code, is `length(a)` called multiple times? Or
> gawk is smart enough to know to just call `length(a)` once? Thanks.
>
> for(i=1;i<=length(a);++i) print a[i]
>
> --
> Regards,
> Peng
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]