当前位置: 首页>>代码示例>>Golang>>正文


Golang term.Make函数代码示例

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


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


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