Skip to content

Forward function calls ​

filter-and-copy calls two functions defined later in the same file. Named arguments in each call connect the natural-language inputs to the callee.

Stated source ​

Source mapGrammarVocabularyTypeName / reference
Define filter-and-copy as a function.It accepts an integer sequence named input and an integer named threshold.Call filter-values with the input as input and the threshold as threshold, storing the result as filtered.Call copy-values with the filtered as input, storing the result as copied.Return the copied.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.Replace each retained value with the doubled value of that value before appending it.

Generated Go ​

go
package generated

import (
	"errors"
	"math"
)

func FilterAndCopy(p0 []int64, p1 int64) ([]int64, error) {
	r0, err0 := FilterValues(p0, p1)
	if err0 != nil {
		return nil, err0
	}
	_ = r0
	r1, err1 := CopyValues(r0)
	if err1 != nil {
		return nil, err1
	}
	_ = r1
	result := make([]int64, len(r1))
	copy(result, r1)
	return result, nil
}

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 {
			if value > math.MaxInt64/2 || value < math.MinInt64/2 {
				return nil, errors.New("integer overflow")
			}
			result = append(result, value+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.