Skip to content

Multiple named functions ​

A Stated file may define more than one function. Each Define … as a function. sentence supplies the corresponding exported Go function name.

Stated source ​

Source mapGrammarVocabularyTypeName / reference
Define copy-values as a function.It accepts an integer sequence named input.Collect the input values in encounter order into a fresh sequence.Retain every occurrence.Define filter-values as a function.It accepts an integer sequence named input and an integer named threshold.Collect the input values in encounter order into a fresh sequence.Retain each value only when it is greater than the threshold.

Generated Go ​

go
package generated

func CopyValues(p0 []int64) ([]int64, error) {
	result := make([]int64, len(p0))
	copy(result, p0)
	return result, nil
}

func FilterValues(p0 []int64, p1 int64) ([]int64, error) {
	result := make([]int64, 0)
	for _, value := range p0 {
		if value > p1 {
			result = append(result, value)
		}
	}
	return result, nil
}

Download the Stated source · Download the generated Go

Stated compiles controlled English deterministically. It does not call an LLM at compile time.