September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,4 @@
' Empty string
a$ = ""
IF a$ = "" THEN PRINT "Empty string"
IF a$ != "" THEN PRINT "Non empty string"

View file

@ -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") ]
].

View 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

View file

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

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

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

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

View file

@ -0,0 +1,6 @@
scalar s=""
display s==""
* Alternatively, check the length
display length(s)==0

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

View file

@ -0,0 +1,3 @@
s:=""; // or s:=String, String is the object ""
s.toBool() //-->False
if (s) println("not empty")