Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More functions on strings #176

Closed
UlfNorell opened this issue Nov 18, 2019 · 11 comments · Fixed by aeternity/aeternity#3156 or #238
Closed

More functions on strings #176

UlfNorell opened this issue Nov 18, 2019 · 11 comments · Fixed by aeternity/aeternity#3156 or #238
Projects
Milestone

Comments

@UlfNorell
Copy link
Contributor

Some suggestions

  String.split(i : int, s : string) : string * string
  String.to_list(s : string) : list(char)
  String.from_list(cs : list(char)) : string
  String.at(s : string, i : int) : char

cc @thepiwo @radrow

@radrow
Copy link
Member

radrow commented Nov 18, 2019

May be also useful:

Char.to_int : char -> int
Char.from_int : int -> option?(char) 

@UlfNorell UlfNorell added the enhancement New feature or request label Nov 18, 2019
@UlfNorell UlfNorell added this to Backlog in Sophia via automation Nov 18, 2019
@UlfNorell UlfNorell added this to the iris milestone Nov 18, 2019
@hanssv
Copy link
Member

hanssv commented Dec 2, 2019

Maybe String.contains, etc.

@maptuhec
Copy link

maptuhec commented Dec 4, 2019

Also useful:

String.to_upper_case 
String.to_lower_case

@maptuhec
Copy link

maptuhec commented Dec 4, 2019

String.to_bytes?

@UlfNorell
Copy link
Contributor Author

String.to_bytes

What type would that have?

@maptuhec
Copy link

maptuhec commented Dec 4, 2019

This was a suggestion from @hanssv for the following issue. The ecrecover returns. bytes, and if you want to compare it to a string it will not be possible for now(Bytes.to_str returns uppercase String) if the string is not passed in uppercase. So probably the type should be bytes. Just an issue that we have run into today.

Best,
Martin

@UlfNorell
Copy link
Contributor Author

UlfNorell commented Dec 4, 2019

The problem is that bytes have fixed length and you don't know the length of the string at compile time.

There could be a Bytes.to_raw_string : bytes(n) => string (or some better name) though, that gives you the bytes as they are without hex-encoding.

I'm confused as to why you would have your address as an unencoded string though. It would contain lots of unprintable characters.

@tolbrino
Copy link
Contributor

tolbrino commented Dec 9, 2019

Something like String.to_int(s : string) : int would also be helpful.

@tolbrino
Copy link
Contributor

tolbrino commented Dec 9, 2019

And String.tokens(s : string, c : char) : list(string) would split the string into tokens with the given character used as limiter.

@radrow
Copy link
Member

radrow commented Dec 9, 2019

@tolbrino String.to_int(s : string) : option(int), let's be safe

@hanssv
Copy link
Member

hanssv commented Dec 9, 2019

Maybe even String.to_int(s : string, base : int) : option(int)?

hanssv added a commit that referenced this issue Feb 25, 2020
@hanssv hanssv moved this from Backlog to In Progress in Sophia Feb 25, 2020
@hanssv hanssv linked a pull request Feb 26, 2020 that will close this issue
Sophia automation moved this from In Progress to Done Feb 26, 2020
hanssv added a commit that referenced this issue Feb 26, 2020
Change Char.to_lower/upper into String.to_lower/upper
hanssv added a commit that referenced this issue Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Sophia
  
Done
5 participants