我正试图将我的大脑第一次包裹在Prolog(SWI-Prolog),我正在努力克服我确定的基础知识.我正试图拿一个像"馅饼"这样的字符串并打印出军事北约拼写它看起来像这样:
spellWord("Pie").
Papa
India
Echo
Run Code Online (Sandbox Code Playgroud)
目前我只是想验证我正在使用[H | T]语法和Write函数.我的功能是:
spellWord(String) :- String = [H|T], writeChar(H), spellWord(T).
writeChar(String) :- H == "P", print4("Papa").
Run Code Online (Sandbox Code Playgroud)
打电话时spellWord("Pie").这当前只返回false.