Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -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]]

View 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

View file

@ -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

View file

@ -0,0 +1,2 @@
var s = "";
var s = new String();

View file

@ -0,0 +1,4 @@
s == ""
s.length == 0
!s
!Boolean(s)

View file

@ -0,0 +1,4 @@
s != ""
s.length != 0
s.length > 0
Boolean(s)

View 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

View file

@ -0,0 +1,4 @@
assign_empty_string(Variable) :- Variable = "".
is_empty_string(String) :- String == "".
not_empty_string(String) :- String \== "".

View 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.

View 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 <> ""