我有一些.pl
文件,我想从python脚本调用其中声明的谓词。我怎样才能做到这一点?
例如, test.pl
rD( [], Ans, Ans ).
rD( [X|Xs], Ans, Acc ) :-
member( X, Acc ),
rD( Xs, Ans, Acc ), !.
rD( [X|Xs], Ans, Acc ) :-
\+member( X, Acc ),
append( Acc, [X], AccNew ),
rD( Xs, Ans, AccNew ), !.
Run Code Online (Sandbox Code Playgroud)
像
?- rD( [1,2,3,4,5,4], X ).
X = [1, 2, 3, 4, 5].
Run Code Online (Sandbox Code Playgroud)
我想以rD
某种方式从python脚本调用并在结果变量中获取答案
result
[1, 2, 3, 4, 5]
Run Code Online (Sandbox Code Playgroud)
ps:这只是一个例子,我不想重写当前的Prolog程序。
我看到一些涉及monad实例的奇怪行为.我正在编写一个快照应用程序,在我的一个处理程序中,除非我创建一个函数,否则它将无法编译.
withManager
直接在我的处理程序中调用如下:
authenticateLanding :: Handler App App ()
authenticateLanding = do
req <- getRequest
oir <- liftIO $ withManager $ OpenId.authenticateClaimed (convertParams req)
writeBS (fromString $ show oir)
Run Code Online (Sandbox Code Playgroud)
导致此编译时错误
openIDTrial.hs:120:25:
No instance for (Control.Monad.Trans.Control.MonadBaseControl
IO m1)
arising from a use of `withManager'
Possible fix:
add an instance declaration for
(Control.Monad.Trans.Control.MonadBaseControl IO m1)
In the expression: withManager
In the second argument of `($)', namely
`withManager $ OpenId.authenticateClaimed (convertParams req)'
In a stmt of a 'do' block:
oir <- liftIO
$ …
Run Code Online (Sandbox Code Playgroud) 我试着寻找一个答案,但没有发现任何匹配这个问题.如果已有答案,请随时将我链接到答案.
我所做的是提交并推送大量更改作为一次提交.虽然我没有把那个推入合并到主人.我现在想在上演任何内容之前回到状态,所以我可以将更改分阶段提交.
我尝试使用推送的更改创建一个新分支(已保存的工作),删除原始远程分支(用户登录),然后将新分支合并到原始本地分支,但这只是让我回到我所在的位置现在,用户登录分支不包含任何要添加/提交的内容.
那么我如何获得所有这些更改,以便我可以单独审核和分阶段(使用git add -p)?
有没有办法定义自动运行谓词,它将在加载文件后运行?
是的,我知道swipl -s file.pl -g "main."
,但仍在寻找可以放在源文件中的东西file.pl
我怎样才能舒展一些字符串元素_text
从
A
B
C
Run Code Online (Sandbox Code Playgroud)
至
A
B
C
Run Code Online (Sandbox Code Playgroud)
?
实际上,我有一些来自DB的文本
_text = this.NormalizeString(DinamicLibrary.LoadText(DinamicLibrary.Path[(int)_category] + _textdllName, this.TextNumber));
Run Code Online (Sandbox Code Playgroud)
我应该怎么处理这个查询或_text
以后获得我想要的东西?我知道我应该改变\n
到\n\n
,但不知道怎么样.
我是Haskell的新手,我只是想编写一个简单的列表解析来从列表列表中删除空列表的每个实例,即输入此..
> remove ["abfwfw", "wfgwg", "", "dfw"]
Run Code Online (Sandbox Code Playgroud)
将导致此输出...
> ["abfwfw", "wfgwg", "dfw"]
Run Code Online (Sandbox Code Playgroud)
提前致谢 :)
如何将trial
输出转换为JUnit xml格式?没有这种可能的报告格式trial
.
$> trial --help-reporters
Trial's output can be customized using plugins called Reporters. You can
select any of the following reporters using --reporter=<foo>
subunit subunit output
bwverbose Colorless verbose output
text terse text output
verbose verbose color output (default reporter)
timing Timing output
summary minimal summary output
Run Code Online (Sandbox Code Playgroud) import Data.Attoparsec.Text.Lazy
import Data.Text.Lazy.Internal (Text)
import Data.Text.Lazy (pack)
data List a = Nil | Cons a (List a)
list :: Text
list = pack $ unlines
[ "0"
, "1"
, "2"
, "5"
]
Run Code Online (Sandbox Code Playgroud)
如何List Int
解析器coud实现解析Cons 0 (Cons 1 (Cons 2 (Cons 5 Nil)))
从list
?
ps:纯解析器而不解析a [Int]
并将其转换List Int
为更好.
假设有一个F#
定义:
type Either<'a,'b> = | Left of 'a | Right of 'b
let f (i : int) : Either<int, string> =
if i > 0
then Left i
else Right "nothing"
Run Code Online (Sandbox Code Playgroud)
函数f
用于C#
代码:
var a = Library.f(5);
Run Code Online (Sandbox Code Playgroud)
结果值如何a
与数据构造函数进行模式匹配?就像是:
/*
(if a is Left x)
do something with x
(if a is Right y)
do something with y
*/
Run Code Online (Sandbox Code Playgroud)