// For the index of a character at a certain line, calculate the index of
// the first character on that line.
426403
func (d *Document) findLineStartIndex(index int) (pos int, lineStartIndex int) {
	indexes := d.lineStartIndexes()
	pos = bisect.Right(indexes, index) - 1
	lineStartIndex = indexes[pos]
	return
}
1324426
func (t *StringTree) At(index int) string {
	v := t.Tree.At(index)
	if v != nil {
		return v.(string)
	}
	return ""
}
1102185
func (s *IndicesExistsService) Index(index []string) *IndicesExistsService {
	s.index = index
	return s
}
790902
func IndexN(s, sep string, n int) int {
	sepIdx := 0
	for i := 0; i < n; i++ {
		nextIdx := strings.Index(s[sepIdx:], sep)
		if nextIdx == -1 {
			return -1 // ### return, not found ###
		}
		sepIdx += nextIdx + 1
	}
	return sepIdx - 1
}
73239
func (pd *PictureData) Index(at Vec) int {
	at = at.Sub(pd.Rect.Min.Map(math.Floor))
	x, y := int(at.X), int(at.Y)
	return y*pd.Stride + x
}
1374007
func (s *OpenIndexService) Index(index string) *OpenIndexService {
	s.index = index
	return s
}
258141
func asIndex(v Value, len int, result *int) error {
	if v != nil && v != None {
		var err error
		*result, err = AsInt32(v)
		if err != nil {
			return fmt.Errorf("got %s, want int", v.Type())
		}
		if *result < 0 {
			*result += len
		}
	}
	return nil
}
496767
func SymbolIndex(s int) (idx int) {
	for idx = 0; idx < len(Symbol); idx++ {
		if Symbol[idx] == s {
			return idx
		}
	}
	return -1
}
160218
func (p Position) add(s string) Position {
	if n := strings.Count(s, "\n"); n > 0 {
		p.Line += int32(n)
		s = s[strings.LastIndex(s, "\n")+1:]
		p.Col = 1
	}
	p.Col += int32(utf8.RuneCountInString(s))
	return p
}
852747
func FibonacciNext(start int) int {
	fib := Fibonacci()
	num := fib()
	for num <= start {
		num = fib()
	}
	return num
}
385299
func GetWordIndex(word string) (int, bool) {
	idx, ok := wordMap[word]
	return idx, ok
}
1237593
func Line(nums []float64) string {
	if len(nums) == 0 {
		return ""
	}
	indices := normalize(nums)
	var sparkline bytes.Buffer
	for _, index := range indices {
		sparkline.WriteRune(steps[index])
	}
	return sparkline.String()
}
594917
func (s *ScrollService) Index(indices ...string) *ScrollService {
	if s.indices == nil {
		s.indices = make([]string, 0)
	}
	s.indices = append(s.indices, indices...)
	return s
}
920504
func GetFirstChar(s string) string {
	firstChar := ""
	for _, r := range s {
		firstChar = fmt.Sprintf("%c", r)
		break
	}
	return firstChar
}
512285
func FirstLine(src string) (line string, err error) {
	err = Filter(src, func(_ int, l []byte) (error) {
		line = string(l)

		return io.EOF
	})

	return
}
765961
func (t Term) AtIndex(args ...interface{}) Term {
	return constructMethodTerm(t, "AtIndex", p.Term_BRACKET, args, map[string]interface{}{})
}
861987
func (s *IndicesSegmentsService) Index(indices ...string) *IndicesSegmentsService {
	s.index = append(s.index, indices...)
	return s
}