Beispiel #1
0
func allSettings(d dynamics.Dwimmer, s *term.SettingT) term.T {
	queue := []*term.Setting{term.Init()}
	for k := 0; k < len(queue); k++ {
		top := queue[k]
		queue = append(queue, d.Continuations(top)...)
	}
	result := make([]term.T, len(queue))
	for i, setting := range queue {
		result[i] = represent.Setting(setting)
	}
	return core.Answer.T(represent.List(result))
}
Beispiel #2
0
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))
}
Beispiel #3
0
func displayTemplate(d dynamics.Dwimmer, context *term.SettingT, quotedSetting term.T) term.T {
	setting, err := represent.ToSetting(d, quotedSetting)
	if err != nil {
		return represent.ConversionError.T(quotedSetting, err)
	}
	settingS := addNames(setting)
	ShowSettingS(d, settingS)
	d.Println("")
	d.Println("")
	quotedNames := make([]term.T, len(settingS.Names))
	for i, name := range settingS.Names {
		quotedNames[i] = represent.Str(name)
	}
	return Names.T(represent.List(quotedNames))
}
Beispiel #4
0
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))

}