bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: wishes


From: Aharon Robbins
Subject: Re: wishes
Date: Mon, 07 Aug 2006 22:56:18 +0300

Greetings. Re this:

> Date: Mon, 07 Aug 2006 15:42:23 +0200
> From: address@hidden
> Subject: wishes
> To: address@hidden
>
> Hi,
>
> I'm using gawk for the effective processing of table like numerical data.
> However, typically I don't use special awk script, but just call it from
> the command line.
> For that reason I only can use  the very limited number of built-in
> numerical functions.
>
> Therefore my wish:
>
> Could you implement e.g. a min() and max() function. Ideally these should
> accept arbitrary
> numbers of input arguments. I.e.
>
> min($1, $2)

This one is easy:

        function min(a, b)
        {
                if ((a+0) < (b+0))
                        return a + 0
                else
                        return b + 0
        }

> min($1, $3, $4, $5)

This one should be written to accept an array argument:

        function min_a(data,    i, result)
        {
                for (i in data)
                        if ((data[i] + 0) < result)
                                result = data[i] + 0

                return result
        }

As Juergen pointed out, there are other options as well.

Thanks,

Arnold




reply via email to

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