當前位置: 首頁>>代碼示例>>Golang>>正文


Golang term.SettingS類代碼示例

本文整理匯總了Golang中github.com/paulfchristiano/dwimmer/term.SettingS的典型用法代碼示例。如果您正苦於以下問題:Golang SettingS類的具體用法?Golang SettingS怎麽用?Golang SettingS使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SettingS類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AddNativeTo

func AddNativeTo(table *TransitionTable, s *term.SettingS,
    f func(Dwimmer, *term.SettingT, ...term.T) term.T, names ...string) {

    indices := make([]int, len(names))
    for i, name := range names {
        for j, key := range s.Names {
            if name == key {
                indices[i] = j
            }
        }
    }
    g := func(d Dwimmer, s *term.SettingT) term.T {
        args := make([]term.T, len(indices))
        for i, index := range indices {
            args[i] = s.Args[index]
        }
        s.AppendAction(term.AskC(NativeQ.C()))
        result := f(d, s, args...)
        if result != nil {
            s.AppendTerm(core.Answer.T(result))
            s.AppendAction(term.ReturnC(term.Cr(len(s.Args) - 1)))
        }
        return result
    }
    table.Save(s.Setting, NativeTransition(g))
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:26,代碼來源:transitions.go

示例2: init

func init() {
    var s, t *term.SettingS
    s = term.InitS()
    s.AppendTemplate(Fold, "f", "l", "x")
    s = dynamics.AddSimple(s, term.ViewS(term.Sr("l")))

    t = s.Copy().AppendTemplate(lists.Empty)
    t = dynamics.AddSimple(t, term.ReturnS(term.Sr("x")))

    t = s.Copy().AppendTemplate(lists.Cons, "head", "tail")
    t = dynamics.AddSimple(t, term.AskS(Apply2.S(term.Sr("f"), term.Sr("x"), term.Sr("head"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A1", "y")
    t = dynamics.AddSimple(t, term.AskS(Fold.S(term.Sr("f"), term.Sr("tail"), term.Sr("y"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A2", "A")
    t = dynamics.AddSimple(t, term.ReturnS(term.Sr("A")))

    t = s.Copy().AppendTemplate(lists.Snoc, "init", "last")
    t = dynamics.AddSimple(t, term.AskS(Fold.S(term.Sr("f"), term.Sr("init"), term.Sr("x"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A1", "y")
    t = dynamics.AddSimple(t, term.AskS(Apply2.S(term.Sr("f"), term.Sr("y"), term.Sr("last"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A2", "A")
    t = dynamics.AddSimple(t, term.ReturnS(term.Sr("A")))

    t = s.Copy().AppendTemplate(lists.Concat, "a", "b")
    t = dynamics.AddSimple(t, term.AskS(Fold.S(term.Sr("f"), term.Sr("a"), term.Sr("x"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A1", "y")
    t = dynamics.AddSimple(t, term.AskS(Fold.S(term.Sr("f"), term.Sr("b"), term.Sr("y"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A2", "A")
    t = dynamics.AddSimple(t, term.ReturnS(term.Sr("A")))

    t = s.Copy().AppendTemplate(lists.Singleton, "y")
    t = dynamics.AddSimple(t, term.AskS(Apply2.S(term.Sr("f"), term.Sr("x"), term.Sr("y"))))
    t = dynamics.ExpectAnswer(t, core.Answer, "A1", "A")
    t = dynamics.AddSimple(t, term.ReturnS(term.Sr("A")))
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:35,代碼來源:functions.go

示例3: SaveSimpleS

func (t *TransitionTable) SaveSimpleS(s *term.SettingS, a term.ActionS) *term.SettingS {
    aC := a.Instantiate(s.Names)
    t.SaveSimpleC(s.Setting, aC)
    return s.Copy().AppendAction(aC)
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:5,代碼來源:transitions.go

示例4: ExpectQuestion

func ExpectQuestion(s *term.SettingS, t term.TemplateID, names ...string) *term.SettingS {
    result := s.Copy()
    result.AppendTemplate(ParentChannel, names[0])
    result.AppendTemplate(t, names[1:]...)
    return result
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:6,代碼來源:examples.go

示例5: ExpectAnswer

func ExpectAnswer(s *term.SettingS, t term.TemplateID, names ...string) *term.SettingS {
    result := s.Copy()
    result.AppendTemplate(OpenChannel, names[0])
    result.AppendTemplate(t, names[1:]...)
    return result
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:6,代碼來源:examples.go

示例6: init

func init() {
    //dynamics.AddNativeResponse(FallThrough, 1, dynamics.Args1(fallThrough))
    dynamics.AddNativeResponse(DisplayTemplate, 1, dynamics.Args1(displayTemplate))
    dynamics.AddNativeResponse(GetActionInput, 2, dynamics.Args2(getInput))
    dynamics.AddNativeResponse(ParseInputAsAction, 2, dynamics.Args2(parseInput))

    var s *term.SettingS
    s = dynamics.ExpectQuestion(term.InitS(), FallThrough, "Q", "setting")
    s = dynamics.AddSimple(s, term.AskS(GetTemplate.S(term.Sr("setting"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A", "template")
    s = dynamics.AddSimple(s, term.AskS(ElicitActionQ.S(term.Sr("template"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A2", "action")
    s = dynamics.AddSimple(s, term.AskS(MakeTransition.S(term.Sr("action"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A3", "transition")
    s = dynamics.AddSimple(s, term.AskS(ShouldRecord.S(term.Sr("action"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "AA", "should")
    s = dynamics.AddSimple(s, term.ViewS(term.Sr("should")))
    s.AppendTemplate(core.Yes)
    s = dynamics.AddSimple(s, term.AskS(SetTransition.S(term.Sr("transition"), term.Sr("template"))))
    s = dynamics.ExpectAnswer(s, core.OK, "A4")
    s = dynamics.AddSimple(s, term.ReturnS(TakeTransition.S(term.Sr("transition"))))

    s = dynamics.ExpectQuestion(term.InitS(), ShouldRecord, "Q", "action")
    s = dynamics.AddSimple(s, term.ViewS(term.Sr("action")))
    s.AppendTemplate(represent.QuotedActionC, "act", "args", "indices")
    s = dynamics.AddSimple(s, term.ViewS(term.Sr("act")))
    for act, template := range represent.ActionLookup {
        t := s.Copy().AppendTemplate(template)
        switch act {
        case term.Replace, term.Correct, term.Replay:
            dynamics.AddSimple(t, term.ReturnS(core.Answer.S(core.No.S())))
        default:
            dynamics.AddSimple(t, term.ReturnS(core.Answer.S(core.Yes.S())))
        }
    }

    s = dynamics.ExpectQuestion(term.InitS(), MakeTransition, "Q", "action")
    s = dynamics.AddSimple(s, term.ReturnS(core.Answer.S(represent.QuotedSimpleTransition.S(term.Sr("action")))))

    s = dynamics.ExpectQuestion(term.InitS(), GetTemplate, "Q", "setting")
    t := dynamics.AddSimple(s, term.ViewS(term.Sr("setting")))
    s = t.Copy().AppendTemplate(represent.QuotedTemplate, "parts")
    s = dynamics.AddSimple(s, term.ReturnS(core.Answer.S(term.Sr("setting"))))
    s = t.Copy().AppendTemplate(represent.QuotedSettingT, "template", "args")
    s = dynamics.AddSimple(s, term.ReturnS(core.Answer.S(term.Sr("template"))))

    s = dynamics.ExpectQuestion(term.InitS(), ElicitActionQ, "Q", "setting")
    s = dynamics.AddSimple(s, term.AskS(GetTemplate.S(term.Sr("setting"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A", "template")
    s = dynamics.AddSimple(s, term.AskS(ElicitActionQTemplate.S(term.Sr("template"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A2", "action")
    s = dynamics.AddSimple(s, term.ReturnS(core.Answer.S(term.Sr("action"))))

    s = dynamics.ExpectQuestion(term.InitS(), ElicitActionQTemplate, "Q", "template")
    s = dynamics.AddSimple(s, term.AskS(similarity.GetHints.S(term.Sr("template"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A", "hints")
    s = dynamics.AddSimple(s, term.AskS(similarity.GetTools.S(term.Sr("template"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A2", "tools")
    s = dynamics.AddSimple(s, term.AskS(ElicitActionQTemplateHints.S(
        term.Sr("template"), term.Sr("hints"), term.Sr("tools"),
    )))
    s = dynamics.ExpectAnswer(s, core.Answer, "A3", "action")
    s = dynamics.AddSimple(s, term.ReturnS(core.Answer.S(term.Sr("action"))))

    s = dynamics.ExpectQuestion(term.InitS(), ElicitActionQTemplateHints, "Q", "template", "hints", "tools")
    s = dynamics.AddSimple(s, term.AskS(meta.Clear.S()))
    s = dynamics.ExpectAnswer(s, core.OK, "A")
    s = dynamics.AddSimple(s, term.AskS(DisplayTemplate.S(term.Sr("template"))))
    s = dynamics.ExpectAnswer(s, Names, "A2", "names")
    s = dynamics.AddSimple(s, term.AskS(similarity.DisplayTools.S(term.Sr("tools"))))
    s = dynamics.ExpectAnswer(s, similarity.ToolMapping, "A3", "toolmap")
    s = dynamics.AddSimple(s, term.AskS(similarity.DisplayHints.S(term.Sr("hints"), term.Sr("names"))))
    s = dynamics.ExpectAnswer(s, similarity.HintStrings, "A4", "hintstrings")
    s = dynamics.AddSimple(s, term.AskS(GetActionInput.S(term.Sr("hintstrings"), term.Sr("toolmap"))))
    s = dynamics.ExpectAnswer(s, core.Answer, "A5", "input")
    s = dynamics.AddSimple(s, term.AskS(ParseInputAsAction.S(term.Sr("input"), term.Sr("names"))))

    t = dynamics.ExpectAnswer(s.Copy(), core.Answer, "A6", "action")
    t = dynamics.AddSimple(t, term.ReturnS(core.Answer.S(term.Sr("action"))))

    t = dynamics.ExpectAnswer(s.Copy(), GoMeta, "A6")
    t = dynamics.AddSimple(t, term.MetaS())

    dynamics.AddNativeResponse(ActionQ, 1, dynamics.Args1(findAction))
    dynamics.AddNativeResponse(SetTransition, 2, dynamics.Args2(setTransition))
    dynamics.AddNativeResponse(GetTransition, 1, dynamics.Args1(getTransition))
    dynamics.AddNativeResponse(GetContinuations, 1, dynamics.Args1(getContinuations))
    dynamics.AddNativeResponse(AllSettings, 0, dynamics.Args0(allSettings))
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:89,代碼來源:elicit.go

示例7: ShowSettingS

func ShowSettingS(d dynamics.Dwimmer, settingS *term.SettingS) {
    d.Clear()
    for _, line := range settingS.Lines() {
        d.Println(line)
    }
}
開發者ID:paulfchristiano,項目名稱:dwimmer,代碼行數:6,代碼來源:elicit.go


注:本文中的github.com/paulfchristiano/dwimmer/term.SettingS類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。