September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
4
Task/Empty-string/BASIC/empty-string-3.basic
Normal file
4
Task/Empty-string/BASIC/empty-string-3.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
' Empty string
|
||||
a$ = ""
|
||||
IF a$ = "" THEN PRINT "Empty string"
|
||||
IF a$ != "" THEN PRINT "Non empty string"
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
#import system.
|
||||
#import extensions.
|
||||
import extensions.
|
||||
|
||||
#symbol program = [
|
||||
#var s := emptyLiteralValue.
|
||||
program = [
|
||||
var s := emptyLiteralValue.
|
||||
|
||||
(s is &empty)
|
||||
? [ console writeLine:"'":s:"' is empty". ].
|
||||
if (s isEmpty)
|
||||
[ console printLine("'", s, "' is empty") ].
|
||||
|
||||
(s is &nonempty)
|
||||
? [ console writeLine:"'":s:"' is not empty". ].
|
||||
if (s isNonempty)
|
||||
[ console printLine("'", s, "' is not empty") ]
|
||||
].
|
||||
|
|
|
|||
15
Task/Empty-string/Gambas/empty-string.gambas
Normal file
15
Task/Empty-string/Gambas/empty-string.gambas
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
Public Sub Main()
|
||||
Dim sString As String[] = ["", "Hello", "world", "", "Today", "Tomorrow", "", "", "End!"]
|
||||
Dim sTemp As String
|
||||
Dim siCount As Short
|
||||
|
||||
For Each sTemp In sString
|
||||
If sString[siCount] Then
|
||||
Print "String " & siCount & " = " & sString[siCount]
|
||||
Else
|
||||
Print "String " & siCount & " is empty"
|
||||
End If
|
||||
Inc siCount
|
||||
Next
|
||||
|
||||
End
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
val s = ""
|
||||
println(s.isEmpty()) // true
|
||||
println(s.isNotEmpty()) // false
|
||||
println(s.length) // 0
|
||||
println(s.none()) // true
|
||||
println(s.any()) // false
|
||||
fun main(args: Array<String>) {
|
||||
val s = ""
|
||||
println(s.isEmpty()) // true
|
||||
println(s.isNotEmpty()) // false
|
||||
println(s.length) // 0
|
||||
println(s.none()) // true
|
||||
println(s.any()) // false
|
||||
}
|
||||
|
|
|
|||
14
Task/Empty-string/Oberon-2/empty-string.oberon-2
Normal file
14
Task/Empty-string/Oberon-2/empty-string.oberon-2
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
MODULE EmptyString;
|
||||
IMPORT Out;
|
||||
VAR
|
||||
str: ARRAY 64 OF CHAR;
|
||||
BEGIN
|
||||
str := "";
|
||||
Out.String("for str := ");Out.Char('"');Out.Char('"');Out.Char(';');Out.Ln;
|
||||
Out.String("checking str = ");Out.Char('"');Out.Char('"');Out.String(" Is Empty? ");Out.Bool(str = "");Out.Ln;
|
||||
Out.String("checking str[0] = 0X. Is Empty? ");Out.Bool(str[0] = 0X);Out.Ln;
|
||||
str := "Hello Rossetta";
|
||||
Out.String("for str :=");Out.Char('"');Out.String(str);Out.Char('"');Out.Char(";");Out.Ln;
|
||||
Out.String("checking str = ");Out.Char('"');Out.String(str);Out.Char('"');Out.String(" Is Empty? ");Out.Bool(str = "");Out.Ln;
|
||||
Out.String("checking str[0] = 0X. Is Empty? ");Out.Bool(str[0] = 0X);Out.Ln;
|
||||
END EmptyString.
|
||||
17
Task/Empty-string/Ol/empty-string.ol
Normal file
17
Task/Empty-string/Ol/empty-string.ol
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
; define the empty string
|
||||
(define empty-string "")
|
||||
|
||||
; three simplest tests for 'the-string emptiness
|
||||
(if (or
|
||||
(string-eq? the-string "")
|
||||
(string=? the-string "")
|
||||
(eq? (string-length the-string) 0))
|
||||
(print "the-string is empty")
|
||||
|
||||
; four simplest tests for 'the-string not emptiness
|
||||
(if (or
|
||||
(not (string-eq? the-string ""))
|
||||
(not (string=? the-string ""))
|
||||
(not (eq? (string-length the-string) 0))
|
||||
(less? 0 (string-length the-string)))
|
||||
(print "the-string is NOT empty))
|
||||
5
Task/Empty-string/OoRexx/empty-string.rexx
Normal file
5
Task/Empty-string/OoRexx/empty-string.rexx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
v=''
|
||||
w=' '
|
||||
if v=='' Then Say 'v contains the empty string'<
|
||||
If length(w)>0 Then Say 'Variable w does not contain the empty string'
|
||||
If w='' Then Say 'this is not a good test'
|
||||
6
Task/Empty-string/Stata/empty-string.stata
Normal file
6
Task/Empty-string/Stata/empty-string.stata
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
scalar s=""
|
||||
|
||||
display s==""
|
||||
|
||||
* Alternatively, check the length
|
||||
display length(s)==0
|
||||
9
Task/Empty-string/XLISP/empty-string.xlisp
Normal file
9
Task/Empty-string/XLISP/empty-string.xlisp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[1] (define my-empty-string "") ;; assign an empty string to a variable
|
||||
|
||||
MY-EMPTY-STRING
|
||||
[2] (string-null? my-empty-string)
|
||||
|
||||
#T
|
||||
[3] (string-null? "A non-empty string")
|
||||
|
||||
()
|
||||
3
Task/Empty-string/Zkl/empty-string.zkl
Normal file
3
Task/Empty-string/Zkl/empty-string.zkl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s:=""; // or s:=String, String is the object ""
|
||||
s.toBool() //-->False
|
||||
if (s) println("not empty")
|
||||
Loading…
Add table
Add a link
Reference in a new issue