I was exploring the write predicate in Prolog but it behaves differently at times. I did go through some posts but I am unable to spot the catch.
Predicate :
explore_write_predicate(InputList,Index):-
TempIndex is Index+1,
select(Element,InputList,TempList),
write(TempIndex).
query:
explore_write_predicate([1,2,3,4],1).
Result :
2
true
The above code works fine but when I add one more argument to the write predicate(Element) it gives an error.
Predicate :
explore_write_predicate(InputList,Index):-
TempIndex is Index+1,
select(Element,InputList,TempList),
write(TempIndex,Element).
query:
explore_write_predicate([1,2,3,4],1).
Error:
No permission to call sandboxed `write(_1132,_1134)'
Reachable from:
explore_write_predicate(A,B)
swish_trace:swish_call(explore_write_predicate([1,2,3,4],1))
'$swish wrapper'(explore_write_predicate([1,2,3,4],1),A)
Please help me why this anomaly. P.S I also saw the documentation for write but could not get much out of it. Any help is greatly appreciated.
write([TempIndex,Element])
to make it work. – Enigmativitywrite(TempIndex=Element)
– CapelliCwriteq
instead! – false