Hello, Olaf!
My point was that in Haskell we define how to calculate result from arguments, exactly as in C# and with the same pattern-matching. But in Prolog I coded relation, so Prolog know how to calculate not only factorial but also argument from the result like we have 2 different evaluation coded in Prolog. Currently it's obvious: there are different classification. I showed only what I myself studied as a student :)Your own example of factorial is very much declarative in the above sense, because it only declares what the factorial function is, in terms of the relationship between factorial(n) and factorial(n-1). Of course the functional programmer must have a mental model of the runtime's behaviour in mind. (Recursively calling the function, in this case.) But what happens on the lower, imperative level when computing factorial(n) is not relevant for the definition of the function.
`e1 && e2` is equals to `if e1 then e2`. And there is a lot of code which relies on this. Why they implements boolean operations in such way? Order has not matter for +, -, *, etc in the same languages (they are commutative). Why so many languages have not commutative bool operations? When i think about it, i find next example: Haskell function is pure, but is it really true? :) In practical world we can have 2 functions one like `f a b = a + b`. And another `g` may be some wavelet transformation or calculation of some super big fractal. No side effects (effects in external world), but when you evaluate `f` - you can not see effect. But when you calculate `g` - you can even touch the effect on CPU case with fingers (it will be hot!) :-) So, there is difference to write `f && g` or `g && f`. If some code relies on order of execution and use `&&` instead of `if` - it has matter. May be bool operations were not implemented commutative in those languages because it allows to write "multi-ifs" (a & b & c & d ...) in short circuit way? I never though about this early :) I remember that there were orelse and andalso in Basic and Ocaml... So, seems there is such tradition in CS: to have mandatory non-commutative and's/or's and optionally commutative and's/or's ?do a <- ma b <- mb f a b is equal to:
do b <- mb a <- ma f a b
&& and || are commutative sure. But question is: why in this case in C/C++, Bash (what else) order has matter, even more: order is fixed in standard.