Empty string: Difference between revisions
removed langur language example for now
m (Update Lang example: Fix spelling of Lang) |
Langurmonkey (talk | contribs) (removed langur language example for now) |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1,281:
Also possible is <code>(string= "" str)</code>.
An common lisp incompatible way:
(defvar str "" "An empty string")
(if (length= str 0)
(message "string is empty")
(message "string is not empty"))
<syntaxhighlight lang="emal">
# Demonstrate how to assign an empty string to a variable.
text sampleA = Text.EMPTY
text sampleB = "hello world"
text sampleC = ""
List samples = text[sampleA, sampleB, sampleC]
for each text sample in samples
# Demonstrate how to check that a string is empty.
writeLine("Is '" + sample + "' empty? " + when(sample.isEmpty(), "Yes", "No") + ".")
end
</syntaxhighlight>
{{out}}▼
Is '' empty? Yes.
Is 'hello world' empty? No.
Is '' empty? Yes.
=={{header|Erlang}}==
Line 1,863 ⟶ 1,891:
fn.println(parser.op(@$s > 0))
</syntaxhighlight>
▲=={{header|langur}}==
▲<syntaxhighlight lang="langur">val .zls = ""
▲writeln len(.zls)</syntaxhighlight>
▲{{out}}
▲<pre>true
▲0</pre>
=={{header|Lasso}}==
Line 2,157 ⟶ 2,173:
true
false
</pre>
=={{header|MiniScript}}==
{{trans|Wren}}
<syntaxhighlight lang="miniscript">string.isEmpty = function
return self == ""
end function
number.toBoolStr = function
if self == 0 then return "false"
return "true"
end function
s = ""
t = "0"
print "'s' is empty? " + s.isEmpty.toBoolStr
print "'t' is empty? " + t.isEmpty.toBoolStr</syntaxhighlight>
{{out}}
<pre>'s' is empty? true
't' is empty? false
</pre>
Line 3,449 ⟶ 3,486:
=={{header|Wren}}==
<syntaxhighlight lang="
var s = ""
|