diff --git a/.llm/BETA_12_CONCRETE_VECTOR_QUERY_AND_PREFIX_PARITY.md b/.llm/BETA_12_CONCRETE_VECTOR_QUERY_AND_PREFIX_PARITY.md new file mode 100644 index 0000000..a8768e4 --- /dev/null +++ b/.llm/BETA_12_CONCRETE_VECTOR_QUERY_AND_PREFIX_PARITY.md @@ -0,0 +1,59 @@ +# 1.0.0-beta.12 Concrete Vector Query And Prefix Parity + +Status: release scope for `1.0.0-beta.12`. + +`1.0.0-beta.12` is a source-authored standard-library/helper parity release for +current concrete vectors. It keeps the `1.0.0-beta` source language, typed core, +runtime, ABI/layout, and compiler-known `std.vec.*` runtime names unchanged. + +## Scope + +- Add `count_of`, `starts_with`, `without_prefix`, `ends_with`, and + `without_suffix` to `std.vec_i64`. +- Add `count_of` to `std.vec_f64`. +- Keep helpers ordinary Slovo source over the existing concrete vector runtime + names, equality, `len`, `at`, and already staged recursive helpers. +- Extend explicit source-helper project coverage for repeated `count_of` + results and prefix/suffix empty, mismatch, exact, and longer-than-input + cases where applicable. +- Bump the Glagol package version to `1.0.0-beta.12`. +- Update README, language docs, compiler docs, and the post-beta roadmap. + +## Public Contract + +The helper additions are concrete-family helpers: + +- `std.vec_i64.count_of(values,target)` counts `i64` elements equal to + `target`. +- `std.vec_i64.starts_with(values,prefix)` and + `std.vec_i64.ends_with(values,suffix)` treat empty prefixes/suffixes and + exact full-vector matches as true, reject mismatches, and reject longer + prefix/suffix inputs. +- `std.vec_i64.without_prefix(values,prefix)` and + `std.vec_i64.without_suffix(values,suffix)` return the unmatched original + vector or the remaining vector after a match. +- `std.vec_f64.count_of(values,target)` counts `f64` elements equal to + `target`. + +## Explicit Non-Scope + +- no source-language syntax change +- no typed-core or lowering change +- no runtime implementation change +- no new compiler-known stdlib or runtime names +- no executable generics or generic stdlib dispatch +- no maps or sets +- no iterators +- no mutable vector operations +- no slice/view APIs +- no ABI/layout stability promise +- no performance claim +- no stable stdlib/API freeze + +## Checks + +Focused checks for this slice: + +- `cargo test --manifest-path compiler/Cargo.toml --test standard_vec_i64_source_helpers_alpha --test standard_vec_f64_source_helpers_alpha` +- `cargo fmt --manifest-path compiler/Cargo.toml --check` +- `git diff --check -- compiler/tests/standard_vec_i64_source_helpers_alpha.rs compiler/tests/standard_vec_f64_source_helpers_alpha.rs compiler/Cargo.toml compiler/Cargo.lock README.md docs/POST_BETA_ROADMAP.md docs/language/ROADMAP.md docs/language/RELEASE_NOTES.md docs/language/SPEC-v1.md docs/compiler/ROADMAP.md docs/compiler/RELEASE_NOTES.md .llm/BETA_12_CONCRETE_VECTOR_QUERY_AND_PREFIX_PARITY.md` diff --git a/.llm/reviews/BETA_12_RELEASE_REVIEW.md b/.llm/reviews/BETA_12_RELEASE_REVIEW.md new file mode 100644 index 0000000..dee3c1c --- /dev/null +++ b/.llm/reviews/BETA_12_RELEASE_REVIEW.md @@ -0,0 +1,54 @@ +# 1.0.0-beta.12 Release Review + +Status: ready for publication after controller release gate. + +## Verdict + +No blocking issues found in the current beta12 worktree. The slice is correctly +framed as concrete vector source-helper parity and can proceed to the final +publication gate. + +## Scope Checked + +- `lib/std/vec_i64.slo` exports and implements `count_of`, `starts_with`, + `without_prefix`, `ends_with`, and `without_suffix` as ordinary source + helpers over the existing `std.vec.i64` runtime wrappers and staged helper + surface. +- `lib/std/vec_f64.slo` exports and implements `count_of` as an ordinary + source helper; the existing f64 prefix/suffix helpers remain aligned. +- Local fixture copies, explicit `std.vec_i64` and `std.vec_f64` examples, and + mirrored language-doc examples import and exercise the new helpers. +- Focused helper tests, source-search tests, and promotion-gate inventories now + require the new exports and expected `20 test(s) passed` fixture output. +- README, roadmaps, release notes, SPEC-v1, regenerated `STDLIB_API.md`, the + beta12 `.llm` scope note, and the compiler package version bump align on the + `1.0.0-beta.12` concrete vector query and prefix parity scope. + +## Findings + +No blockers. + +- Helper semantics match the existing concrete lanes: exact equality counts, + empty prefix/suffix success, longer input rejection, mismatch rejection, exact + removal to empty, and unmatched removal returning the original vector. +- Release-facing text keeps the scope narrow: no source-language, runtime, + typed-core, compiler-known stdlib/runtime-name, generic dispatch, map/set, + iterator, mutable-vector, slice/view, ABI/layout, performance, or stable + stdlib/API-freeze claim. +- `STDLIB_API.md` is consistent with the current `lib/std` sources: 578 + exported helper signatures total, with 36 each for `std.vec_i64` and + `std.vec_f64`. +- Publication hygiene review found no beta12 private local path leakage in the + touched release-facing text. + +## Verification + +- `cargo test --manifest-path compiler/Cargo.toml --test standard_vec_i64_source_helpers_alpha --test standard_vec_f64_source_helpers_alpha --test standard_vec_i64_source_search_alpha --test standard_vec_f64_source_search_alpha`: passed. +- `cargo fmt --manifest-path compiler/Cargo.toml --check`: passed. +- `git diff --check`: passed. +- `STDLIB_API.md` was regenerated in an isolated copy and compared against the + worktree copy: no diff. + +- `./scripts/release-gate.sh`: passed after the beta12 release commit, including + docs/API freshness, `cargo fmt --check`, full `cargo test`, ignored promotion + gates, binary smoke, and LLVM smoke. diff --git a/README.md b/README.md index 262e770..d89081c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository is the canonical public monorepo for the language design, standard library source, compiler, runtime, examples, benchmarks, and technical documents. -Current release: `1.0.0-beta.11`. +Current release: `1.0.0-beta.12`. ## Repository Layout @@ -24,7 +24,7 @@ scripts/ local release and document tooling ## Beta Scope -`1.0.0-beta.11` keeps the `1.0.0-beta` language baseline, includes the +`1.0.0-beta.12` keeps the `1.0.0-beta` language baseline, includes the `1.0.0-beta.1` tooling/install hardening slice, the `1.0.0-beta.2` runtime/resource foundation bundle, the `1.0.0-beta.3` standard-library stabilization bundle, the `1.0.0-beta.4` language-usability diagnostics @@ -34,6 +34,7 @@ serialization/data-interchange foundation and the `1.0.0-beta.8` concrete type alias foundation, the `1.0.0-beta.9` collection alias unification and generic reservation slice, the `1.0.0-beta.10` developer-experience API discovery slice, and the `1.0.0-beta.11` local package API documentation +slice, plus the `1.0.0-beta.12` concrete vector query and prefix parity slice. The language baseline supports practical local command-line, file, and loopback-network programs with: @@ -61,19 +62,25 @@ structs, enums, functions, tests, source spans, and workspace package names. API sections for local package and module documentation: exact exported function signatures, exported struct fields, exported enum variants and payload types, non-export filtering, and module-local alias normalization. +The `1.0.0-beta.12` vector parity slice adds source-authored helper coverage +only: `std.vec_i64` gains `count_of`, `starts_with`, `without_prefix`, +`ends_with`, and `without_suffix`, while `std.vec_f64` gains `count_of`. Still deferred before stable: executable generics, maps/sets, broad package registry semantics, stable Markdown schema, stable stdlib/API compatibility freeze, DNS/TLS/async networking, LSP/watch guarantees, SARIF and daemon protocols, diagnostics schema policy, re-exports/globs/hierarchical modules, -stable ABI and layout, and runtime changes for generic collections. +mutable vectors, slice/view APIs, iterators, new compiler-known runtime names, +stable ABI and layout, performance claims, and runtime changes for generic +collections. -The next likely language slice after `1.0.0-beta.11` should continue from the +The next likely language slice after `1.0.0-beta.12` should continue from the developer-experience, diagnostics, and reserved generic/collection lanes without claiming executable generics, maps, sets, traits, inference, monomorphization, iterators, ABI stability, runtime changes, LSP/watch protocols, registry semantics, stable Markdown schema, or a -standard-library/API compatibility freeze until the contract and gates are +standard-library/API compatibility freeze, mutable vectors, slice/view APIs, +new runtime names, or performance claims until the contract and gates are explicit. ## Build And Test @@ -287,6 +294,19 @@ SARIF or daemon protocols, set diagnostics schema policy, implement executable generics, maps, or sets, add re-exports, globs, or hierarchical modules, or define package registry semantics. +## 1.0.0-beta.12 Concrete Vector Query And Prefix Parity + +The `1.0.0-beta.12` release is a source-authored stdlib/helper parity update +for concrete vectors. It adds `count_of`, `starts_with`, `without_prefix`, +`ends_with`, and `without_suffix` to `std.vec_i64`, and adds `count_of` to +`std.vec_f64`, matching the already staged concrete helper style. + +This release does not change the source language, runtime, compiler-known +`std.vec.*` names, ABI/layout contract, or performance contract. Generics, +maps/sets, iterators, mutable vectors, slice/view APIs, new runtime helper +names, stable stdlib API freeze, and broader collection abstractions remain +deferred. + ## Documentation - [Language Manifest](docs/language/MANIFEST.md) diff --git a/compiler/Cargo.lock b/compiler/Cargo.lock index 8463c80..c7eaaaa 100644 --- a/compiler/Cargo.lock +++ b/compiler/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "glagol" -version = "1.0.0-beta.11" +version = "1.0.0-beta.12" diff --git a/compiler/Cargo.toml b/compiler/Cargo.toml index 9c525b1..7614452 100644 --- a/compiler/Cargo.toml +++ b/compiler/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "glagol" -version = "1.0.0-beta.11" +version = "1.0.0-beta.12" edition = "2021" description = "Glagol, the first compiler for the Slovo language" license = "MIT OR Apache-2.0" diff --git a/compiler/tests/promotion_gate.rs b/compiler/tests/promotion_gate.rs index b78a7e4..35eeb60 100644 --- a/compiler/tests/promotion_gate.rs +++ b/compiler/tests/promotion_gate.rs @@ -1468,9 +1468,14 @@ const STANDARD_VEC_I64_SOURCE_FACADE_ALPHA: &[&str] = &[ "index_of_option", "last_index_of_option", "contains", + "count_of", "sum", "concat", "take", + "starts_with", + "without_prefix", + "ends_with", + "without_suffix", "drop", "reverse", "subvec", @@ -1502,9 +1507,14 @@ const STANDARD_VEC_F64_SOURCE_FACADE_ALPHA: &[&str] = &[ "index_of_option", "last_index_of_option", "contains", + "count_of", "sum", "concat", "take", + "starts_with", + "without_prefix", + "ends_with", + "without_suffix", "drop", "reverse", "subvec", @@ -7582,6 +7592,11 @@ fn assert_project_std_import_vec_i64_tooling_matches_fixture(project: &Path) { "test \"explicit std vec_i64 builder helpers\" ... ok\n", "test \"explicit std vec_i64 query helpers\" ... ok\n", "test \"explicit std vec_i64 option query helpers\" ... ok\n", + "test \"explicit std vec_i64 count_of helper\" ... ok\n", + "test \"explicit std vec_i64 starts_with helper\" ... ok\n", + "test \"explicit std vec_i64 ends_with helper\" ... ok\n", + "test \"explicit std vec_i64 without_suffix helper\" ... ok\n", + "test \"explicit std vec_i64 without_prefix helper\" ... ok\n", "test \"explicit std vec_i64 transform helpers\" ... ok\n", "test \"explicit std vec_i64 subvec helper\" ... ok\n", "test \"explicit std vec_i64 insert helper\" ... ok\n", @@ -7592,7 +7607,7 @@ fn assert_project_std_import_vec_i64_tooling_matches_fixture(project: &Path) { "test \"explicit std vec_i64 remove range helper\" ... ok\n", "test \"explicit std vec_i64 real program helpers\" ... ok\n", "test \"explicit std vec_i64 helpers all\" ... ok\n", - "15 test(s) passed\n", + "20 test(s) passed\n", ), "std import vec_i64 project test", ); @@ -7676,6 +7691,7 @@ fn assert_project_std_import_vec_f64_tooling_matches_fixture(project: &Path) { "test \"explicit std vec_f64 builder helpers\" ... ok\n", "test \"explicit std vec_f64 query helpers\" ... ok\n", "test \"explicit std vec_f64 option query helpers\" ... ok\n", + "test \"explicit std vec_f64 count_of helper\" ... ok\n", "test \"explicit std vec_f64 starts_with helper\" ... ok\n", "test \"explicit std vec_f64 ends_with helper\" ... ok\n", "test \"explicit std vec_f64 without_suffix helper\" ... ok\n", @@ -7690,7 +7706,7 @@ fn assert_project_std_import_vec_f64_tooling_matches_fixture(project: &Path) { "test \"explicit std vec_f64 remove range helper\" ... ok\n", "test \"explicit std vec_f64 real program helpers\" ... ok\n", "test \"explicit std vec_f64 helpers all\" ... ok\n", - "19 test(s) passed\n", + "20 test(s) passed\n", ), "std import vec_f64 project test", ); @@ -9784,6 +9800,11 @@ fn assert_project_std_layout_local_vec_i64_tooling_matches_fixture(project: &Pat "test \"explicit local vec_i64 builder helpers\" ... ok\n", "test \"explicit local vec_i64 query helpers\" ... ok\n", "test \"explicit local vec_i64 option query helpers\" ... ok\n", + "test \"explicit local vec_i64 count_of helper\" ... ok\n", + "test \"explicit local vec_i64 starts_with helper\" ... ok\n", + "test \"explicit local vec_i64 ends_with helper\" ... ok\n", + "test \"explicit local vec_i64 without_suffix helper\" ... ok\n", + "test \"explicit local vec_i64 without_prefix helper\" ... ok\n", "test \"explicit local vec_i64 transform helpers\" ... ok\n", "test \"explicit local vec_i64 subvec helper\" ... ok\n", "test \"explicit local vec_i64 insert helper\" ... ok\n", @@ -9794,7 +9815,7 @@ fn assert_project_std_layout_local_vec_i64_tooling_matches_fixture(project: &Pat "test \"explicit local vec_i64 remove range helper\" ... ok\n", "test \"explicit local vec_i64 real program helpers\" ... ok\n", "test \"explicit local vec_i64 helpers all\" ... ok\n", - "15 test(s) passed\n", + "20 test(s) passed\n", ), "std layout local vec_i64 project test", ); @@ -9818,6 +9839,7 @@ fn assert_project_std_layout_local_vec_f64_tooling_matches_fixture(project: &Pat "test \"explicit local vec_f64 builder helpers\" ... ok\n", "test \"explicit local vec_f64 query helpers\" ... ok\n", "test \"explicit local vec_f64 option query helpers\" ... ok\n", + "test \"explicit local vec_f64 count_of helper\" ... ok\n", "test \"explicit local vec_f64 starts_with helper\" ... ok\n", "test \"explicit local vec_f64 ends_with helper\" ... ok\n", "test \"explicit local vec_f64 without_suffix helper\" ... ok\n", @@ -9832,7 +9854,7 @@ fn assert_project_std_layout_local_vec_f64_tooling_matches_fixture(project: &Pat "test \"explicit local vec_f64 remove range helper\" ... ok\n", "test \"explicit local vec_f64 real program helpers\" ... ok\n", "test \"explicit local vec_f64 helpers all\" ... ok\n", - "19 test(s) passed\n", + "20 test(s) passed\n", ), "std layout local vec_f64 project test", ); diff --git a/compiler/tests/standard_vec_f64_source_helpers_alpha.rs b/compiler/tests/standard_vec_f64_source_helpers_alpha.rs index a83f396..765fc4a 100644 --- a/compiler/tests/standard_vec_f64_source_helpers_alpha.rs +++ b/compiler/tests/standard_vec_f64_source_helpers_alpha.rs @@ -11,6 +11,7 @@ const EXPECTED_TEST_OUTPUT: &str = concat!( "test \"explicit local vec_f64 builder helpers\" ... ok\n", "test \"explicit local vec_f64 query helpers\" ... ok\n", "test \"explicit local vec_f64 option query helpers\" ... ok\n", + "test \"explicit local vec_f64 count_of helper\" ... ok\n", "test \"explicit local vec_f64 starts_with helper\" ... ok\n", "test \"explicit local vec_f64 ends_with helper\" ... ok\n", "test \"explicit local vec_f64 without_suffix helper\" ... ok\n", @@ -25,7 +26,7 @@ const EXPECTED_TEST_OUTPUT: &str = concat!( "test \"explicit local vec_f64 remove range helper\" ... ok\n", "test \"explicit local vec_f64 real program helpers\" ... ok\n", "test \"explicit local vec_f64 helpers all\" ... ok\n", - "19 test(s) passed\n", + "20 test(s) passed\n", ); const STANDARD_VEC_F64_SOURCE_FACADE_ALPHA: &[&str] = &[ @@ -48,6 +49,7 @@ const STANDARD_VEC_F64_SOURCE_FACADE_ALPHA: &[&str] = &[ "index_of_option", "last_index_of_option", "contains", + "count_of", "sum", "concat", "take", @@ -184,6 +186,7 @@ fn assert_local_vec_f64_fixture_is_source_authored(project: &Path) { "index_of_option_loop", "last_index_of_option_loop", "contains_loop", + "count_of_loop", "sum_loop", "concat_loop", "take_loop", @@ -196,6 +199,43 @@ fn assert_local_vec_f64_fixture_is_source_authored(project: &Path) { helper ); } + + assert_count_of_cases_are_exercised(&main); + assert_prefix_suffix_cases_are_exercised(&main); +} + +fn assert_count_of_cases_are_exercised(main: &str) { + assert!( + main.contains("(count_of (empty)"), + "main.slo must exercise count_of on an empty vec_f64" + ); + assert!( + main.matches("(count_of").count() >= 4, + "main.slo must exercise repeated, singleton, and absent count_of cases" + ); +} + +fn assert_prefix_suffix_cases_are_exercised(main: &str) { + for case in [ + "(starts_with values (empty))", + "(starts_with values values)", + "(ends_with values (empty))", + "(ends_with values values)", + "(without_prefix values (empty))", + "(without_prefix values values)", + "(without_suffix values (empty))", + "(without_suffix values values)", + "mismatched_prefix", + "mismatched_suffix", + "longer_prefix", + "longer_suffix", + ] { + assert!( + main.contains(case), + "main.slo must exercise vec_f64 prefix/suffix case `{}`", + case + ); + } } fn run_glagol(args: I) -> Output diff --git a/compiler/tests/standard_vec_f64_source_search_alpha.rs b/compiler/tests/standard_vec_f64_source_search_alpha.rs index d33d250..739e519 100644 --- a/compiler/tests/standard_vec_f64_source_search_alpha.rs +++ b/compiler/tests/standard_vec_f64_source_search_alpha.rs @@ -11,6 +11,7 @@ const EXPECTED_STD_VEC_F64_OUTPUT: &str = concat!( "test \"explicit std vec_f64 builder helpers\" ... ok\n", "test \"explicit std vec_f64 query helpers\" ... ok\n", "test \"explicit std vec_f64 option query helpers\" ... ok\n", + "test \"explicit std vec_f64 count_of helper\" ... ok\n", "test \"explicit std vec_f64 starts_with helper\" ... ok\n", "test \"explicit std vec_f64 ends_with helper\" ... ok\n", "test \"explicit std vec_f64 without_suffix helper\" ... ok\n", @@ -25,7 +26,7 @@ const EXPECTED_STD_VEC_F64_OUTPUT: &str = concat!( "test \"explicit std vec_f64 remove range helper\" ... ok\n", "test \"explicit std vec_f64 real program helpers\" ... ok\n", "test \"explicit std vec_f64 helpers all\" ... ok\n", - "19 test(s) passed\n", + "20 test(s) passed\n", ); const STANDARD_VEC_F64_SOURCE_FACADE_ALPHA: &[&str] = &[ @@ -48,6 +49,7 @@ const STANDARD_VEC_F64_SOURCE_FACADE_ALPHA: &[&str] = &[ "index_of_option", "last_index_of_option", "contains", + "count_of", "sum", "concat", "take", diff --git a/compiler/tests/standard_vec_i64_source_helpers_alpha.rs b/compiler/tests/standard_vec_i64_source_helpers_alpha.rs index 4b643e5..0dce29f 100644 --- a/compiler/tests/standard_vec_i64_source_helpers_alpha.rs +++ b/compiler/tests/standard_vec_i64_source_helpers_alpha.rs @@ -11,6 +11,11 @@ const EXPECTED_TEST_OUTPUT: &str = concat!( "test \"explicit local vec_i64 builder helpers\" ... ok\n", "test \"explicit local vec_i64 query helpers\" ... ok\n", "test \"explicit local vec_i64 option query helpers\" ... ok\n", + "test \"explicit local vec_i64 count_of helper\" ... ok\n", + "test \"explicit local vec_i64 starts_with helper\" ... ok\n", + "test \"explicit local vec_i64 ends_with helper\" ... ok\n", + "test \"explicit local vec_i64 without_suffix helper\" ... ok\n", + "test \"explicit local vec_i64 without_prefix helper\" ... ok\n", "test \"explicit local vec_i64 transform helpers\" ... ok\n", "test \"explicit local vec_i64 subvec helper\" ... ok\n", "test \"explicit local vec_i64 insert helper\" ... ok\n", @@ -21,7 +26,7 @@ const EXPECTED_TEST_OUTPUT: &str = concat!( "test \"explicit local vec_i64 remove range helper\" ... ok\n", "test \"explicit local vec_i64 real program helpers\" ... ok\n", "test \"explicit local vec_i64 helpers all\" ... ok\n", - "15 test(s) passed\n", + "20 test(s) passed\n", ); const STANDARD_VEC_I64_SOURCE_FACADE_ALPHA: &[&str] = &[ @@ -44,9 +49,14 @@ const STANDARD_VEC_I64_SOURCE_FACADE_ALPHA: &[&str] = &[ "index_of_option", "last_index_of_option", "contains", + "count_of", "sum", "concat", "take", + "starts_with", + "without_prefix", + "ends_with", + "without_suffix", "drop", "reverse", "subvec", @@ -176,6 +186,7 @@ fn assert_local_vec_i64_fixture_is_source_authored(project: &Path) { "index_of_option_loop", "last_index_of_option_loop", "contains_loop", + "count_of_loop", "sum_loop", "concat_loop", "take_loop", @@ -188,6 +199,43 @@ fn assert_local_vec_i64_fixture_is_source_authored(project: &Path) { helper ); } + + assert_count_of_cases_are_exercised(&main); + assert_prefix_suffix_cases_are_exercised(&main); +} + +fn assert_count_of_cases_are_exercised(main: &str) { + assert!( + main.contains("(count_of (empty)"), + "main.slo must exercise count_of on an empty vec_i64" + ); + assert!( + main.matches("(count_of").count() >= 4, + "main.slo must exercise repeated, singleton, and absent count_of cases" + ); +} + +fn assert_prefix_suffix_cases_are_exercised(main: &str) { + for case in [ + "(starts_with values (empty))", + "(starts_with values values)", + "(ends_with values (empty))", + "(ends_with values values)", + "(without_prefix values (empty))", + "(without_prefix values values)", + "(without_suffix values (empty))", + "(without_suffix values values)", + "mismatched_prefix", + "mismatched_suffix", + "longer_prefix", + "longer_suffix", + ] { + assert!( + main.contains(case), + "main.slo must exercise vec_i64 prefix/suffix case `{}`", + case + ); + } } fn run_glagol(args: I) -> Output diff --git a/compiler/tests/standard_vec_i64_source_search_alpha.rs b/compiler/tests/standard_vec_i64_source_search_alpha.rs index 993945d..1e5689e 100644 --- a/compiler/tests/standard_vec_i64_source_search_alpha.rs +++ b/compiler/tests/standard_vec_i64_source_search_alpha.rs @@ -11,6 +11,11 @@ const EXPECTED_STD_VEC_I64_OUTPUT: &str = concat!( "test \"explicit std vec_i64 builder helpers\" ... ok\n", "test \"explicit std vec_i64 query helpers\" ... ok\n", "test \"explicit std vec_i64 option query helpers\" ... ok\n", + "test \"explicit std vec_i64 count_of helper\" ... ok\n", + "test \"explicit std vec_i64 starts_with helper\" ... ok\n", + "test \"explicit std vec_i64 ends_with helper\" ... ok\n", + "test \"explicit std vec_i64 without_suffix helper\" ... ok\n", + "test \"explicit std vec_i64 without_prefix helper\" ... ok\n", "test \"explicit std vec_i64 transform helpers\" ... ok\n", "test \"explicit std vec_i64 subvec helper\" ... ok\n", "test \"explicit std vec_i64 insert helper\" ... ok\n", @@ -21,7 +26,7 @@ const EXPECTED_STD_VEC_I64_OUTPUT: &str = concat!( "test \"explicit std vec_i64 remove range helper\" ... ok\n", "test \"explicit std vec_i64 real program helpers\" ... ok\n", "test \"explicit std vec_i64 helpers all\" ... ok\n", - "15 test(s) passed\n", + "20 test(s) passed\n", ); const STANDARD_VEC_I64_SOURCE_FACADE_ALPHA: &[&str] = &[ @@ -44,9 +49,14 @@ const STANDARD_VEC_I64_SOURCE_FACADE_ALPHA: &[&str] = &[ "index_of_option", "last_index_of_option", "contains", + "count_of", "sum", "concat", "take", + "starts_with", + "without_prefix", + "ends_with", + "without_suffix", "drop", "reverse", "subvec", diff --git a/docs/POST_BETA_ROADMAP.md b/docs/POST_BETA_ROADMAP.md index c936bf2..30dfa5b 100644 --- a/docs/POST_BETA_ROADMAP.md +++ b/docs/POST_BETA_ROADMAP.md @@ -319,6 +319,35 @@ Why eleventh: local packages are useful only if their public surface can be reviewed without reading every source file, but the documentation format should remain flexible until the package and editor stories are stronger. +### 12. Concrete Vector Query And Prefix Parity + +Goal: close small source-authored helper gaps in the current concrete vector +facades before returning to larger language and tooling slices. + +Work: + +- add `count_of`, `starts_with`, `without_prefix`, `ends_with`, and + `without_suffix` to `std.vec_i64` +- add `count_of` to `std.vec_f64` +- keep all helpers source-authored over the already promoted concrete vector + runtime names, equality, `len`, `at`, `take`, `drop`, and recursive helper + style +- add explicit local helper project coverage for repeated count results and + prefix/suffix empty, mismatch, exact, and longer-than-input cases where + applicable +- document the slice as helper parity only, not a language/runtime change + +Released in `1.0.0-beta.12`: `std.vec_i64` gains `count_of`, `starts_with`, +`without_prefix`, `ends_with`, and `without_suffix`; `std.vec_f64` gains +`count_of`; and focused Glagol fixture tests require the corresponding explicit +source-helper coverage. The release does not add generics, maps/sets, +iterators, mutable vectors, slice/view APIs, new runtime names, ABI/layout +stability, performance claims, or a stable stdlib/API freeze. + +Why twelfth: concrete vectors are already broad enough that parity gaps create +surprising differences, and source-authored helpers can close those gaps +without committing to generic collection design. + ## Stable `1.0.0` Gate Slovo should not become stable until all of these are true: @@ -344,5 +373,9 @@ complete first: - macro system - stable C ABI/layout guarantees - optimizing compiler claims +- mutable vectors, slice/view APIs, iterators, maps, sets, and executable + generics +- new runtime helper names or generic stdlib dispatch before an explicit + runtime/language slice - web framework or HTTP server framework - broad Unicode/string normalization policy diff --git a/docs/compiler/RELEASE_NOTES.md b/docs/compiler/RELEASE_NOTES.md index caa43fd..cc373be 100644 --- a/docs/compiler/RELEASE_NOTES.md +++ b/docs/compiler/RELEASE_NOTES.md @@ -10,11 +10,43 @@ integration/readiness release, not the first real beta. ## Unreleased -Next scoped Glagol work is expected to continue after the `1.0.0-beta.11` -local package API documentation update. +Next scoped Glagol work is expected to continue after the `1.0.0-beta.12` +concrete vector query and prefix parity update. No unreleased compiler scope is committed here yet. +## 1.0.0-beta.12 + +Release label: `1.0.0-beta.12` + +Release date: 2026-05-22 + +Release state: source-authored concrete vector helper parity update + +### Summary + +The beta.12 compiler-side contract is test and package metadata support for a +stdlib/helper parity release. It keeps Glagol language execution, runtime +lowering, and compiler-known `std.vec.*` names unchanged. + +- Bump the `glagol` compiler package version to `1.0.0-beta.12`. +- Extend explicit local `std.vec_i64` source-helper fixture tests to require + `count_of`, `starts_with`, `without_prefix`, `ends_with`, and + `without_suffix`. +- Extend explicit local `std.vec_f64` source-helper fixture tests to require + `count_of`. +- Require focused fixture coverage for repeated count results and + prefix/suffix empty, mismatch, exact, and longer-than-input cases where + applicable. + +### Explicit Deferrals + +This release does not implement source-language runtime changes, executable +generics, generic vectors, maps, sets, iterators, mutable vectors, slice/view +APIs, generic stdlib dispatch, new compiler-known stdlib or runtime names, +stable collection ABI/layout, performance claims, or a stable stdlib/API +compatibility freeze. + ## 1.0.0-beta.11 Release label: `1.0.0-beta.11` diff --git a/docs/compiler/ROADMAP.md b/docs/compiler/ROADMAP.md index effa563..b349110 100644 --- a/docs/compiler/ROADMAP.md +++ b/docs/compiler/ROADMAP.md @@ -22,8 +22,8 @@ general-purpose beta release. A Glagol feature is done only when it has parser/lowerer support, checker behavior, diagnostics for invalid forms, backend behavior or explicit unsupported diagnostics, and tests. -Current stage: `1.0.0-beta.11`, released on 2026-05-22 as a local package API -documentation update. It keeps the `1.0.0-beta` +Current stage: `1.0.0-beta.12`, released on 2026-05-22 as a concrete vector +query and prefix parity update. It keeps the `1.0.0-beta` language/compiler support baseline and includes the `1.0.0-beta.1` tooling hardening release, the `1.0.0-beta.2` runtime/resource foundation release, the `1.0.0-beta.3` standard-library stabilization release, @@ -47,15 +47,21 @@ The beta.11 documentation slice extends exported/public API sections for local packages and modules, including exact exported function signatures, exported struct fields, exported enum variants/payload types, non-export filtering, and module-local alias -normalization. It adds no source-language runtime behavior. +normalization. The beta.12 stdlib/helper parity slice adds source-authored +coverage for `std.vec_i64.count_of`, `std.vec_i64.starts_with`, +`std.vec_i64.without_prefix`, `std.vec_i64.ends_with`, +`std.vec_i64.without_suffix`, and `std.vec_f64.count_of` without changing +source-language runtime behavior. -Next stage target: post-`1.0.0-beta.11` developer-experience, +Next stage target: post-`1.0.0-beta.12` developer-experience, diagnostics-schema, package, and collection/generic planning. Generic vectors, maps, sets, generic stdlib dispatch, runtime collection changes, collection unification, stable Markdown schema, LSP/watch protocols, SARIF/daemon protocols, re-exports/globs/hierarchical modules, diagnostics schema policy, -registry semantics, and a stable stdlib/API compatibility freeze remain -unimplemented until a later scoped contract promotes them explicitly. +registry semantics, mutable vectors, slice/view APIs, new runtime names, +iterators, performance claims, ABI/layout stability, and a stable stdlib/API +compatibility freeze remain unimplemented until a later scoped contract +promotes them explicitly. The final experimental precursor scope is `exp-125`. Its unsigned direct-value flow, parse/format runtime lanes, and matching staged stdlib helper breadth diff --git a/docs/language/RELEASE_NOTES.md b/docs/language/RELEASE_NOTES.md index 2b5aaab..63f203a 100644 --- a/docs/language/RELEASE_NOTES.md +++ b/docs/language/RELEASE_NOTES.md @@ -8,7 +8,7 @@ Historical `exp-*` releases listed here are experimental maturity milestones. The pushed tag `v2.0.0-beta.1` is historical. It is now documented as an experimental integration/readiness release, not as a beta maturity claim. -The current release is `1.0.0-beta.11`, published on 2026-05-22. It keeps the +The current release is `1.0.0-beta.12`, published on 2026-05-22. It keeps the `1.0.0-beta` language surface, includes the first post-beta tooling/install hardening bundle from `1.0.0-beta.1`, and adds the first runtime/resource foundation bundle from `1.0.0-beta.2` plus the first standard-library @@ -21,12 +21,44 @@ first concrete type alias foundation from `1.0.0-beta.8`, plus the first collection alias unification and generic reservation slice from `1.0.0-beta.9`, the first developer-experience API discovery slice from `1.0.0-beta.10`, and the local package API documentation extension from -`1.0.0-beta.11`. +`1.0.0-beta.11`, plus the concrete vector query and prefix parity slice from +`1.0.0-beta.12`. ## Unreleased No unreleased language scope is committed here yet. +## 1.0.0-beta.12 + +Release label: `1.0.0-beta.12` + +Release name: Concrete Vector Query And Prefix Parity + +Release date: 2026-05-22 + +Status: released beta stdlib/helper parity update on the `1.0.0-beta` +language baseline. + +`1.0.0-beta.12` is a source-authored concrete vector helper release. It closes +small parity gaps in the current concrete vector facades without changing the +language, typed core, runtime, ABI, or compiler-known `std.vec.*` runtime +names: + +- `std.vec_i64` gains `count_of`, `starts_with`, `without_prefix`, + `ends_with`, and `without_suffix`. +- `std.vec_f64` gains `count_of`. +- The helper behavior stays source-authored over the existing concrete vector + runtime names, current equality, `len`, `at`, `take`, `drop`, and recursive + helper style. +- Focused Glagol fixture coverage exercises repeated `count_of` results and + prefix/suffix empty, mismatch, exact, and longer-than-input cases where the + helper family applies. + +This release does not add executable generics, maps, sets, iterators, mutable +vectors, slice/view APIs, new runtime names, new compiler-known stdlib names, +ABI/layout stability, performance claims, stable stdlib API freeze, generic +stdlib dispatch, or broad collection abstractions. + ## 1.0.0-beta.11 Release label: `1.0.0-beta.11` diff --git a/docs/language/ROADMAP.md b/docs/language/ROADMAP.md index 9008646..69f44ca 100644 --- a/docs/language/ROADMAP.md +++ b/docs/language/ROADMAP.md @@ -10,8 +10,9 @@ Long-horizon planning lives in release train from the historical `v2.0.0-beta.1` tag toward and beyond the first real general-purpose beta Slovo contract. -Current stage: `1.0.0-beta.11`, released on 2026-05-22 as a post-beta local -package API documentation update. It keeps the `1.0.0-beta` language contract and +Current stage: `1.0.0-beta.12`, released on 2026-05-22 as a post-beta concrete +vector query and prefix parity update. It keeps the `1.0.0-beta` language +contract and includes the `1.0.0-beta.1` tooling hardening release, the `1.0.0-beta.2` runtime/resource foundation release, the `1.0.0-beta.3` standard-library stabilization release, the `1.0.0-beta.4` language-usability diagnostics @@ -27,21 +28,26 @@ signatures with module-local aliases normalized to concrete public types, plus workspaces, plus `glagol doc -o ` public API sections for local packages/modules with exact exported function signatures, exported struct fields, exported enum variants/payload types, non-export -filtering, and module-local alias normalization. JSON parsing, recursive JSON -values, executable generics, generic aliases, +filtering, and module-local alias normalization, plus source-authored concrete +vector helper parity: `std.vec_i64` gains `count_of`, `starts_with`, +`without_prefix`, `ends_with`, and `without_suffix`, and `std.vec_f64` gains +`count_of`. JSON parsing, recursive JSON values, executable generics, generic +aliases, parameterized aliases, cross-module alias visibility, maps/sets, traits, inference, monomorphization, iterators, runtime changes for generic collections, DNS, TLS, UDP, async IO, non-loopback binding, HTTP frameworks, rich host-error ADTs, stable ABI/layout, stable Markdown schema, stable stdlib/API compatibility freeze, LSP/watch, SARIF/daemon protocols, -diagnostics schema policy, re-exports/globs/hierarchical modules, and package +diagnostics schema policy, re-exports/globs/hierarchical modules, mutable +vectors, slice/view APIs, new runtime names, performance claims, and package registry semantics remain deferred. -Next stage target: continue from developer-experience, diagnostics, package, -and reserved generic/map/set planning without claiming executable generics, an -LSP/watch protocol, stable Markdown schema, registry semantics, or -stable standard-library/API compatibility freeze until the exact scope is -frozen from the manifest and roadmap. +Next stage target: continue after `1.0.0-beta.12` from developer-experience, +diagnostics, package, and reserved generic/map/set planning without claiming +executable generics, an LSP/watch protocol, stable Markdown schema, registry +semantics, or stable standard-library/API compatibility freeze, mutable +vectors, slice/view APIs, new runtime names, performance claims, maps/sets, or +iterators until the exact scope is frozen from the manifest and roadmap. The final experimental precursor scope is `exp-125`, defined in `.llm/EXP_125_UNSIGNED_U32_U64_NUMERIC_AND_STDLIB_BREADTH_ALPHA.md`. Its diff --git a/docs/language/SPEC-v1.md b/docs/language/SPEC-v1.md index c563fba..e936ed7 100644 --- a/docs/language/SPEC-v1.md +++ b/docs/language/SPEC-v1.md @@ -3,7 +3,8 @@ Status: living beta contract for `1.0.0-beta`, with the post-beta `1.0.0-beta.1` tooling/install update, `1.0.0-beta.2` runtime/resource foundation update, `1.0.0-beta.10` developer-experience API discovery update, -and `1.0.0-beta.11` local package API documentation update. The language contract integrates +`1.0.0-beta.11` local package API documentation update, and `1.0.0-beta.12` +concrete vector query and prefix parity update. The language contract integrates promoted language slices through `exp-125` and the historical publication baseline through `exp-123`. `1.0.0-beta` is the first real general-purpose beta release. `exp-125` completed the unsigned numeric and stdlib breadth @@ -139,6 +140,14 @@ Current v1 release surface and explicit experimental targets: compatibility freeze, LSP/watch contract, SARIF/daemon protocol, diagnostics schema policy, executable generics, maps/sets, re-exports, globs, hierarchical modules, or registry semantics +- `1.0.0-beta.12` concrete vector query and prefix parity target: + source-authored `std.vec_i64` gains `count_of`, `starts_with`, + `without_prefix`, `ends_with`, and `without_suffix`; source-authored + `std.vec_f64` gains `count_of`; this is helper parity over the current + concrete vector runtime names only, not a source-language/runtime change, + executable generics, maps/sets, iterators, mutable vectors, slice/view APIs, + new runtime names, ABI/layout stability, performance claims, or a stable + stdlib API freeze - `exp-1` owned runtime strings: compiler-known `std.string.concat` accepts two `string` values and returns an immutable runtime-owned `string`; existing string equality, length, printing, locals, parameters, returns, and calls work @@ -1307,6 +1316,35 @@ diagnostics schema policy, executable generics, maps/sets, re-exports, glob imports, hierarchical modules, registry semantics, runtime behavior, package ABI, or layout. +### 4.4.9 Post-Beta Concrete Vector Query And Prefix Parity + +Status: released in `1.0.0-beta.12` as a source-authored stdlib/helper parity +update on the existing concrete vector surface. + +`1.0.0-beta.12` closes narrow helper gaps in the concrete vector facades: + +- `std.vec_i64` exports `count_of`, `starts_with`, `without_prefix`, + `ends_with`, and `without_suffix`. +- `std.vec_f64` exports `count_of`. + +The helpers are ordinary Slovo source helpers. They build on the existing +compiler-known concrete vector runtime names, equality, `len`, `at`, and +already staged source helpers such as `take` and `drop`. They do not add new +source-language syntax, typed-core forms, runtime calls, compiler-known stdlib +names, ABI/layout commitments, or performance guarantees. + +The helper semantics follow the existing concrete vector family conventions: +`count_of(values,target)` returns the number of elements equal to `target`; +`starts_with(values,prefix)` and `ends_with(values,suffix)` accept empty, +exact, and shorter matching vectors and reject longer or mismatched vectors; +`without_prefix` and `without_suffix` return the original vector when the +prefix/suffix does not match and return the remaining vector when it does. + +This target explicitly does not add executable generics, generic vector +dispatch, maps, sets, iterators, mutable vectors, slice/view APIs, new runtime +names, stable ABI/layout promises, performance claims, or a stable stdlib API +freeze. + ## 4.5 v2.0.0-beta.1 Experimental Integration Readiness Status: current experimental Slovo-side release contract, released 2026-05-17. @@ -1502,22 +1540,23 @@ ABI symbols or stable runtime helper symbols. The exact promoted names are reserved from user function, export, import, local, and parameter shadowing. -The latest released Slovo-side collection target after exp-107 is `exp-108`, -Standard Vec String, F64, And Bool Prefix And Suffix Helpers Alpha. It -broadens `std/vec_string.slo`, `std/vec_f64.slo`, and `std/vec_bool.slo` -with exactly `starts_with`, `without_prefix`, `ends_with`, and -`without_suffix` over the already released concrete vec-string, vec-f64, and -vec-bool helper surfaces. The helper lanes stay source-authored, -recursive, and immutable and do not widen the promoted collection runtime -surface beyond those connected prefix/suffix helpers. +The latest released Slovo-side concrete collection helper target is +`1.0.0-beta.12`, Concrete Vector Query And Prefix Parity. It broadens +`std/vec_i64.slo` with `count_of`, `starts_with`, `without_prefix`, +`ends_with`, and `without_suffix`, and broadens `std/vec_f64.slo` with +`count_of`. The helper lanes stay source-authored, recursive, immutable, and +limited to the already promoted concrete vector runtime names. They do not +widen the promoted collection runtime surface or add new compiler-known names. The collections alpha slice explicitly defers generic vectors, vector element -types other than `i32`, `i64`, `f64`, `bool`, and `string`, vector mutation, vector -`var`, vector `set`, vector literals besides empty/append construction, a `push` -alias, nested vectors, vectors in arrays, vectors in structs, vectors in -options, vectors in results, iterators, slices, maps, sets, user-visible -deallocation, stable ABI/layout/helper-symbol promises, package expansion, -and IO expansion. +types other than `i32`, `i64`, `f64`, `bool`, and `string`, vector mutation, +mutable vector operations beyond whole-value `var`/`set` already promoted for +current concrete vectors, vector literals besides empty/append construction, a +`push` alias, nested vectors, vectors in arrays, vectors in structs, vectors in +options, vectors in results, iterators, slices/views, maps, sets, user-visible +deallocation, new runtime names, stable ABI/layout/helper-symbol promises, +performance claims, package expansion, stable stdlib API freeze, and IO +expansion. The collection fixture targets are: @@ -5856,8 +5895,9 @@ promises remain deferred until a future spec explicitly promotes them. concrete option source helpers, randomness beyond the exp-11 target, time beyond the exp-8 host time/sleep target, vectors/collections beyond the exp-2 - `(vec i32)`, exp-94 `(vec i64)`, exp-99 `(vec string)`, and exp-103 - `(vec f64)` targets, + `(vec i32)`, exp-94 `(vec i64)`, exp-99 `(vec string)`, exp-103 + `(vec f64)`, exp-104 `(vec bool)`, and beta.12 source-helper parity + targets, user-defined standard modules, overloading, and generic standard-library APIs - numeric primitives and conversions beyond exp-20 direct `f64`, exp-21 direct `i64`, exp-22 explicit `std.num.i32_to_i64`, @@ -5902,10 +5942,14 @@ promises remain deferred until a future spec explicitly promotes them. facade wrappers, including wall-clock/calendar/timezone APIs, high-resolution timers, async timers, cancellation, and scheduling guarantees -- generic vectors, vector element types other than `i32`, vector mutation, - vector literals beyond empty/append construction, `push`, nested vectors, - vectors in arrays/structs/options/results, iterators, slices, maps, sets, - user-visible vector deallocation, and stable vector ABI/layout/helper symbols +- generic vectors, vector element types other than `i32`, `i64`, `f64`, + `bool`, and `string`, element-level mutable vectors and mutable vector + operations beyond whole-value local reassignment, vector literals beyond + empty/append construction, `push`, nested vectors, vectors in + arrays/structs/options/results, iterators, slices/views, maps, sets, new + runtime vector helper names, performance claims, user-visible vector + deallocation, stable stdlib API freeze, and stable vector ABI/layout/helper + symbols - string concatenation beyond exp-1 `std.string.concat`, parsing beyond exp-13 `std.string.parse_i32_result`, exp-25 `std.string.parse_i64_result`, and exp-28 diff --git a/docs/language/STDLIB_API.md b/docs/language/STDLIB_API.md index 307c655..4b7e24a 100644 --- a/docs/language/STDLIB_API.md +++ b/docs/language/STDLIB_API.md @@ -6,7 +6,7 @@ Do not edit this file by hand. ## Stability Tiers - `beta-supported`: exported from `lib/std` and covered by source-search, promotion, or facade gates in the current beta line. -- `experimental`: not used for exported `lib/std` helpers in `1.0.0-beta.11`; future releases may mark new helpers this way before they graduate. +- `experimental`: not used for exported `lib/std` helpers in `1.0.0-beta.12`; future releases may mark new helpers this way before they graduate. - `internal`: helper names that are not exported from their module; they are intentionally omitted from this catalog. The catalog is a beta API discovery aid, not a stable `1.0.0` standard-library freeze. @@ -16,7 +16,7 @@ Only exported `(fn ...)` helpers are listed; `(type ...)` aliases and non-export ## Summary - Modules: 19 -- Exported helper signatures: 572 +- Exported helper signatures: 578 - Exported type aliases omitted: 0 - Default tier: `beta-supported` @@ -563,7 +563,7 @@ Only exported `(fn ...)` helpers are listed; `(type ...)` aliases and non-export - Path: `lib/std/vec_f64.slo` - Tier: `beta-supported` -- Exported helper signatures: 35 +- Exported helper signatures: 36 - `empty () -> (vec f64)` - `append ((values (vec f64)) (value f64)) -> (vec f64)` @@ -584,6 +584,7 @@ Only exported `(fn ...)` helpers are listed; `(type ...)` aliases and non-export - `index_of_option ((values (vec f64)) (target f64)) -> (option i32)` - `last_index_of_option ((values (vec f64)) (target f64)) -> (option i32)` - `contains ((values (vec f64)) (target f64)) -> bool` +- `count_of ((values (vec f64)) (target f64)) -> i32` - `sum ((values (vec f64))) -> f64` - `concat ((left (vec f64)) (right (vec f64))) -> (vec f64)` - `take ((values (vec f64)) (count i32)) -> (vec f64)` @@ -651,7 +652,7 @@ Only exported `(fn ...)` helpers are listed; `(type ...)` aliases and non-export - Path: `lib/std/vec_i64.slo` - Tier: `beta-supported` -- Exported helper signatures: 31 +- Exported helper signatures: 36 - `empty () -> (vec i64)` - `append ((values (vec i64)) (value i64)) -> (vec i64)` @@ -672,9 +673,14 @@ Only exported `(fn ...)` helpers are listed; `(type ...)` aliases and non-export - `index_of_option ((values (vec i64)) (target i64)) -> (option i32)` - `last_index_of_option ((values (vec i64)) (target i64)) -> (option i32)` - `contains ((values (vec i64)) (target i64)) -> bool` +- `count_of ((values (vec i64)) (target i64)) -> i32` - `sum ((values (vec i64))) -> i64` - `concat ((left (vec i64)) (right (vec i64))) -> (vec i64)` - `take ((values (vec i64)) (count i32)) -> (vec i64)` +- `starts_with ((values (vec i64)) (prefix (vec i64))) -> bool` +- `without_prefix ((values (vec i64)) (prefix (vec i64))) -> (vec i64)` +- `ends_with ((values (vec i64)) (suffix (vec i64))) -> bool` +- `without_suffix ((values (vec i64)) (suffix (vec i64))) -> (vec i64)` - `drop ((values (vec i64)) (count i32)) -> (vec i64)` - `reverse ((values (vec i64))) -> (vec i64)` - `subvec ((values (vec i64)) (start i32) (end_exclusive i32)) -> (vec i64)` diff --git a/docs/language/examples/projects/std-import-vec_f64/src/main.slo b/docs/language/examples/projects/std-import-vec_f64/src/main.slo index e4a49dd..ffb5535 100644 --- a/docs/language/examples/projects/std-import-vec_f64/src/main.slo +++ b/docs/language/examples/projects/std-import-vec_f64/src/main.slo @@ -1,6 +1,6 @@ (module main) -(import std.vec_f64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(import std.vec_f64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (fn imported_empty_length () -> i32 (len (empty))) @@ -72,6 +72,16 @@ false) false)) +(fn imported_count_of_helper_ok () -> bool + (let values (vec f64) (append3 (pair 10.0 20.0) 30.0 20.0 10.0)) + (if (= (count_of (empty) 20.0) 0) + (if (= (count_of values 99.0) 0) + (if (= (count_of values 20.0) 2) + (= (count_of values 10.0) 2) + false) + false) + false)) + (fn imported_starts_with_helper_ok () -> bool (let values (vec f64) (append2 (triple 10.0 20.0 30.0) 40.0 50.0)) (let prefix (vec f64) (pair 10.0 20.0)) @@ -285,19 +295,21 @@ (if (imported_builder_helpers_ok) (if (imported_query_helpers_ok) (if (imported_option_query_helpers_ok) - (if (imported_starts_with_helper_ok) - (if (imported_ends_with_helper_ok) - (if (imported_without_suffix_helper_ok) - (if (imported_without_prefix_helper_ok) - (if (imported_transform_helpers_ok) - (if (imported_subvec_helper_ok) - (if (imported_insert_helper_ok) - (if (imported_insert_range_helper_ok) - (if (imported_replace_helper_ok) - (if (imported_replace_range_helper_ok) - (if (imported_remove_helper_ok) - (if (imported_remove_range_helper_ok) - (imported_real_program_helpers_ok) + (if (imported_count_of_helper_ok) + (if (imported_starts_with_helper_ok) + (if (imported_ends_with_helper_ok) + (if (imported_without_suffix_helper_ok) + (if (imported_without_prefix_helper_ok) + (if (imported_transform_helpers_ok) + (if (imported_subvec_helper_ok) + (if (imported_insert_helper_ok) + (if (imported_insert_range_helper_ok) + (if (imported_replace_helper_ok) + (if (imported_replace_range_helper_ok) + (if (imported_remove_helper_ok) + (if (imported_remove_range_helper_ok) + (imported_real_program_helpers_ok) + false) false) false) false) @@ -331,6 +343,9 @@ (test "explicit std vec_f64 option query helpers" (imported_option_query_helpers_ok)) +(test "explicit std vec_f64 count_of helper" + (imported_count_of_helper_ok)) + (test "explicit std vec_f64 starts_with helper" (imported_starts_with_helper_ok)) diff --git a/docs/language/examples/projects/std-import-vec_i64/src/main.slo b/docs/language/examples/projects/std-import-vec_i64/src/main.slo index 21e9b91..bb2f3c0 100644 --- a/docs/language/examples/projects/std-import-vec_i64/src/main.slo +++ b/docs/language/examples/projects/std-import-vec_i64/src/main.slo @@ -1,6 +1,6 @@ (module main) -(import std.vec_i64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(import std.vec_i64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (fn imported_empty_length () -> i32 (len (empty))) @@ -72,6 +72,92 @@ false) false)) +(fn imported_count_of_helper_ok () -> bool + (let values (vec i64) (append3 (pair 10i64 20i64) 30i64 20i64 10i64)) + (if (= (count_of (empty) 20i64) 0) + (if (= (count_of values 99i64) 0) + (if (= (count_of values 20i64) 2) + (= (count_of values 10i64) 2) + false) + false) + false)) + +(fn imported_starts_with_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let prefix (vec i64) (pair 10i64 20i64)) + (let longer_prefix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_prefix (vec i64) (pair 20i64 30i64)) + (if (starts_with values (empty)) + (if (starts_with values prefix) + (if (starts_with values values) + (if (starts_with values longer_prefix) + false + (if (starts_with values mismatched_prefix) + false + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= prefix (pair 10i64 20i64)) + false))) + false) + false) + false)) + +(fn imported_ends_with_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let suffix (vec i64) (pair 40i64 50i64)) + (let longer_suffix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_suffix (vec i64) (pair 40i64 51i64)) + (if (ends_with values (empty)) + (if (ends_with values suffix) + (if (ends_with values values) + (if (ends_with values longer_suffix) + false + (if (ends_with values mismatched_suffix) + false + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= suffix (pair 40i64 50i64)) + false))) + false) + false) + false)) + +(fn imported_without_suffix_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let suffix (vec i64) (pair 40i64 50i64)) + (let longer_suffix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_suffix (vec i64) (pair 40i64 51i64)) + (if (= (without_suffix values (empty)) values) + (if (= (without_suffix values values) (empty)) + (if (= (without_suffix values suffix) (triple 10i64 20i64 30i64)) + (if (= (without_suffix values longer_suffix) values) + (if (= (without_suffix values mismatched_suffix) values) + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= suffix (pair 40i64 50i64)) + false) + false) + false) + false) + false) + false)) + +(fn imported_without_prefix_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let prefix (vec i64) (pair 10i64 20i64)) + (let longer_prefix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_prefix (vec i64) (pair 10i64 21i64)) + (if (= (without_prefix values (empty)) values) + (if (= (without_prefix values values) (empty)) + (if (= (without_prefix values prefix) (triple 30i64 40i64 50i64)) + (if (= (without_prefix values longer_prefix) values) + (if (= (without_prefix values mismatched_prefix) values) + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= prefix (pair 10i64 20i64)) + false) + false) + false) + false) + false) + false)) + (fn imported_transform_helpers_ok () -> bool (if (= (concat (empty) (pair 7i64 8i64)) (pair 7i64 8i64)) (if (= (concat (pair 1i64 2i64) (triple 3i64 4i64 5i64)) (append3 (pair 1i64 2i64) 3i64 4i64 5i64)) @@ -209,15 +295,25 @@ (if (imported_builder_helpers_ok) (if (imported_query_helpers_ok) (if (imported_option_query_helpers_ok) - (if (imported_transform_helpers_ok) - (if (imported_subvec_helper_ok) - (if (imported_insert_helper_ok) - (if (imported_insert_range_helper_ok) - (if (imported_replace_helper_ok) - (if (imported_replace_range_helper_ok) - (if (imported_remove_helper_ok) - (if (imported_remove_range_helper_ok) - (imported_real_program_helpers_ok) + (if (imported_count_of_helper_ok) + (if (imported_starts_with_helper_ok) + (if (imported_ends_with_helper_ok) + (if (imported_without_suffix_helper_ok) + (if (imported_without_prefix_helper_ok) + (if (imported_transform_helpers_ok) + (if (imported_subvec_helper_ok) + (if (imported_insert_helper_ok) + (if (imported_insert_range_helper_ok) + (if (imported_replace_helper_ok) + (if (imported_replace_range_helper_ok) + (if (imported_remove_helper_ok) + (if (imported_remove_range_helper_ok) + (imported_real_program_helpers_ok) + false) + false) + false) + false) + false) false) false) false) @@ -247,6 +343,21 @@ (test "explicit std vec_i64 option query helpers" (imported_option_query_helpers_ok)) +(test "explicit std vec_i64 count_of helper" + (imported_count_of_helper_ok)) + +(test "explicit std vec_i64 starts_with helper" + (imported_starts_with_helper_ok)) + +(test "explicit std vec_i64 ends_with helper" + (imported_ends_with_helper_ok)) + +(test "explicit std vec_i64 without_suffix helper" + (imported_without_suffix_helper_ok)) + +(test "explicit std vec_i64 without_prefix helper" + (imported_without_prefix_helper_ok)) + (test "explicit std vec_i64 transform helpers" (imported_transform_helpers_ok)) diff --git a/examples/projects/std-import-vec_f64/src/main.slo b/examples/projects/std-import-vec_f64/src/main.slo index e4a49dd..ffb5535 100644 --- a/examples/projects/std-import-vec_f64/src/main.slo +++ b/examples/projects/std-import-vec_f64/src/main.slo @@ -1,6 +1,6 @@ (module main) -(import std.vec_f64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(import std.vec_f64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (fn imported_empty_length () -> i32 (len (empty))) @@ -72,6 +72,16 @@ false) false)) +(fn imported_count_of_helper_ok () -> bool + (let values (vec f64) (append3 (pair 10.0 20.0) 30.0 20.0 10.0)) + (if (= (count_of (empty) 20.0) 0) + (if (= (count_of values 99.0) 0) + (if (= (count_of values 20.0) 2) + (= (count_of values 10.0) 2) + false) + false) + false)) + (fn imported_starts_with_helper_ok () -> bool (let values (vec f64) (append2 (triple 10.0 20.0 30.0) 40.0 50.0)) (let prefix (vec f64) (pair 10.0 20.0)) @@ -285,19 +295,21 @@ (if (imported_builder_helpers_ok) (if (imported_query_helpers_ok) (if (imported_option_query_helpers_ok) - (if (imported_starts_with_helper_ok) - (if (imported_ends_with_helper_ok) - (if (imported_without_suffix_helper_ok) - (if (imported_without_prefix_helper_ok) - (if (imported_transform_helpers_ok) - (if (imported_subvec_helper_ok) - (if (imported_insert_helper_ok) - (if (imported_insert_range_helper_ok) - (if (imported_replace_helper_ok) - (if (imported_replace_range_helper_ok) - (if (imported_remove_helper_ok) - (if (imported_remove_range_helper_ok) - (imported_real_program_helpers_ok) + (if (imported_count_of_helper_ok) + (if (imported_starts_with_helper_ok) + (if (imported_ends_with_helper_ok) + (if (imported_without_suffix_helper_ok) + (if (imported_without_prefix_helper_ok) + (if (imported_transform_helpers_ok) + (if (imported_subvec_helper_ok) + (if (imported_insert_helper_ok) + (if (imported_insert_range_helper_ok) + (if (imported_replace_helper_ok) + (if (imported_replace_range_helper_ok) + (if (imported_remove_helper_ok) + (if (imported_remove_range_helper_ok) + (imported_real_program_helpers_ok) + false) false) false) false) @@ -331,6 +343,9 @@ (test "explicit std vec_f64 option query helpers" (imported_option_query_helpers_ok)) +(test "explicit std vec_f64 count_of helper" + (imported_count_of_helper_ok)) + (test "explicit std vec_f64 starts_with helper" (imported_starts_with_helper_ok)) diff --git a/examples/projects/std-import-vec_i64/src/main.slo b/examples/projects/std-import-vec_i64/src/main.slo index 21e9b91..bb2f3c0 100644 --- a/examples/projects/std-import-vec_i64/src/main.slo +++ b/examples/projects/std-import-vec_i64/src/main.slo @@ -1,6 +1,6 @@ (module main) -(import std.vec_i64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(import std.vec_i64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (fn imported_empty_length () -> i32 (len (empty))) @@ -72,6 +72,92 @@ false) false)) +(fn imported_count_of_helper_ok () -> bool + (let values (vec i64) (append3 (pair 10i64 20i64) 30i64 20i64 10i64)) + (if (= (count_of (empty) 20i64) 0) + (if (= (count_of values 99i64) 0) + (if (= (count_of values 20i64) 2) + (= (count_of values 10i64) 2) + false) + false) + false)) + +(fn imported_starts_with_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let prefix (vec i64) (pair 10i64 20i64)) + (let longer_prefix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_prefix (vec i64) (pair 20i64 30i64)) + (if (starts_with values (empty)) + (if (starts_with values prefix) + (if (starts_with values values) + (if (starts_with values longer_prefix) + false + (if (starts_with values mismatched_prefix) + false + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= prefix (pair 10i64 20i64)) + false))) + false) + false) + false)) + +(fn imported_ends_with_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let suffix (vec i64) (pair 40i64 50i64)) + (let longer_suffix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_suffix (vec i64) (pair 40i64 51i64)) + (if (ends_with values (empty)) + (if (ends_with values suffix) + (if (ends_with values values) + (if (ends_with values longer_suffix) + false + (if (ends_with values mismatched_suffix) + false + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= suffix (pair 40i64 50i64)) + false))) + false) + false) + false)) + +(fn imported_without_suffix_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let suffix (vec i64) (pair 40i64 50i64)) + (let longer_suffix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_suffix (vec i64) (pair 40i64 51i64)) + (if (= (without_suffix values (empty)) values) + (if (= (without_suffix values values) (empty)) + (if (= (without_suffix values suffix) (triple 10i64 20i64 30i64)) + (if (= (without_suffix values longer_suffix) values) + (if (= (without_suffix values mismatched_suffix) values) + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= suffix (pair 40i64 50i64)) + false) + false) + false) + false) + false) + false)) + +(fn imported_without_prefix_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let prefix (vec i64) (pair 10i64 20i64)) + (let longer_prefix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_prefix (vec i64) (pair 10i64 21i64)) + (if (= (without_prefix values (empty)) values) + (if (= (without_prefix values values) (empty)) + (if (= (without_prefix values prefix) (triple 30i64 40i64 50i64)) + (if (= (without_prefix values longer_prefix) values) + (if (= (without_prefix values mismatched_prefix) values) + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= prefix (pair 10i64 20i64)) + false) + false) + false) + false) + false) + false)) + (fn imported_transform_helpers_ok () -> bool (if (= (concat (empty) (pair 7i64 8i64)) (pair 7i64 8i64)) (if (= (concat (pair 1i64 2i64) (triple 3i64 4i64 5i64)) (append3 (pair 1i64 2i64) 3i64 4i64 5i64)) @@ -209,15 +295,25 @@ (if (imported_builder_helpers_ok) (if (imported_query_helpers_ok) (if (imported_option_query_helpers_ok) - (if (imported_transform_helpers_ok) - (if (imported_subvec_helper_ok) - (if (imported_insert_helper_ok) - (if (imported_insert_range_helper_ok) - (if (imported_replace_helper_ok) - (if (imported_replace_range_helper_ok) - (if (imported_remove_helper_ok) - (if (imported_remove_range_helper_ok) - (imported_real_program_helpers_ok) + (if (imported_count_of_helper_ok) + (if (imported_starts_with_helper_ok) + (if (imported_ends_with_helper_ok) + (if (imported_without_suffix_helper_ok) + (if (imported_without_prefix_helper_ok) + (if (imported_transform_helpers_ok) + (if (imported_subvec_helper_ok) + (if (imported_insert_helper_ok) + (if (imported_insert_range_helper_ok) + (if (imported_replace_helper_ok) + (if (imported_replace_range_helper_ok) + (if (imported_remove_helper_ok) + (if (imported_remove_range_helper_ok) + (imported_real_program_helpers_ok) + false) + false) + false) + false) + false) false) false) false) @@ -247,6 +343,21 @@ (test "explicit std vec_i64 option query helpers" (imported_option_query_helpers_ok)) +(test "explicit std vec_i64 count_of helper" + (imported_count_of_helper_ok)) + +(test "explicit std vec_i64 starts_with helper" + (imported_starts_with_helper_ok)) + +(test "explicit std vec_i64 ends_with helper" + (imported_ends_with_helper_ok)) + +(test "explicit std vec_i64 without_suffix helper" + (imported_without_suffix_helper_ok)) + +(test "explicit std vec_i64 without_prefix helper" + (imported_without_prefix_helper_ok)) + (test "explicit std vec_i64 transform helpers" (imported_transform_helpers_ok)) diff --git a/examples/projects/std-layout-local-vec_f64/src/main.slo b/examples/projects/std-layout-local-vec_f64/src/main.slo index ecbde14..8135e09 100644 --- a/examples/projects/std-layout-local-vec_f64/src/main.slo +++ b/examples/projects/std-layout-local-vec_f64/src/main.slo @@ -1,6 +1,6 @@ (module main) -(import vec_f64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(import vec_f64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (fn imported_empty_length () -> i32 (len (empty))) @@ -72,6 +72,16 @@ false) false)) +(fn imported_count_of_helper_ok () -> bool + (let values (vec f64) (append3 (pair 10.0 20.0) 30.0 20.0 10.0)) + (if (= (count_of (empty) 20.0) 0) + (if (= (count_of values 99.0) 0) + (if (= (count_of values 20.0) 2) + (= (count_of values 10.0) 2) + false) + false) + false)) + (fn imported_starts_with_helper_ok () -> bool (let values (vec f64) (append2 (triple 10.0 20.0 30.0) 40.0 50.0)) (let prefix (vec f64) (pair 10.0 20.0)) @@ -285,19 +295,21 @@ (if (imported_builder_helpers_ok) (if (imported_query_helpers_ok) (if (imported_option_query_helpers_ok) - (if (imported_starts_with_helper_ok) - (if (imported_ends_with_helper_ok) - (if (imported_without_suffix_helper_ok) - (if (imported_without_prefix_helper_ok) - (if (imported_transform_helpers_ok) - (if (imported_subvec_helper_ok) - (if (imported_insert_helper_ok) - (if (imported_insert_range_helper_ok) - (if (imported_replace_helper_ok) - (if (imported_replace_range_helper_ok) - (if (imported_remove_helper_ok) - (if (imported_remove_range_helper_ok) - (imported_real_program_helpers_ok) + (if (imported_count_of_helper_ok) + (if (imported_starts_with_helper_ok) + (if (imported_ends_with_helper_ok) + (if (imported_without_suffix_helper_ok) + (if (imported_without_prefix_helper_ok) + (if (imported_transform_helpers_ok) + (if (imported_subvec_helper_ok) + (if (imported_insert_helper_ok) + (if (imported_insert_range_helper_ok) + (if (imported_replace_helper_ok) + (if (imported_replace_range_helper_ok) + (if (imported_remove_helper_ok) + (if (imported_remove_range_helper_ok) + (imported_real_program_helpers_ok) + false) false) false) false) @@ -331,6 +343,9 @@ (test "explicit local vec_f64 option query helpers" (imported_option_query_helpers_ok)) +(test "explicit local vec_f64 count_of helper" + (imported_count_of_helper_ok)) + (test "explicit local vec_f64 starts_with helper" (imported_starts_with_helper_ok)) diff --git a/examples/projects/std-layout-local-vec_f64/src/vec_f64.slo b/examples/projects/std-layout-local-vec_f64/src/vec_f64.slo index 8e8f6ef..483eeb8 100644 --- a/examples/projects/std-layout-local-vec_f64/src/vec_f64.slo +++ b/examples/projects/std-layout-local-vec_f64/src/vec_f64.slo @@ -1,4 +1,4 @@ -(module vec_f64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(module vec_f64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (type VecF64 (vec f64)) @@ -92,6 +92,16 @@ (fn contains ((values VecF64) (target f64)) -> bool (contains_loop values target 0 (len values))) +(fn count_of_loop ((values VecF64) (target f64) (position i32) (values_len i32) (hits i32)) -> i32 + (if (< position values_len) + (count_of_loop values target (+ position 1) values_len (+ hits (if (= (at values position) target) + 1 + 0))) + hits)) + +(fn count_of ((values VecF64) (target f64)) -> i32 + (count_of_loop values target 0 (len values) 0)) + (fn sum_loop ((values VecF64) (position i32) (values_len i32) (total f64)) -> f64 (if (< position values_len) (sum_loop values (+ position 1) values_len (+ total (at values position))) diff --git a/examples/projects/std-layout-local-vec_i64/src/main.slo b/examples/projects/std-layout-local-vec_i64/src/main.slo index f2b7667..8e29afa 100644 --- a/examples/projects/std-layout-local-vec_i64/src/main.slo +++ b/examples/projects/std-layout-local-vec_i64/src/main.slo @@ -1,6 +1,6 @@ (module main) -(import vec_i64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(import vec_i64 (empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (fn imported_empty_length () -> i32 (len (empty))) @@ -72,6 +72,92 @@ false) false)) +(fn imported_count_of_helper_ok () -> bool + (let values (vec i64) (append3 (pair 10i64 20i64) 30i64 20i64 10i64)) + (if (= (count_of (empty) 20i64) 0) + (if (= (count_of values 99i64) 0) + (if (= (count_of values 20i64) 2) + (= (count_of values 10i64) 2) + false) + false) + false)) + +(fn imported_starts_with_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let prefix (vec i64) (pair 10i64 20i64)) + (let longer_prefix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_prefix (vec i64) (pair 20i64 30i64)) + (if (starts_with values (empty)) + (if (starts_with values prefix) + (if (starts_with values values) + (if (starts_with values longer_prefix) + false + (if (starts_with values mismatched_prefix) + false + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= prefix (pair 10i64 20i64)) + false))) + false) + false) + false)) + +(fn imported_ends_with_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let suffix (vec i64) (pair 40i64 50i64)) + (let longer_suffix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_suffix (vec i64) (pair 40i64 51i64)) + (if (ends_with values (empty)) + (if (ends_with values suffix) + (if (ends_with values values) + (if (ends_with values longer_suffix) + false + (if (ends_with values mismatched_suffix) + false + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= suffix (pair 40i64 50i64)) + false))) + false) + false) + false)) + +(fn imported_without_suffix_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let suffix (vec i64) (pair 40i64 50i64)) + (let longer_suffix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_suffix (vec i64) (pair 40i64 51i64)) + (if (= (without_suffix values (empty)) values) + (if (= (without_suffix values values) (empty)) + (if (= (without_suffix values suffix) (triple 10i64 20i64 30i64)) + (if (= (without_suffix values longer_suffix) values) + (if (= (without_suffix values mismatched_suffix) values) + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= suffix (pair 40i64 50i64)) + false) + false) + false) + false) + false) + false)) + +(fn imported_without_prefix_helper_ok () -> bool + (let values (vec i64) (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (let prefix (vec i64) (pair 10i64 20i64)) + (let longer_prefix (vec i64) (append2 values 60i64 70i64)) + (let mismatched_prefix (vec i64) (pair 10i64 21i64)) + (if (= (without_prefix values (empty)) values) + (if (= (without_prefix values values) (empty)) + (if (= (without_prefix values prefix) (triple 30i64 40i64 50i64)) + (if (= (without_prefix values longer_prefix) values) + (if (= (without_prefix values mismatched_prefix) values) + (if (= values (append2 (triple 10i64 20i64 30i64) 40i64 50i64)) + (= prefix (pair 10i64 20i64)) + false) + false) + false) + false) + false) + false)) + (fn imported_transform_helpers_ok () -> bool (if (= (concat (empty) (pair 7i64 8i64)) (pair 7i64 8i64)) (if (= (concat (pair 1i64 2i64) (triple 3i64 4i64 5i64)) (append3 (pair 1i64 2i64) 3i64 4i64 5i64)) @@ -209,15 +295,25 @@ (if (imported_builder_helpers_ok) (if (imported_query_helpers_ok) (if (imported_option_query_helpers_ok) - (if (imported_transform_helpers_ok) - (if (imported_subvec_helper_ok) - (if (imported_insert_helper_ok) - (if (imported_insert_range_helper_ok) - (if (imported_replace_helper_ok) - (if (imported_replace_range_helper_ok) - (if (imported_remove_helper_ok) - (if (imported_remove_range_helper_ok) - (imported_real_program_helpers_ok) + (if (imported_count_of_helper_ok) + (if (imported_starts_with_helper_ok) + (if (imported_ends_with_helper_ok) + (if (imported_without_suffix_helper_ok) + (if (imported_without_prefix_helper_ok) + (if (imported_transform_helpers_ok) + (if (imported_subvec_helper_ok) + (if (imported_insert_helper_ok) + (if (imported_insert_range_helper_ok) + (if (imported_replace_helper_ok) + (if (imported_replace_range_helper_ok) + (if (imported_remove_helper_ok) + (if (imported_remove_range_helper_ok) + (imported_real_program_helpers_ok) + false) + false) + false) + false) + false) false) false) false) @@ -247,6 +343,21 @@ (test "explicit local vec_i64 option query helpers" (imported_option_query_helpers_ok)) +(test "explicit local vec_i64 count_of helper" + (imported_count_of_helper_ok)) + +(test "explicit local vec_i64 starts_with helper" + (imported_starts_with_helper_ok)) + +(test "explicit local vec_i64 ends_with helper" + (imported_ends_with_helper_ok)) + +(test "explicit local vec_i64 without_suffix helper" + (imported_without_suffix_helper_ok)) + +(test "explicit local vec_i64 without_prefix helper" + (imported_without_prefix_helper_ok)) + (test "explicit local vec_i64 transform helpers" (imported_transform_helpers_ok)) diff --git a/examples/projects/std-layout-local-vec_i64/src/vec_i64.slo b/examples/projects/std-layout-local-vec_i64/src/vec_i64.slo index 7feeece..83be285 100644 --- a/examples/projects/std-layout-local-vec_i64/src/vec_i64.slo +++ b/examples/projects/std-layout-local-vec_i64/src/vec_i64.slo @@ -1,4 +1,4 @@ -(module vec_i64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(module vec_i64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (type VecI64 (vec i64)) @@ -92,6 +92,16 @@ (fn contains ((values VecI64) (target i64)) -> bool (contains_loop values target 0 (len values))) +(fn count_of_loop ((values VecI64) (target i64) (position i32) (values_len i32) (hits i32)) -> i32 + (if (< position values_len) + (count_of_loop values target (+ position 1) values_len (+ hits (if (= (at values position) target) + 1 + 0))) + hits)) + +(fn count_of ((values VecI64) (target i64)) -> i32 + (count_of_loop values target 0 (len values) 0)) + (fn sum_loop ((values VecI64) (position i32) (values_len i32) (total i64)) -> i64 (if (< position values_len) (sum_loop values (+ position 1) values_len (+ total (at values position))) @@ -122,6 +132,29 @@ (take_loop values 0 count (empty)) values))) +(fn starts_with ((values VecI64) (prefix VecI64)) -> bool + (let prefix_len i32 (len prefix)) + (if (< (len values) prefix_len) + false + (= (take values prefix_len) prefix))) + +(fn without_prefix ((values VecI64) (prefix VecI64)) -> VecI64 + (if (starts_with values prefix) + (drop values (len prefix)) + values)) + +(fn ends_with ((values VecI64) (suffix VecI64)) -> bool + (let values_len i32 (len values)) + (let suffix_len i32 (len suffix)) + (if (< values_len suffix_len) + false + (= (drop values (- values_len suffix_len)) suffix))) + +(fn without_suffix ((values VecI64) (suffix VecI64)) -> VecI64 + (if (ends_with values suffix) + (take values (- (len values) (len suffix))) + values)) + (fn drop_loop ((values VecI64) (position i32) (values_len i32) (result VecI64)) -> VecI64 (if (< position values_len) (drop_loop values (+ position 1) values_len (append result (at values position))) diff --git a/lib/std/README.md b/lib/std/README.md index e100801..3bae2d6 100644 --- a/lib/std/README.md +++ b/lib/std/README.md @@ -29,9 +29,10 @@ updated through `exp-65`; env option helpers updated through `exp-110`; fs fallback helpers updated through `exp-63` and `exp-70`; fs typed read helpers updated through `exp-66`; fs option helpers updated through `exp-110`; num fallback helpers updated through `exp-64`; concrete vec helpers updated -through released `exp-108`, including the current concrete +through `1.0.0-beta.12`, including the current concrete `std/vec_string.slo`, `std/vec_f64.slo`, and `std/vec_bool.slo` -prefix/suffix helper scopes; `1.0.0-beta.6` networking foundation work releases +prefix/suffix helper scopes, `std/vec_i64.slo` query and prefix/suffix parity, +and `std/vec_f64.slo` query parity; `1.0.0-beta.6` networking foundation work releases `std/net.slo` as an experimental loopback TCP facade over matching compiler-known runtime calls; `1.0.0-beta.7` serialization work releases `std/json.slo` as an experimental JSON text-construction facade over @@ -139,8 +140,12 @@ family; exp-103 stages `std/vec_f64.slo` as a concrete source-authored `(vec f64)` baseline facade over the sibling `std.vec.f64` runtime family; exp-104 stages `std/vec_bool.slo` as a concrete source-authored `(vec bool)` baseline facade over the sibling `std.vec.bool` runtime family; -and exp-108 broadens all three non-i32 concrete collection lanes with one -connected prefix/suffix helper package. +exp-108 broadens all three non-i32 concrete collection lanes with one +connected prefix/suffix helper package; and `1.0.0-beta.12` fills concrete +vector source parity by adding `count_of`, `starts_with`, `without_prefix`, +`ends_with`, and `without_suffix` to `std/vec_i64.slo`, plus `count_of` to +`std/vec_f64.slo`, matching the existing concrete lane behavior for empty +prefixes/suffixes, mismatches, exact removals, and repeated exact counts. It does not make the standard library fully self-hosted, does not add automatic standard-library imports, and does not replace the compiler-known `std.*` @@ -148,8 +153,8 @@ standard-runtime calls cataloged in `../STANDARD_RUNTIME.md`. The current `.slo` files use flat module declarations such as `(module math)`. For exp-44, exp-45, exp-47, exp-48, exp-49, exp-52, exp-53, exp-76, exp-94, -exp-96, exp-97, exp-98, exp-99, exp-103, exp-104, exp-105, exp-107, and -exp-108, `std/math.slo`, `std/result.slo`, +exp-96, exp-97, exp-98, exp-99, exp-103, exp-104, exp-105, exp-107, exp-108, +and `1.0.0-beta.12`, `std/math.slo`, `std/result.slo`, `std/option.slo`, `std/time.slo`, `std/random.slo`, `std/env.slo`, `std/fs.slo`, `std/net.slo`, `std/json.slo`, `std/string.slo`, `std/num.slo`, `std/io.slo`, `std/process.slo`, `std/cli.slo`, `std/vec_i32.slo`, diff --git a/lib/std/vec_f64.slo b/lib/std/vec_f64.slo index 8e8f6ef..483eeb8 100644 --- a/lib/std/vec_f64.slo +++ b/lib/std/vec_f64.slo @@ -1,4 +1,4 @@ -(module vec_f64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(module vec_f64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (type VecF64 (vec f64)) @@ -92,6 +92,16 @@ (fn contains ((values VecF64) (target f64)) -> bool (contains_loop values target 0 (len values))) +(fn count_of_loop ((values VecF64) (target f64) (position i32) (values_len i32) (hits i32)) -> i32 + (if (< position values_len) + (count_of_loop values target (+ position 1) values_len (+ hits (if (= (at values position) target) + 1 + 0))) + hits)) + +(fn count_of ((values VecF64) (target f64)) -> i32 + (count_of_loop values target 0 (len values) 0)) + (fn sum_loop ((values VecF64) (position i32) (values_len i32) (total f64)) -> f64 (if (< position values_len) (sum_loop values (+ position 1) values_len (+ total (at values position))) diff --git a/lib/std/vec_i64.slo b/lib/std/vec_i64.slo index 7feeece..83be285 100644 --- a/lib/std/vec_i64.slo +++ b/lib/std/vec_i64.slo @@ -1,4 +1,4 @@ -(module vec_i64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains sum concat take drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) +(module vec_i64 (export empty append len at singleton append2 append3 pair triple is_empty index_or first_or last_or index_option first_option last_option index_of_option last_index_of_option contains count_of sum concat take starts_with without_prefix ends_with without_suffix drop reverse subvec insert_at insert_range replace_at replace_range remove_at remove_range)) (type VecI64 (vec i64)) @@ -92,6 +92,16 @@ (fn contains ((values VecI64) (target i64)) -> bool (contains_loop values target 0 (len values))) +(fn count_of_loop ((values VecI64) (target i64) (position i32) (values_len i32) (hits i32)) -> i32 + (if (< position values_len) + (count_of_loop values target (+ position 1) values_len (+ hits (if (= (at values position) target) + 1 + 0))) + hits)) + +(fn count_of ((values VecI64) (target i64)) -> i32 + (count_of_loop values target 0 (len values) 0)) + (fn sum_loop ((values VecI64) (position i32) (values_len i32) (total i64)) -> i64 (if (< position values_len) (sum_loop values (+ position 1) values_len (+ total (at values position))) @@ -122,6 +132,29 @@ (take_loop values 0 count (empty)) values))) +(fn starts_with ((values VecI64) (prefix VecI64)) -> bool + (let prefix_len i32 (len prefix)) + (if (< (len values) prefix_len) + false + (= (take values prefix_len) prefix))) + +(fn without_prefix ((values VecI64) (prefix VecI64)) -> VecI64 + (if (starts_with values prefix) + (drop values (len prefix)) + values)) + +(fn ends_with ((values VecI64) (suffix VecI64)) -> bool + (let values_len i32 (len values)) + (let suffix_len i32 (len suffix)) + (if (< values_len suffix_len) + false + (= (drop values (- values_len suffix_len)) suffix))) + +(fn without_suffix ((values VecI64) (suffix VecI64)) -> VecI64 + (if (ends_with values suffix) + (take values (- (len values) (len suffix))) + values)) + (fn drop_loop ((values VecI64) (position i32) (values_len i32) (result VecI64)) -> VecI64 (if (< position values_len) (drop_loop values (+ position 1) values_len (append result (at values position)))