I'm new with yap
(and with Prolog in general), and I can't figure out how to get the current directory.
In fact, I can't make sense of the documentation:
working_directory(-CurDir,?NextDir)
Fetch the current directory at
CurDir
. IfNextDir
is bound to an atom, make its value the current working directory.
I don't understand what's meant by "at CurDir
".
Also, I can't find documentation on the -
and ?
preceding the formal arguments. (I guess that the ?
means that the argument is optional, but I have no clue about the -
.)
Bottom line, I can't figure out how to use this information to query for the current working directory.
I've tried many blind guesses, and always get either no.
or an error in response. E.g.:
$ yap
% Restoring file /usr/lib/Yap/startup.yss
YAP 6.2.2 (x86_64-linux): Sat Nov 23 17:51:47 UTC 2013
?- working_directory(CurDir).
no
?- working_directory(-CurDir).
no
?- working_directory().
SYNTAX ERROR at user, near line 7:
working_directory(
<==== HERE ====>
).
?- working_directory.
no
?- CurDir.
ERROR!!
INSTANTIATION ERROR- meta_call(_131099): expected bound value
?- -CurDir.
no
?- working_directory('.').
no
?- working_directory(-'.').
no
I have two questions:
- Where can I find meta-documentation on the
-
,?
, and+
that appear in front of formal arguments in theyap
documentation? - How do I get the current working directory?
UPDATE: The following also fail:
$ yap
% Restoring file /usr/lib/Yap/startup.yss
YAP 6.2.2 (x86_64-linux): Sat Nov 23 17:51:47 UTC 2013
?- working_directory(X, '').
no
?- working_directory(X, X).
no