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

make character predicates (isspace etc) work for strings arguments too #4102

Merged
merged 1 commit into from
Aug 20, 2013

Conversation

stevengj
Copy link
Member

This adds the simple convenience that functions like isspace or isalpha can work for string arguments as well as for individual characters (returning true for a string if the predicate is true for all characters in the string).

…o (applying to each character in the string)
@StefanKarpinski
Copy link
Member

Seems reasonable to me although the fact that all predicates are true for "" seems potentially problematic. Perhaps they should only return true for non-empty strings where all the characters satisfy the predicate. It's easy enough to explicitly write isempty(s) || isdigit(s) if you actually wanted to allow the empty string.

@johnmyleswhite
Copy link
Member

+1

@stevengj
Copy link
Member Author

Is this string all of this character type? should be true for an empty string.

For example, I would tend to want isspace("") to be true, and returning true for the empty string is a nice, comprehensible semantic meaning if applied uniformly to all isfoo functions. It is also conceptually consistent with the general concept of an empty product of logical ands (as well as with our all function).

It is easy enough to write !isempty(s) && isdigit(s) if you want to exclude the empty string.

JeffBezanson added a commit that referenced this pull request Aug 20, 2013
make character predicates (isspace etc) work for strings arguments too
@JeffBezanson JeffBezanson merged commit 21a4b16 into JuliaLang:master Aug 20, 2013
KristofferC pushed a commit that referenced this pull request Dec 4, 2024
Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 7b759d7f0
New commit: d84a1a38b
Julia version: 1.12.0-DEV
Pkg version: 1.12.0
Bump invoked by: @KristofferC
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@7b759d7...d84a1a3

```
$ git log --oneline 7b759d7f0..d84a1a38b
d84a1a38b Allow use of a url and subdir in [sources] (#4039)
cd75456a8 Fix heading (#4102)
b61066120 rename FORMER_STDLIBS -> UPGRADABLE_STDLIBS (#4070)
814949ed2 Increase version of `StaticArrays` in `why` tests (#4077)
83e13631e Run CI on backport branch too (#4094)
```

Co-authored-by: Dilum Aluthge <[email protected]>
stevengj pushed a commit that referenced this pull request Jan 2, 2025
Stdlib: Pkg
URL: https://github.com/JuliaLang/Pkg.jl.git
Stdlib branch: master
Julia branch: master
Old commit: 7b759d7f0
New commit: d84a1a38b
Julia version: 1.12.0-DEV
Pkg version: 1.12.0
Bump invoked by: @KristofferC
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Pkg.jl@7b759d7...d84a1a3

```
$ git log --oneline 7b759d7f0..d84a1a38b
d84a1a38b Allow use of a url and subdir in [sources] (#4039)
cd75456a8 Fix heading (#4102)
b61066120 rename FORMER_STDLIBS -> UPGRADABLE_STDLIBS (#4070)
814949ed2 Increase version of `StaticArrays` in `why` tests (#4077)
83e13631e Run CI on backport branch too (#4094)
```

Co-authored-by: Dilum Aluthge <[email protected]>
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

Successfully merging this pull request may close these issues.

4 participants