Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Blob []byte
View Source
var FactorialCheck = []rt.Execute{ &debug.Expect{ Value: &math.CompareNum{ A: F(6), Compare: math.C_Comparison_EqualTo, B: &call.CallPattern{ PatternName: "factorial", Arguments: []call.Arg{{ Name: "num", Value: &call.FromNum{Value: F(3)}, }}}, }, }, }
run 3! factorial
View Source
var FactorialDecreaseRule = []rt.Execute{ &logic.ChooseBranch{ Condition: &math.CompareNum{ Markup: UserComment("above zero, subtract one"), A: object.Variable("num"), Compare: math.C_Comparison_GreaterThan, B: F(0)}, Exe: FactorialMulMinusOne, }, }
override the default behavior:
View Source
var FactorialDefaultRule = []rt.Execute{ &object.SetValue{ Markup: UserComment("by default, return one"), Target: object.Variable("num"), Value: &call.FromNum{Value: I(1)}, }, }
the default rule: use the number 1
View Source
var FactorialJs string
View Source
var FactorialMulMinusOne = []rt.Execute{ &object.SetValue{ Target: object.Variable("num"), Value: &call.FromNum{Value: &math.MultiplyValue{ A: object.Variable("num"), B: &math.SubtractValue{ A: object.Variable("num"), B: I(1), }, }}}, }
subtracts 1 from the num and multiples by one
View Source
var FactorialStory = story.StoryFile{ Statements: []story.StoryStatement{ &story.DefineScene{ SceneName: T("factorial"), Exe: FactorialCheck, }, &story.DefinePattern{ PatternName: T("factorial"), Requires: []story.FieldDefinition{ &story.NumField{ Markup: UserComment("just one argument, a number called 'num'"), FieldName: T("num"), }}, Provides: []story.FieldDefinition{&story.NumField{ Markup: UserComment("the result uses the same variable as the pattern input does"), FieldName: T("num"), }}, Exe: FactorialDefaultRule, }, &story.DefineRule{ RuleTiming: T("factorial"), Exe: FactorialDecreaseRule, }}, }
a program that can check factorials
View Source
var SayPattern = testpat.Pattern{ Name: "say me", Labels: []string{"num"}, Fields: []rt.Field{ {Name: "num", Affinity: "number", Type: ""}, }, Rules: []rt.Rule{{ Name: "default", Exe: SayIt("Not between 1 and 3."), }, { Name: "3b", Exe: []rt.Execute{&logic.ChooseBranch{ Condition: &MatchNumber{3}, Exe: SayIt("San!")}, }, }, { Name: "3a", Exe: []rt.Execute{&logic.ChooseBranch{ Condition: &MatchNumber{3}, Exe: SayIt("Three!")}, }, }, { Name: "2", Exe: []rt.Execute{&logic.ChooseBranch{ Condition: &MatchNumber{2}, Exe: SayIt("Two!")}, }, }, { Name: "1", Exe: []rt.Execute{&logic.ChooseBranch{ Condition: &MatchNumber{1}, Exe: SayIt("One!")}, }, }}, }
the rules defined last run first
Functions ¶
func DetermineSay ¶
func DetermineSay(i int) *call.CallPattern
func UserComment ¶
Types ¶
type Flow ¶
type Flow struct {
// contains filtered or unexported fields
}
Flow creates a debug flow to simulate spec generation
type MatchNumber ¶
type MatchNumber struct {
Val int
}
Click to show internal directories.
Click to hide internal directories.