Date:
Thu, 22 Apr 1999 21:47:13 +0200
In-Reply-To:
< [log in to unmask]> (message
from Nick Roberts on Thu, 22 Apr 1999 17:21:04 +0100)
|
Nick Roberts <[log in to unmask]> wrote:
> [...] Personally, I find the ability to define a small selection of my own
> operators in Prolog to be incredibly useful. There's no doubt that, without
> care, you can reduce your code to something resembling the output of a
> spaghetti machine on steroids; so the point is you have to take care not to
> do this. The facility is otherwise tremendously useful, e.g. instead of (in
> Ada):
>
> X := Max(Max(Max(Max(23.0-6.5*Y,Y),Y+Z),Y-Z,Limit);
> [...]
What about:
X := Max (Float_Values => (23.0-6.5*Y, Y, Y+Z, Y-Z, Limit));
With:
type Float_Array is array (Natural range <>) of Float;
function Max (Float_Values : in Float_Array) return Float;
There are of course also other function-based ways to improve
readability here without need for language built-in fancy operator
creation.
--LG
|
|
|