Skip to content

Commit 918c3bc

Browse files
Marcos-catmagistau
andauthored
Implement parse subscripts (#786)
* implement base subscripts * add tests for parse subscripts * document parse subscripts * Add an extra test Co-authored-by: Tau <[email protected]> --------- Co-authored-by: Tau <[email protected]>
1 parent abe0178 commit 918c3bc

File tree

9 files changed

+368
-69
lines changed

9 files changed

+368
-69
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This version is not yet released. If you are reading this on the website, then t
1515
- **Breaking Change** - [`dip ⊙`](https://uiua.org/docs/dip) and [`on ⟜`](https://uiua.org/docs/on) function packs no longer apply their modifier to the leftmost function
1616
- This change makes most usecases of these function packs cleaner, as `A⊙(B|C)` changes to `⊙(A|B|C)` and likewise for [`on ⟜`](https://uiua.org/docs/on)
1717
- **Breaking Change** - The FFI function API has been changed considerably, read more in the documentation for [`&ffi`](https://uiua.org/docs/&ffi), [`&memcpy`](https://uiua.org/docs/&memcpy), and [`&memset`](https://uiua.org/docs/&memset)
18+
- [`parse ⋕`](https://uiua.org/docs/parse) can be subscripted to parse strings in different bases
1819
- Allow for private [modules](https://uiua.org/tutorial/modules#private-scoped-modules), [imports](https://uiua.org/tutorial/modules#private-imports), and [data definitions](https://uiua.org/tutorial/datadefs#visibility)
1920
- Add array pack syntactic sugar. This lets you write code like `[⊃(+|×)]` as `⊃[+|×]`.
2021
- Subscripts can now be typed with `,` instead of `__`s

parser/src/defs.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,14 @@ primitive!(
865865
/// ex: ⋕ {"5" "24" "106"}
866866
/// ex: ⋕ .↯3_4 "012"
867867
///
868+
/// [parse] can take a subscript to parse in a different base. Bases `1` through `36` are supported as well as [Base64](https://en.wikipedia.org/wiki/Base64).
869+
/// ex: ⋕₁₆"beef"
870+
/// ex: ⋕₂ "-101010"
871+
///
868872
/// [un][parse] will convert a scalar number into a string.
869873
/// ex: °⋕ 58
870874
/// ex: °⋕ 6.283185307179586
875+
/// ex: °⋕₁₆ 250.9375
871876
/// [un][parse] on a non-scalar number array will [box] each string.
872877
/// ex: °⋕ 1_2_3
873878
/// ex: °⋕ ↯3_4⇡12

site/src/other.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ pub fn Subscripts() -> impl IntoView {
565565
subscript(First, "First N values", "⊢₂ \"hello\""),
566566
subscript(Last, "Last N values", "⊣₂ \"hello\""),
567567
subscript(Bits, "Force N bits", "⋯₄ [1 2 3]"),
568+
subscript(Parse, "Parse in base N", "⋕₁₆ \"beef\""),
568569
subscript(Base, "Base N", "⊥₁₀ 123"),
569570
subscript(Keep, "Keep along N axes", "▽₂ 1.5 [1_2_3_4 5_6_7_8]"),
570571
subscript(Rand, "Random integer", "⚂₁₀₀"),

0 commit comments

Comments
 (0)