相当于SWI Prolog中的Python酸洗? [英] Equivalent of Python pickling in SWI Prolog?

查看:178
本文介绍了相当于SWI Prolog中的Python酸洗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Prolog程序,我正在对所有字符串进行一些暴力搜索,直到一定长度。我正在检查哪些字符串匹配某个模式,继续添加模式,直到我希望找到一组涵盖所有字符串的模式。我想将哪些文件存储到与我的任何模式都不匹配的文件中,这样当我添加新模式时,我只需要检查剩余部分,而不是再次进行整个强力搜索。

I've got a Prolog program where I'm doing some brute force search on all strings up to a certain length. I'm checking which strings match a certain pattern, keeping adding patterns until hopefully I find a set of patterns that covers all strings. I would like to store which ones to a file which don't match any of my patterns, so that when I add a new pattern, I only need to check the leftovers, instead of doing the entire brute force search again.

如果我在python中写这个,我只会挑选字符串列表,并从文件中加载它。有没有人知道如何在Prolog中做类似的事情?

If I were writing this in python, I would just pickle the list of strings, and load it from the file. Does anybody know how to do something similar in Prolog?

我有很多Prolog编程经验,但Prolog IO很少。我可能会编写一个谓词来读取一个文件并将其解析为一个术语,但我认为可能有一种方法可以更轻松地完成它。

I have a good amount of Prolog programming experience, but very little with Prolog IO. I could probably write a predicate to read a file and parse it into a term, but I figured there might be a way to do it more easily.

推荐答案

writeq 阅读做了类似的工作,但如果你申报,请阅读关于运营商的关于运营商的说明任何。

writeq and read make a similar job, but read the note on writeq about operators, if you declare any.

这篇关于相当于SWI Prolog中的Python酸洗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆