简体   繁体   English

在SWI Prolog中使用字符串

[英]Use String in SWI Prolog

I'm a little bit confused. 我有点困惑。 I would like to use the split_string function which can be seen here . 我想使用split_string函数,可以在这里看到。 But I just don't know how to import or use this function. 但我只是不知道如何导入或使用此功能。 Do I have this pl File already on my PC? 我的PC上已经有这个pl文件吗? I can only find strings.pl in C:\\Program Files\\swipl\\library\\dialect\\ciao but I doesn't include the split_string function. 我只能在C:\\ Program Files \\ swipl \\ library \\ dialect \\ ciao中找到strings.pl,但我不包含split_string函数。

I'm pretty sure it's totally easy but I just can't figure it out. 我敢肯定这是完全容易的,但我只是想不通。

Thanks! 谢谢!

You will probably need to install the "development release" of SWI-Prolog (major version 7), if you haven't yet. 如果尚未安装,则可能需要安装SWI-Prolog的“开发版本”(主要版本7)。 On Windows and MacOS, this simply means getting the right binaries . 在Windows和MacOS上,这仅意味着获得正确的二进制文件 For Linux, you can either add the PPA (on the same page), or build from source , which is straight-forward enough. 对于Linux,您可以添加PPA(在同一页面上),也可以直接从source进行构建

Then, you will get something along the lines of: (note the banner with the version number) 然后,您将获得以下内容:(注意标有版本号的横幅)

$ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.25)
Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- split_string("a.b.c", ".", "", L).
L = ["a", "b", "c"].

You shouldn't need to import anything explicitly. 您不需要显式导入任何内容。

Does that solve your problem? 这样可以解决您的问题吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM