• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang term.Make函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/paulfchristiano/dwimmer/term.Make函数的典型用法代码示例。如果您正苦于以下问题:Golang Make函数的具体用法?Golang Make怎么用?Golang Make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Make函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: getChar

func getChar(d dynamics.Dwimmer, s *term.SettingT, quotedN, quotedS term.T) term.T {
	n, err := represent.ToInt(d, quotedN)
	if err != nil {
		return term.Make("asked to index into a string, but received " +
			"[] while converting the index to native format").T(err)
	}
	str, err := represent.ToStr(d, quotedS)
	if err != nil {
		return term.Make("asked to index into a string, but received " +
			"[] while converting the string to native format").T(err)
	}
	return core.Answer.T(represent.Rune(rune(str[n])))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:13,代码来源:strings.go


示例2: setTransition

func setTransition(d dynamics.Dwimmer, s *term.SettingT, quotedTransition, quotedSetting term.T) term.T {
	transition, err := represent.ToTransition(d, quotedTransition)
	if err != nil {
		return term.Make("asked to set a setting to transition [], "+
			"but while converting to a transition received []").T(quotedTransition, err)
	}
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return term.Make("asked to set a transition in setting [], "+
			"but while converting to a setting received []").T(quotedSetting, err)
	}
	d.Save(setting, transition)
	return core.OK.T()
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:14,代码来源:elicit.go


示例3: nativeSetCursor

func nativeSetCursor(d dynamics.Dwimmer, s *term.SettingT, xt, yt term.T) term.T {
	x, err := represent.ToInt(d, xt)
	if err != nil {
		return term.Make("asked to move cursor, but received [] "+
			"while converting coordinate [] to an integer").T(err, xt)
	}
	y, err := represent.ToInt(d, yt)
	if err != nil {
		return term.Make("asked to move cursor, but received [] "+
			"while converting coordinate [] to an integer").T(err, yt)
	}
	d.SetCursor(x, y)
	return core.OK.T()
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:14,代码来源:ui.go


示例4: nativeSuggestedActions

func nativeSuggestedActions(d dynamics.Dwimmer, context *term.SettingT, quotedSetting, quotedN term.T) term.T {
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return term.Make("was asked to generate suggestions in setting [], "+
			"but received [] while converting it to native form").T(quotedSetting, err)
	}
	n, err := represent.ToInt(d, quotedN)
	if err != nil {
		return term.Make("was asked to generate [] suggestions, "+
			"but received [] while converting it to native form").T(quotedN, err)
	}
	suggestions, _ := Suggestions(d, setting, n)
	quotedSuggestions := make([]term.T, len(suggestions))
	for i, suggestion := range suggestions {
		quotedSuggestions[i] = represent.ActionC(suggestion)
	}
	return core.Answer.T(represent.List(quotedSuggestions))

}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:19,代码来源:similarity.go


示例5: nativePutChar

func nativePutChar(d dynamics.Dwimmer, s *term.SettingT, char, xt, yt term.T) term.T {
	c, err := represent.ToRune(d, char)
	if err != nil {
		return term.Make("asked to write character, but received [] " +
			"while converting to a character").T(err)
	}
	x, err := represent.ToInt(d, xt)
	if err != nil {
		return term.Make("asked to write character, but received [] "+
			"while converting coordinate [] to an integer").T(err, xt)
	}
	y, err := represent.ToInt(d, yt)
	if err != nil {
		return term.Make("asked to write character, but received [] "+
			"while converting coordinate [] to an integer").T(err, yt)
	}
	d.SetCursor(x, y)
	d.PrintCh(c)
	return core.OK.T()
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:20,代码来源:ui.go


示例6: fallThrough

func fallThrough(d dynamics.Dwimmer, s *term.SettingT, quotedSetting term.T) term.T {
	settingT, err := represent.ToSettingT(d, quotedSetting)
	if err != nil {
		return term.Make("asked to decide what to do in setting [], "+
			"but while converting to a setting received []").T(quotedSetting, err)
	}
	transition := ElicitAction(d, s, settingT.Setting)
	if shouldSave(transition) {
		d.Save(settingT.Setting, transition)
	}
	return TakeTransition.T(represent.Transition(transition))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:12,代码来源:elicit.go


示例7: getTransition

func getTransition(d dynamics.Dwimmer, s *term.SettingT, quotedSetting term.T) term.T {
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return term.Make("asked to get a transition in setting [], "+
			"but while converting to a setting received []").T(quotedSetting, err)
	}
	result, ok := d.Get(setting)
	if !ok {
		return NoCompiledAction.T()
	}
	return core.Answer.T(represent.Transition(result))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:12,代码来源:elicit.go


示例8: findAction

func findAction(d dynamics.Dwimmer, s *term.SettingT, quotedSetting term.T) term.T {
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return term.Make("asked to decide what to do in setting [], "+
			"but while converting to a setting received []").T(quotedSetting, err)
	}
	transition, ok := d.Get(setting)
	if !ok {
		transition := ElicitAction(d, s, setting)
		d.Save(setting, transition)
	}
	return core.Answer.T(represent.Transition(transition))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:13,代码来源:elicit.go


示例9: getContinuations

func getContinuations(d dynamics.Dwimmer, s *term.SettingT, quotedSetting term.T) term.T {
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return term.Make("asked to return the continuations from a setting, " +
			"but while converting to a setting received []").T(err)
	}
	continuations := d.Continuations(setting)
	result := make([]term.T, len(continuations))
	for i, c := range continuations {
		result[i] = represent.Setting(c)
	}
	return core.Answer.T(represent.List(result))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:13,代码来源:elicit.go


示例10: getID

func getID(d dynamics.Dwimmer, s *term.SettingT, quoted term.T) term.T {
	var result int
	switch quoted.Head() {
	case represent.QuotedSetting:
		setting, err := represent.ToSetting(d, quoted)
		if err != nil {
			return term.Make("was asked to find the ID of a setting, " +
				"but while converting to a setting received []").T(err)
		}
		result = int(setting.ID)
	case term.Int(0).Head():
		result = int(term.IDer.PackInt(int(quoted.(term.Int))).(intern.ID))
	case term.Str("").Head():
		result = int(term.IDer.PackString(string(quoted.(term.Str))).(intern.ID))
	}
	return core.Answer.T(represent.Int(result))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:17,代码来源:ids.go


示例11: init

package represent

import (
	"github.com/paulfchristiano/dwimmer/data/core"
	"github.com/paulfchristiano/dwimmer/dynamics"
	"github.com/paulfchristiano/dwimmer/term"
)

var (
	RepresentSetting = term.Make("what term represents the setting []?")
)

func init() {
	s := term.InitS()
	s = dynamics.ExpectQuestion(s, RepresentSetting, "Q", "s")
	dynamics.AddNative(s, dynamics.Args1(quote), "s")
}

func quote(d dynamics.Dwimmer, s *term.SettingT, t term.T) term.T {
	return core.Answer.T(term.Quote(t))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:21,代码来源:questions.go


示例12:

package represent

import (
	"fmt"

	"github.com/paulfchristiano/dwimmer/data/core"
	"github.com/paulfchristiano/dwimmer/data/lists"
	"github.com/paulfchristiano/dwimmer/dynamics"
	"github.com/paulfchristiano/dwimmer/term"
)

var (
	QuotedNil = term.Make("nothing")

	QuotedRune     = term.Make("the character with unicode representation []")
	ByRunes        = term.Make("the string containing the sequence of characters []")
	QuotedSetting  = term.Make("the setting with the list of lines []")
	QuotedSettingT = term.Make("the concrete setting with template [] " +
		"and list of arguments []")
	QuotedTemplate = term.Make("the term template that has parts []")

	ActionLookup = map[term.Action]term.TemplateID{
		term.Return: term.Make("the parametrized action that returns the instantiation of its first argument"),
		term.View:   term.Make("the parametrized action that views the instantiation of its first argument"),
		term.Ask:    term.Make("the parametrized action that asks the instantiation of its first argument"),
		term.Replace: term.Make("the parametrized action that replaces the line given by its first index with " +
			"with the instantiation of its first argument"),
		term.Replay: term.Make("the parametrized action that replays the line given by its first index"),
		term.Clarify: term.Make("the parametrized action that sends the instantiation of its first argument " +
			"to the instantiation of its second argument"),
		term.Correct: term.Make("the parametrized action that prompts the user to correct its first index"),
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:31,代码来源:quote.go


示例13: init

package store

import (
	"github.com/paulfchristiano/dwimmer/data/core"
	"github.com/paulfchristiano/dwimmer/dynamics"
	"github.com/paulfchristiano/dwimmer/term"
)

var (
	GetState = term.Make("what is the current state of the interpreter?")
	SetState = term.Make("the state of the interpreter should become []")
)

func init() {
	s := dynamics.ExpectQuestion(term.InitS(), GetState, "Q")
	dynamics.AddNative(s, dynamics.Args0(getState))

	s = dynamics.ExpectQuestion(term.InitS(), SetState, "Q", "s")
	dynamics.AddNative(s, dynamics.Args1(setState), "s")
}

func getState(d dynamics.Dwimmer, s *term.SettingT) term.T {
	return core.Answer.T(d.GetStorage())
}

func setState(d dynamics.Dwimmer, s *term.SettingT, t term.T) term.T {
	d.SetStorage(t)
	return core.OK.T()
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:29,代码来源:store.go


示例14: init

package meta

import (
	"github.com/paulfchristiano/dwimmer/data/core"
	"github.com/paulfchristiano/dwimmer/data/represent"
	"github.com/paulfchristiano/dwimmer/dynamics"
	"github.com/paulfchristiano/dwimmer/term"
)

var (
	SettingForChannel = term.Make("what setting corresponds to the channel []?")
	NotAChannel       = term.Make("the argument is not a channel")
)

func init() {
	s := dynamics.ExpectQuestion(term.InitS(), SettingForChannel, "Q", "c")
	s = dynamics.AddSimple(s, term.ViewS(term.Sr("c")))
	s = s.AppendTemplate(term.Channel{}.Head())
	dynamics.AddNative(s, dynamics.Args1(settingForChannel), "c")
}

func settingForChannel(d dynamics.Dwimmer, context *term.SettingT, channel term.T) term.T {
	c, ok := channel.(term.Channel)
	if !ok {
		return NotAChannel.T()
	}
	return core.Answer.T(represent.SettingT(c.Setting))
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:28,代码来源:misc.go


示例15: concat

)

func concat(d dynamics.Dwimmer, s *term.SettingT, a, b term.T) term.T {
	return core.Answer.T(term.Str(string(a.(term.Str)) + string(b.(term.Str))))
}

func length(d dynamics.Dwimmer, s *term.SettingT, a term.T) term.T {
	return core.Answer.T(term.Int(len(string(a.(term.Str)))))
}

func bracketed(d dynamics.Dwimmer, s *term.SettingT, a term.T) term.T {
	return core.Answer.T(term.Str(fmt.Sprint("[%s]", string(a.(term.Str)))))
}

var (
	Len       = term.Make("what is the length of []?")
	Concat    = term.Make("what is the result of concatenating [] to []?")
	Bracketed = term.Make("what is the string formed by enclosing [] in brackets?")
	GetChar   = term.Make("what is the character that comes after [] others in the string []?")
)

func init() {
	s := term.InitS()
	s = dynamics.ExpectQuestion(s, Len, "Q", "s")
	s = dynamics.AddSimple(s, term.ViewS(term.Sr("s")))
	s.AppendTemplate(term.Str("").Head())
	dynamics.AddNative(s, dynamics.Args1(length), "s")

	s = term.InitS()
	s = dynamics.ExpectQuestion(s, Bracketed, "Q", "s")
	s = dynamics.AddSimple(s, term.ViewS(term.Sr("s")))
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:31,代码来源:strings.go


示例16: init

package similarity

import (
	"container/heap"

	"github.com/paulfchristiano/dwimmer/data/core"
	"github.com/paulfchristiano/dwimmer/data/represent"
	"github.com/paulfchristiano/dwimmer/dynamics"
	"github.com/paulfchristiano/dwimmer/term"
	"github.com/xrash/smetrics"
)

var (
	RelatedSettings = term.Make("what settings have been encountered before that are most analogous " +
		"to the setting [], and what is their relationship to that setting?")
	SuggestedActions = term.Make("what actions is the user most likely to take in setting [], " +
		"based on analogies with similar settings they have encountered in the past? " +
		"[] items should be returned as a list, sorted with most promising first")
)

func init() {
	dynamics.AddNativeResponse(SuggestedActions, 2, dynamics.Args2(nativeSuggestedActions))
}

func nativeSuggestedActions(d dynamics.Dwimmer, context *term.SettingT, quotedSetting, quotedN term.T) term.T {
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return term.Make("was asked to generate suggestions in setting [], "+
			"but received [] while converting it to native form").T(quotedSetting, err)
	}
	n, err := represent.ToInt(d, quotedN)
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:31,代码来源:similarity.go


示例17: TestRepresentations

func TestRepresentations(t *testing.T) {
	d := dwimmer.TestDwimmer()
	defer d.Close()
	template := term.Make("term with argument [] and second half here")
	template2, err := represent.ToTemplate(d, represent.Template(template))
	if err != nil {
		t.Errorf("received error %v", err)
	}
	if template != template2 {
		t.Errorf("%v != %v", template, template2)
	}
	setting := term.Init().Append(template)
	setting2, err := represent.ToSetting(d, represent.Setting(setting))
	if err != nil {
		t.Errorf("received error %v", err)
	}
	if term.IDSetting(setting) != term.IDSetting(setting2) {
		t.Errorf("%v != %v", setting, setting2)
	}
	actions := []term.ActionC{term.ReturnC(term.Cr(3)), term.ClarifyC(term.Cr(2), core.OK.C()), term.DeleteC(7)}
	for _, action := range actions {
		action2, err := represent.ToActionC(d, represent.ActionC(action))
		if err != nil {
			t.Errorf("received error %v", err)
		}
		if term.IDActionC(action) != term.IDActionC(action2) {
			t.Errorf("%v != %v", action, action2)
		}
	}
	stub := term.Make("stub")
	tm := template.T(stub.T())
	tm2, err := represent.ToT(d, represent.T(tm))
	if err != nil {
		t.Errorf("received error %v", err)
	}
	if tm2.String() != tm.String() {
		t.Errorf("%v != %v", tm2, tm)
	}
	rep, err := d.Answer(represent.Explicit.T(represent.T(tm)))
	if err != nil {
		t.Errorf("failed to make representation explicit: %v", err)
	}
	tm3, err := represent.ToT(d, rep)
	if err != nil {
		t.Errorf("received error %v", err)
	}
	if tm3.String() != tm.String() {
		t.Errorf("%v != %v", tm3, tm)
	}
	settingT := term.InitT().AppendTerm(tm)
	settingT2, err := represent.ToSettingT(d, represent.SettingT(settingT))
	if err != nil {
		t.Errorf("received error %v")
	}
	if settingT2.Setting.ID != settingT.Setting.ID {
		t.Errorf("%v != %v", settingT2, settingT)
	}

	n := -127
	n2, err := represent.ToInt(d, represent.Int(n))
	if err != nil {
		t.Errorf("received error %v", err)
	}
	if n != n2 {
		t.Errorf("%v != %v", n, n2)
	}

	s := "hello ₳"
	s2, err := represent.ToStr(d, represent.Str(s))
	if err != nil {
		t.Errorf("received error %v", err)
	}
	if s != s2 {
		t.Errorf("%s != %s", s, s2)
	}
}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:76,代码来源:quote_test.go


示例18: ApplicationSetting

package functions

import (
	"github.com/paulfchristiano/dwimmer/data/core"
	"github.com/paulfchristiano/dwimmer/data/lists"
	"github.com/paulfchristiano/dwimmer/dynamics"
	"github.com/paulfchristiano/dwimmer/term"
)

var (
	Apply   = term.Make("what is the result of applying function [] to argument []?")
	Compose = term.Make("the function that applies [], then applies [] to the result")
	Map     = term.Make("the function that applies [] to each element of its argument, which should be a list")
	Fold    = term.Make("what is the result of using [] to combine all of the arguments " +
		"in the list [] into one, starting from [] and assuming that the function is associative?")

	Apply2 = term.Make("what is the result of applying function [] to the arguments [] and []?")
)

var applyState, applyState2 *term.SettingS

func ApplicationSetting() *term.SettingS {
	return applyState.Copy()
}

func ApplicationSetting2() *term.SettingS {
	return applyState2.Copy()
}

func init() {
	applyState = term.InitS()
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:31,代码来源:functions.go


示例19: ExpectQuestion

package dynamics

import "github.com/paulfchristiano/dwimmer/term"

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
}

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
}

func Parent(s *term.SettingT) term.T {
	return ParentChannel.T(term.MakeChannel(s))
}

var (
	OpenChannel   = term.Make("@[]")
	ParentChannel = term.Make("@[]*")
)
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:26,代码来源:examples.go


示例20: Dummy

package storage

import "github.com/paulfchristiano/dwimmer/term"

func Dummy() *DummyStorage {
	return &DummyStorage{}
}

var (
	DummyState = term.Make("a placeholder returned when accessing the state of a test harness")
)

type DummyStorage struct{}

func (_ *DummyStorage) CloseStorage()      {}
func (_ *DummyStorage) GetStorage() term.T { return DummyState.T() }
func (_ *DummyStorage) SetStorage(term.T)  {}

var _ StorageImplementer = &DummyStorage{}
开发者ID:paulfchristiano,项目名称:dwimmer,代码行数:19,代码来源:dummy.go



注:本文中的github.com/paulfchristiano/dwimmer/term.Make函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang term.SettingS类代码示例发布时间:2022-05-28
下一篇:
Golang dynamics.Dwimmer类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap