diff --git a/src/algorithm/monadic/mod.rs b/src/algorithm/monadic/mod.rs index b0b6688c6..fd61dc07d 100644 --- a/src/algorithm/monadic/mod.rs +++ b/src/algorithm/monadic/mod.rs @@ -396,6 +396,18 @@ impl Value { return Ok(num.into()); } + if base == 10 { + // Happy path for base 10 + if s.chars() + .all(|c| c.is_ascii_digit() || c == '-' || c == '.') + { + if let Ok(num) = s.parse::() { + return Ok(num.into()); + } + } + // Fall through + } + let sign = if let Some(pos) = s.strip_prefix("-") { s = pos; -1.0 diff --git a/tests/monadic.ua b/tests/monadic.ua index 998e9cf70..a34d22df3 100644 --- a/tests/monadic.ua +++ b/tests/monadic.ua @@ -95,6 +95,7 @@ ⍤⤙≍ [255 2748 16 ∞] ⬚∞⋕₁₆{"ff" "ABC" "10" "Z"} ⍤⤙≍ "Many hands make light work." ⇌°utf₈°⋯↯∞_8⋯≡⋕₆₄⇌ "TWFueSBoYW5kcyBtYWtlIGxpZ2h0IHdvcmsu" ⍤⤙≍ τ ⋕₆ "10.1411001432342522145" +⍤⤙≍ ¯1 ⍣(⋕₁₀|¯1) "inf" ⍤⤙≍ "a3" °⋕₁₂ 123 ⍤⤙≍ "ff00ff" ♭⬚@0°⋕₁₆ ×255 Magenta ⍤⤙≍ τ_(√10)_6 ⋕₃°⋕₃ τ_(√10)_6