h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
309 stars 23 forks source link

How to slice a string? And way how not to do that. #24

Closed Crutiatix closed 6 years ago

Crutiatix commented 6 years ago

I can't find any way how to slice string. There isn't any function in the str module for this purpose.

My idea was at first to split a string a char by char into strings in a quote and then get or slice it by functions from seq module however when I try to do so system gets stuck as if it gets into endless loop. The problem is propably that I wanted to split string by empty string:

"abcdefgh" "" split

How can I slice string by another way? (by which I don't have to insert delimiters between every char)

Thanks

h3rald commented 6 years ago

Mmmm yep, you are right:

If I get a chance this weekend I will fix the split method and also maybe implement a new substr operator for slicing strings.

I am thinking of something like:

"wonderful" 0 6 substr 

...which would output wonder.