More functions on strings #176

Closed
opened 2019-11-18 19:41:27 +09:00 by zxq9 · 11 comments
zxq9 commented 2019-11-18 19:41:27 +09:00 (Migrated from gitlab.com)

Created by: UlfNorell

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

*Created by: UlfNorell* 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
zxq9 commented 2019-11-18 19:51:00 +09:00 (Migrated from gitlab.com)

Created by: radrow

May be also useful:

Char.to_int : char -> int
Char.from_int : int -> option?(char) 
*Created by: radrow* May be also useful: ``` Char.to_int : char -> int Char.from_int : int -> option?(char) ```
zxq9 commented 2019-12-02 23:06:16 +09:00 (Migrated from gitlab.com)

Created by: hanssv

Maybe String.contains, etc.

*Created by: hanssv* Maybe `String.contains`, etc.
zxq9 commented 2019-12-04 18:39:45 +09:00 (Migrated from gitlab.com)

Created by: maptuhec

Also useful:

String.to_upper_case 
String.to_lower_case
*Created by: maptuhec* Also useful: ``` String.to_upper_case String.to_lower_case ```
zxq9 commented 2019-12-05 00:15:25 +09:00 (Migrated from gitlab.com)

Created by: maptuhec

String.to_bytes?

*Created by: maptuhec* `String.to_bytes`?
zxq9 commented 2019-12-05 00:28:48 +09:00 (Migrated from gitlab.com)

Created by: UlfNorell

String.to_bytes

What type would that have?

*Created by: UlfNorell* > `String.to_bytes` What type would that have?
zxq9 commented 2019-12-05 01:10:22 +09:00 (Migrated from gitlab.com)

Created by: maptuhec

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

*Created by: maptuhec* 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
zxq9 commented 2019-12-05 01:37:43 +09:00 (Migrated from gitlab.com)

Created by: UlfNorell

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.

*Created by: UlfNorell* 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.
zxq9 commented 2019-12-09 18:09:07 +09:00 (Migrated from gitlab.com)

Created by: tolbrino

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

*Created by: tolbrino* Something like `String.to_int(s : string) : int` would also be helpful.
zxq9 commented 2019-12-09 18:11:56 +09:00 (Migrated from gitlab.com)

Created by: tolbrino

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

*Created by: tolbrino* And `String.tokens(s : string, c : char) : list(string)` would split the string into tokens with the given character used as limiter.
zxq9 commented 2019-12-09 23:03:05 +09:00 (Migrated from gitlab.com)

Created by: radrow

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

*Created by: radrow* @tolbrino `String.to_int(s : string) : option(int)`, let's be safe
zxq9 commented 2019-12-10 02:19:30 +09:00 (Migrated from gitlab.com)

Created by: hanssv

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

*Created by: hanssv* Maybe even `String.to_int(s : string, base : int) : option(int)`?
Sign in to join this conversation.
No Milestone iris
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#176
No description provided.