1
votes

I have just started with Prolog for one of my classes so it's quite basic. I just had a doubt that does Prolog not have any inbuilt functions that can be used directly or should we always be writing a set of facts and rules first and then use them? I was trying to run this function:

?-transpose([[1,2,3],[4,5,6],[7,8,9]],Ts).

Which gave me this error:

ERROR: Undefined procedure: transpose/2 (DWIM could not correct goal)

So, basically, my question is, do I need to write how the transpose would work? I thought it was an inbuilt function ready to use.

P.S.: I am using: SWI-Prolog (threaded, 64 bits, version 7.6.0-rc1)

1

1 Answers

2
votes

Of course it has quite a few built-in predicates (listed in http://www.swi-prolog.org/pldoc/man?section=builtin) but transpose is not one of them. If it's "for one of my classes so it's quite basic", most likely you are expected to write transpose yourself, especially if it's your first Prolog class.

There is one in clfpd library, see How to use predicate transpose in SWI-Prolog?.