【问题标题】:Stuck in Prolog Directory卡在 Prolog 目录中
【发布时间】:2017-05-05 19:16:31
【问题描述】:

我刚刚开始使用 prolog,必须用它做一个项目。我的教授花了整整 10 分钟的时间,然后给我们分配了一个最终项目。我正在尝试完成它,但我不明白如何切换目录。我知道你应该使用working_directory(oldDir,newDir)。但我被困在我的 oldDir 中并说我的 newDir 不存在。我的 oldDir 是 /Applications/ 并且我正在尝试访问 /Documents/ 但它告诉我这不存在。

这正是我尝试过的:

?- working_directory(CWD,'/Documents/').
ERROR: directory `'/Documents/'' does not exist
ERROR: In:
ERROR:    [9] '$chdir'('/Documents/')
ERROR:    [7] <user>
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?-

请帮忙!如果我什么都不能检查,我就不能做我的项目。

【问题讨论】:

  • 我认为/Documents/不是一个好的工作目录名,试试'c:/users//Documents/' 如果您使用 Windows。无论如何,尝试 working_directory(CWD, CWD)。 以了解当前工作目录的名称。
  • 不幸的是,我使用的是 Mac。这就是我知道我在应用程序文件夹中的方式,所以我想我真正的问题是我被困在那个文件夹中并且无法导航出来。

标签: prolog swi-prolog


【解决方案1】:

试试 working_directory(CWD,“文档”)。

【讨论】:

  • 当我这样做时,我得到:错误:目录 `'Documents'' 不存在 错误:在:错误:[9] '$chdir'('Documents') 错误:[8] '$syspreds':working_directory(//,'Documents') at /Applications/SWI-Prolog.app/Contents/swipl/boot/syspred.pl:1102 错误:[7]
  • 运行swipl的在哪个目录下?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-06-08
  • 1970-01-01
  • 1970-01-01
  • 2016-10-08
  • 1970-01-01
相关资源
最近更新 更多