Skip to content

docs(sheets): cover index-returning search functions - #15

Open
Kepler2024 wants to merge 2 commits into
mainfrom
docs/sheets-index-search
Open

Kepler2024 wants to merge 2 commits into
mainfrom
docs/sheets-index-search

Conversation

@Kepler2024

Copy link
Copy Markdown
Owner

Summary

Each sheet (English sheets/ and Chinese sheets_zh/) now covers the standard functions that return an index, in Arrays and Strings:

  • the first and last index of a value or substring, and what each language returns when it's missing (-1, ValueError, nil, None, npos)
  • search by condition (findIndex, IndexFunc, indexOfFirst, position, find_if, …)
  • binary search on a sorted array where the standard library has one (bisect, Arrays.binarySearch, lower_bound/upper_bound, slices.BinarySearch, BinarySearch, binarySearch, binary_search/partition_point). For JavaScript, TypeScript and Swift, a comment says there is none.

New CAREFUL: notes, each one run through the checker:

  • Python: list.index / str.index raise ValueError.
  • Java: Arrays.asList(int[]).indexOf finds nothing.
  • Java and C#: binarySearch on duplicates may not return the first match.
  • Go: strings.Index counts bytes.
  • JS/TS: indexOf never finds NaN.

Also fixes an example in sheets_zh/kotlin.md that was already broken on main. It used Swift's greeting: "Hi" named-argument syntax, so the block didn't compile.

Notes

  • TypeScript doesn't show findLastIndex: the checker's tsc lib predates ES2023 and reports TS2550. A comment says so instead.
  • Three English sheets go past the ~1100-line guideline: java.md is 1126 lines, cpp.md 1116 and go.md 1110.

Test plan

  • python3 tools/check.py sheets/<id>.md passes for all 10 sheets
  • python3 tools/check.py --no-lint --lang <id> sheets_zh/<id>.md passes for all 10 sheets
  • npm run build and npm run check pass

🤖 Generated with Claude Code

Kepler2024 and others added 2 commits December 5, 2026 15:49
…example

greet("Ann", greeting: "Hi") is Swift syntax and failed to compile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rings

Add first/last index lookups, not-found results, condition-based search
and standard-library binary search (where one exists) to every English
and Chinese sheet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant