mlliarm / ia

An interval arithmetic library in Logtalk
Apache License 2.0
2 stars 0 forks source link

Re-implement add_n/3 #27

Open mlliarm opened 2 years ago

mlliarm commented 2 years ago

https://github.com/mlliarm/ia/blob/aa5908a78b9c91129c4a5ac99e6ed89e3b7db3f0/interval_arithmetic.lgt#L86

I think that maybe it'd be better to use add/3 adding the intervals i(N,N) and i(Xa,Xb) instead of rewriting the logic inside add_n/3.

How it could go like:

add_n(N, i(Xa, Xb), Sum) :- 
    add(i(N, N), i(Xa, Xb), Sum).

What do you think @pmoura ?

pmoura commented 2 years ago

The idea of adding a number to an interval always sounded odd to me. Maybe mark the add_n/3 predicate as deprecated in the next version of the library?

mlliarm commented 2 years ago

@pmoura

I haven't forgotten of your comment, I'm still thinking about it.

I remember seeing some examples where one could have added a number N (i.e. a degenerate interval i(N,N) ) to an interval i(M,L).

I'll have to look for that practical example(s) where such a thing could occur in applications.

You're probably right here, and this predicate could be flagged as deprecated in the next release as unnecessary; I'll have to do some more reading till then though, before agreeing with its removal.

Thanks for the suggestion!