?? fibonacci.python.drl
字號:
<?xml version="1.0"?><rule-set name="fibonacci" xmlns="http://drools.org/rules" xmlns:python="http://drools.org/semantics/python" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/rules rules.xsd http://drools.org/semantics/python python.xsd"> <python:import>from org.drools.examples.fibonacci import Fibonacci</python:import> <rule name="Bootstrap 1" salience="20"> <parameter identifier="f"> <class>Fibonacci</class> </parameter> <python:condition>f.getSequence() == 1</python:condition> <python:condition>f.getValue() == -1</python:condition> <python:consequence> f.setValue( 1 ) print "%d == %d" % ( f.getSequence(), f.getValue() ) drools.modifyObject( f ) </python:consequence> </rule> <rule name="Bootstrap 2"> <parameter identifier="f"> <class>Fibonacci</class> </parameter> <python:condition>f.getSequence() == 2</python:condition> <python:condition>f.getValue() == -1</python:condition> <python:consequence> f.setValue( 1 ) print "%d == %d" % ( f.getSequence(), f.getValue() ) drools.modifyObject( f ) </python:consequence> </rule> <rule name="Recurse" salience="10"> <parameter identifier="f"> <class>Fibonacci</class> </parameter> <python:condition>f.getValue() == -1</python:condition> <python:consequence> from org.drools.examples.fibonacci import Fibonacci print "recurse for %d" % f.getSequence() drools.assertObject( Fibonacci( f.getSequence() - 1 ) ) </python:consequence> </rule> <rule name="Calculate"> <parameter identifier="f1"> <class>Fibonacci</class> </parameter> <parameter identifier="f2"> <class>Fibonacci</class> </parameter> <parameter identifier="f3"> <class>Fibonacci</class> </parameter> <python:condition>f2.getSequence() == (f1.getSequence() + 1)</python:condition> <python:condition>f3.getSequence() == (f2.getSequence() + 1)</python:condition> <python:condition>f1.getValue() != -1</python:condition> <python:condition>f2.getValue() != -1</python:condition> <python:condition>f3.getValue() == -1</python:condition> <python:consequence> f3.setValue( f1.getValue() + f2.getValue() ) print "%d == %d" % ( f3.getSequence(), f3.getValue() ) drools.modifyObject( f3 ) drools.retractObject( f1 ) </python:consequence> </rule></rule-set>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -