[GRASS-user] Re: Strange r.mapcalc results
Hermann Peifer
peifer at gmx.eu
Fri Sep 25 02:15:42 EDT 2009
Glynn Clements wrote:
> Hermann Peifer wrote:
>
>> Thanks indeed for the enlightening. I am new to the mapcalc business and
>> my obviously wrong (AWK-based) thinking was that mapcalc would do a lazy
>> evaluation of the conditions, i.e. "1 && 1 || something" would always
>> be 1, whatever "something" was. Now I know better.
>
> r.mapcalc never does "short-circuit" evaluation. This is true for if()
> and ?: as well as &&,||,&&&,|||.
>
> && and || propagate nulls, while &&& and ||| return non-null where
> possible. All four operators are symmetric, so e.g. "null() ||| 1" and
> "1 ||| null()" both evaluate to 1.
>
Thanks once again.
It might be worth adding this hint into the r.mapcalc documentation at:
http://grass.itc.it/grass64/manuals/html64_user/r.mapcalc.html
Hermann
More information about the grass-user
mailing list