Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
- Ada
- C
- C
- Clojure
- C++
- C#
- D
- D
- Dart
- Elixir
- Erlang
- Erlang
- Fortran
- Go
- Go
- Haskell
- JS
- Java
- Java
- Java
- Java
- Java
- Kotlin
- Kotlin
- Lisp
- Lua
- Obj-C
- PHP
- Pascal
- Perl
- Python
- Python
- Python
- Ruby
- Rust
- Rust
- Rust
- Scala
- Smalltalk
- VB
B := (for all Char of S => Char in '0' .. '9');
char b = 0;
int n = strlen(s);
for (int i = 0; i < n; i++) {
if (! (b = (s[i] >= '0' && s[i] <= '9')))
break;
}
bool b = true;
const int n = strlen(s);
for (int i = 0; i < n; ++i) {
if (!isdigit(s[i])) {
b = false;
break;
}
}
(def b (every? #(Character/isDigit %) s))
bool b = false;
if (! s.empty() && std::all_of(s.begin(), s.end(), [](char c){return std::isdigit(c);})) {
b = true;
}
s must be a std::string
bool b = s.All(char.IsDigit);
b = Regex.match?(~r{\A\d*\z}, s)
Str = "21334",
[Ch || Ch <- Str, Ch < $0 orelse Ch > $9] == [].
using list comprehension
{_,Rest} = string:to_integer(S),
B = Rest == "".
b = .true.
do i=1, len(s)
if (s(i:i) < '0' .or. s(i:i) > '9') then
b = .false.
exit
end if
end do
b := true
for _, c := range s {
if c < '0' || c > '9' {
b = false
break
}
}
c has type rune.
boolean b = s.matches("\\d+");
boolean b = s.matches("[0-9]+");
boolean b = s.chars()
.allMatch(Character::isDigit);
if (s.length() == 0) b = false;
"... If the stream is empty then true is returned and the predicate is not evaluated."
String d = "0123456789";
int i, n = s.length();
boolean b = n != 0;
for (i = 0; i < n; ++i)
if (d.indexOf(s.charAt(i)) == -1) {
b = false;
break;
}
(setf b (every #'digit-char-p s))
var
S: String;
C: Char;
B: Boolean;
for C in S do
begin
B := C in ['0'..'9'];
if not B then Break;
end;
try:
int(s)
b = true
except:
b = false
def onlyDigits(s: String) = s.forall(_.isDigit)
b := s allSatisfy: #isDigit
Dim x As String = "123456"
Dim b As Boolean = IsNumeric(x)