Programming-Idioms

New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
with Ada.Strings.Fixed;
use Ada.Strings.Fixed;
Blank := Index_Non_Blank (Str) = 0;
(require '[clojure.string :refer [blank?]])
(blank? s)
IDENTIFICATION DIVISION.
PROGRAM-ID. blank string.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 BOOLEAN-BLANK     PIC X.
   88 BLANK          VALUE "T".
   88 NOT-BLANK      VALUE "F".
PROCEDURE DIVISION.
    IF s = ' '
       SET BLANK     TO TRUE
    ELSE
       SET NOT-BLANK TO TRUE
    END-IF 	 	
STOP RUN.
#include <algorithm>
#include <cctype>
#include <string>
bool blank = false;
if (s.empty() || std::all_of(s.begin(), s.end(), [](char c){return std::isspace(c);})) {
      blank = true;
}
System;
bool blank = string.IsNullOrWhiteSpace(s);
bool blank = string.IsNullOrWhiteSpace(s);
import std.algorithm;
import std.uni;
bool blank = s.all!isSpace;
final blank = s == null || s.trim() == '';
blank = s == nil || String.length(String.trim s) == 0
Blank = string:is_empty(string:trim(S)).
blank = s == ''
import "strings"
blank := strings.TrimSpace(s) == ""
import Data.Char (isSpace)
b = null (dropWhile isSpace s)
import Data.Char (isSpace)
blank :: Bool
blank = all isSpace s
const blank = s == null || s.trim() === ''
boolean blank = s.trim().isEmpty();
import org.apache.commons.lang.StringUtils;
boolean blank = StringUtils.isBlank(s);
val blank = s.isNullOrBlank()
(setf blank (not (find #\space s :test-not #'eql)))
blank = s ~= nil and s:match("%S") ~= nil
$blank = !trim($s);
$blank = (empty(trim($s));
blank := trim(s) = '';
$blank = !$s || $s=~/^\s*$/;
blank = s.strip() == ''
blank = s.strip.empty?
let blank = s.trim().is_empty();
val blank = s.trim().isEmpty()
Dim myString As String = "abcdefg"
If String.IsNullOrEmpty(myString) Then
    '''
End If