我写了一个简单的守护进程.这个守护进程应该在我运行任何程序时响应.这该怎么做?在一个大守护进程循环中:
while(1)
{
/* function which catches new programm running */
}
Run Code Online (Sandbox Code Playgroud)
当我运行一个新程序(创建新进程)时,在linux中调用什么函数?
例如,我有:
upred(mary, have, knife).
upred(john, have, sword).
upred(sam, have, bowl).
upred(sword, is, long).
Run Code Online (Sandbox Code Playgroud)
我怎样才能获得随机谓词?
% call this and get random predicate as Pred
get_random_pred(Pred) :-
Run Code Online (Sandbox Code Playgroud) 我写了一个rspec测试,它在我的rubric中添加了一些单元.
我有两个模型=> Rubric和Units.Rubric有很多单位.它看起来像这样:
@rubric.units.push Factory :text_unit
@rubric.save
Run Code Online (Sandbox Code Playgroud)
然后我找到了factory_girl并尝试将此代码重写为工厂.但它没有用.
我怎么能在Factory Girl中写这个关联.我试过这个:
factory :common_rubric , :class => :common_info_rubric do |f|
f.sequence(:name) {|n| "common_info_rubric#{n}"}
end
factory :text_unit, :class => text_info_unit do |f|
f.association :common_rubric_with_unit
f.sequence(:name) {|n| "text_unit#n}" }
end
factory :common_rubric_with_unit , :parent => :common_rubric do |f|
f.units { |unit| unit.association(:text_info_unit) }
end
Run Code Online (Sandbox Code Playgroud)
我总是有错误
SystemStackError:
stack level too deep
Run Code Online (Sandbox Code Playgroud)