Is it something reasonable to define a predicate recursively on integers? Something like
pred enum i:int,o:list int.
enum 0 [].
enum N L :- enum (N - 1) L', L = [N|L'].
I can't make it work...
pred enum i:int,o:list int.
enum 0 [].
enum N L :- M is N - 1, enum M L', L = [N|L'].
It happens that N - 1
if the right type, but is not evaluated. That is the role of is
.
Also, IIRC, this function exists as std.iota
Thanks!
Last updated: Oct 13 2024 at 01:02 UTC