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

Useful functions missing in the String module? #94

Closed
eriksvedang opened this issue Nov 14, 2017 · 15 comments
Closed

Useful functions missing in the String module? #94

eriksvedang opened this issue Nov 14, 2017 · 15 comments

Comments

@eriksvedang
Copy link
Collaborator

The String module is probably lacking a lot of useful functions commonly found in other standard libraries. Let's add them!

@hellerve
Copy link
Member

I have a list of useful functions (this is a verbatim copy of what’s present in zepto):

  • (String.join strs delim): joins a list of strings with a delimiter
  • (String.split str delim): splits a string on a delimiter, returns a list of substrings
  • (String.in? str sub): checks whether a substring is within a string
  • (String.count str c): counts the number of occurrences of character c in a string
  • (String.starts-with? str sub): checks whether a string starts with a substring
  • (String.ends-with? str sub): checks whether a string ends with a substring
  • (String.trim str): trims whitespace from a string
  • (String.upper? str): checks whether string is upper case
  • (String.lower? str): checks whether string is lower case
  • (String.num? str): checks whether string is numerical
  • (String.alpha? str): checks whether string is alphabetical
  • (String.alphanum? str): checks whether string is alphanumerical

There are more useful functions, but that’s a whole lot and a good start, I’d say.

Cheers

@eriksvedang
Copy link
Collaborator Author

Great, yes this looks like a very decent start indeed.

@Kungsgeten
Copy link

Maybe s.el (the long lost Emacs string manipulation library) can be used as inspiration?

@hellerve
Copy link
Member

Looks good! It also reminds me that we still have to wrap a regex library!

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 28, 2017

  • string to int
  • int to string

@hellerve
Copy link
Member

Those are already provided as Int.str and Int.from-string! The floating point data types do not have from-string functions, but should probably have them...

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 28, 2017

Should have looked at the source

@hellerve
Copy link
Member

Don’t worry! We have to document the standard modules sooner or later, to make it a bit easier for people to know what’s there.

@eriksvedang
Copy link
Collaborator Author

I feel like this is OK to close now?

@hellerve
Copy link
Member

I haven’t ported everything from the long lost Emacs string library yet, nor do I intend to. SOme of the functions do not need to b included in the standard library, in my opinion.

That being said, I do think that a handful of functions from the library should be included, like truncate and split-up-to.

@eriksvedang
Copy link
Collaborator Author

OK, let us leave it open until then, then :)

chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
@chrisosaurus
Copy link
Contributor

I am going to do a little work on the Strings module, adding documentation, and adding some new functions which I think are important.

I will send a PR once I have a few commits ready.

chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 19, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
Adding memory leak tests to String.append and StringCopy.append

Issue carp-lang#94
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
chrisosaurus added a commit to chrisosaurus/Carp that referenced this issue May 20, 2018
@eriksvedang
Copy link
Collaborator Author

eriksvedang commented May 23, 2018

I guess the String module will never be completely done, so perhaps we can close this now? Or are there still some functions that we really need? If so – let's enumerate them so we know what to shoot for.

@chrisosaurus
Copy link
Contributor

@eriksvedang good point, I'm pretty happy with the current shape of String for now, I don't see anything huge missing, happy for this to be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants