nemo icon indicating copy to clipboard operation
nemo copied to clipboard

feature: Range builtin

Open Laschoking opened this issue 1 year ago • 1 comments

The range built-in can offer a comfortable way to generate facts. It should process 3 arguments min, max, step_size For example:

A(range(1, 5, 0.5)).
B(range(1, 5, 0.5), range(1, 5, 1)).

Laschoking avatar Jan 22 '25 10:01 Laschoking

So far, we only discussed that a built-in body predicate would be nice for this, as in

A(?X) :- IN_RANGE(?X,1,5,0.5) .
B(?X,?Y) :- IN_RANGE(?X,1,5,0.5), IN_RANGE(?Y,1,5,1) .

Whether syntactic sugar for this should be added and how this should look remains unclear. The original proposal would introduce a "special" fact format that cannot be interpreted according to the normal rules. It would be a bit like an inverse aggregation, where one fact-like statement expands into many facts. In this situation range would not be a built-in function, but rather the whole special format of range inside facts would get a different meaning from the usual "fact with a computed value of a function in some of its parameters".

mkroetzsch avatar Jan 27 '25 15:01 mkroetzsch