modularml / mojo

The Mojo Programming Language
https://docs.modular.com/mojo/manual/
Other
23.35k stars 2.6k forks source link

[Feature Request] Add `stol` function #2639

Open YichengDWu opened 6 months ago

YichengDWu commented 6 months ago

Review Mojo's priorities

What is your request?

atol is in the std but not stol, a similar function to strtol in C.

What is your motivation for this change?

More functionalities to parser strings.

Any other details?

No response

gxyd commented 6 months ago

Can I maybe try to work on this issue?

soraros commented 6 months ago

@gxyd You can just go ahead!

bgreni commented 6 months ago

Since atol in mojo already accepts an optional base argument why would we have need for a second function in this case?

YichengDWu commented 6 months ago

atol recognizes "1234" and stol regonizes "1234asda".

bgreni commented 6 months ago

Ah I see the distinction between the behaviours now thank you.