Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,4 +1,5 @@
|
|||
Languages may have features for dealing specifically with empty strings (those containing no characters).
|
||||
Languages may have features for dealing specifically with empty strings
|
||||
(those containing no characters).
|
||||
|
||||
The task is to:
|
||||
|
||||
|
|
@ -7,4 +8,4 @@ The task is to:
|
|||
* Demonstrate how to check that a string is empty.
|
||||
* Demonstrate how to check that a string is not empty.
|
||||
|
||||
[[Category:String manipulation]]
|
||||
[[Category:String manipulation]] [[Category:Simple]]
|
||||
|
|
|
|||
12
Task/Empty-string/Elixir/empty-string.elixir
Normal file
12
Task/Empty-string/Elixir/empty-string.elixir
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
empty_string = ""
|
||||
not_empty_string = "a"
|
||||
|
||||
empty_string == ""
|
||||
# => true
|
||||
String.length(empty_string) == 0
|
||||
# => true
|
||||
|
||||
not_empty_string == ""
|
||||
# => false
|
||||
String.length(not_empty_string) == 0
|
||||
# => false
|
||||
|
|
@ -1,8 +1,14 @@
|
|||
// assign empty string to a variable
|
||||
// define and initialize an empty string
|
||||
var s string
|
||||
s2 := ""
|
||||
|
||||
// assign an empty string to a variable
|
||||
s = ""
|
||||
|
||||
// check that string is empty
|
||||
// check that a string is empty, any of:
|
||||
s == ""
|
||||
len(s) == 0
|
||||
|
||||
// check that string is not empty
|
||||
s > ""
|
||||
// check that a string is not empty, any of:
|
||||
s != ""
|
||||
len(s) != 0 // or > 0
|
||||
|
|
|
|||
2
Task/Empty-string/JavaScript/empty-string-1.js
Normal file
2
Task/Empty-string/JavaScript/empty-string-1.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var s = "";
|
||||
var s = new String();
|
||||
4
Task/Empty-string/JavaScript/empty-string-2.js
Normal file
4
Task/Empty-string/JavaScript/empty-string-2.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
s == ""
|
||||
s.length == 0
|
||||
!s
|
||||
!Boolean(s)
|
||||
4
Task/Empty-string/JavaScript/empty-string-3.js
Normal file
4
Task/Empty-string/JavaScript/empty-string-3.js
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
s != ""
|
||||
s.length != 0
|
||||
s.length > 0
|
||||
Boolean(s)
|
||||
3
Task/Empty-string/Maple/empty-string.maple
Normal file
3
Task/Empty-string/Maple/empty-string.maple
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s := ""; # Create an empty string
|
||||
evalb(s = ""); # test if the string is empty
|
||||
evalb(s <> ""); # test if the string is not empty
|
||||
4
Task/Empty-string/Prolog/empty-string.pro
Normal file
4
Task/Empty-string/Prolog/empty-string.pro
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
assign_empty_string(Variable) :- Variable = "".
|
||||
|
||||
is_empty_string(String) :- String == "".
|
||||
not_empty_string(String) :- String \== "".
|
||||
8
Task/Empty-string/Smalltalk/empty-string.st
Normal file
8
Task/Empty-string/Smalltalk/empty-string.st
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
"Assign empty string to a variable"
|
||||
str := ''.
|
||||
|
||||
"Check that string is empty"
|
||||
str isEmpty.
|
||||
|
||||
"Check that string is not empty"
|
||||
str isEmpty not.
|
||||
6
Task/Empty-string/Standard-ML/empty-string.ml
Normal file
6
Task/Empty-string/Standard-ML/empty-string.ml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(* Assign empty string to a variable *)
|
||||
val s = ""
|
||||
(* Check that a string is empty*)
|
||||
s = ""
|
||||
(* Check that a string is nonempty *)
|
||||
s <> ""
|
||||
Loading…
Add table
Add a link
Reference in a new issue