Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
15
Task/Empty-string/Ada/empty-string.adb
Normal file
15
Task/Empty-string/Ada/empty-string.adb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
procedure Empty_String is
|
||||
|
||||
function Is_Empty(S: String) return Boolean is
|
||||
begin
|
||||
return S = ""; -- test that S is empty
|
||||
end Is_Empty;
|
||||
|
||||
Empty: String := ""; -- Assign empty string
|
||||
XXXXX: String := "Not Empty";
|
||||
|
||||
begin
|
||||
if (not Is_Empty(Empty)) or Is_Empty(XXXXX) then
|
||||
raise Program_Error with "something went wrong very very badly!!!";
|
||||
end if;
|
||||
end Empty_String;
|
||||
16
Task/Empty-string/Bait/empty-string.bait
Normal file
16
Task/Empty-string/Bait/empty-string.bait
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
fun main() {
|
||||
mut e := "" // Declare empty string
|
||||
e = "" // Assign empty string
|
||||
|
||||
// Use either condition to check if the string is empty
|
||||
if e == "" and e.length == 0 {
|
||||
println("`e` is an empty string")
|
||||
}
|
||||
|
||||
s := "not empty"
|
||||
|
||||
// Use either condition to check if the string is _not_ empty
|
||||
if s != "" and s.length > 0 {
|
||||
println("`s` is not an empty string")
|
||||
}
|
||||
}
|
||||
|
|
@ -8,5 +8,7 @@ public function main() {
|
|||
string s = "";
|
||||
string t = "0";
|
||||
io:println("'s' is empty? ", isEmpty(s));
|
||||
io:println("'s' is not empty? ", !isEmpty(s));
|
||||
io:println("'t' is empty? ", isEmpty(t));
|
||||
io:println("'t' is not empty? ", !isEmpty(t));
|
||||
}
|
||||
|
|
|
|||
23
Task/Empty-string/COBOL/empty-string.cob
Normal file
23
Task/Empty-string/COBOL/empty-string.cob
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. EMPTYSTR.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 str PIC X(10).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
Begin.
|
||||
|
||||
* * Assign an empty string.
|
||||
INITIALIZE str.
|
||||
|
||||
* * Or
|
||||
MOVE " " TO str.
|
||||
|
||||
IF (str = " ")
|
||||
DISPLAY "String is empty"
|
||||
ELSE
|
||||
DISPLAY "String is not empty"
|
||||
END-IF.
|
||||
|
||||
STOP RUN.
|
||||
6
Task/Empty-string/Emacs-Lisp/empty-string-1.el
Normal file
6
Task/Empty-string/Emacs-Lisp/empty-string-1.el
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
(setq str "") ;; empty string literal
|
||||
|
||||
(if (= 0 (length str))
|
||||
(message "string is empty"))
|
||||
(if (/= 0 (length str))
|
||||
(message "string is not empty"))
|
||||
5
Task/Empty-string/Emacs-Lisp/empty-string-2.el
Normal file
5
Task/Empty-string/Emacs-Lisp/empty-string-2.el
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(defvar str "" "An empty string")
|
||||
|
||||
(if (length= str 0)
|
||||
(message "string is empty")
|
||||
(message "string is not empty"))
|
||||
15
Task/Empty-string/Euphoria/empty-string.eu
Normal file
15
Task/Empty-string/Euphoria/empty-string.eu
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
sequence s
|
||||
|
||||
-- assign an empty string
|
||||
s = ""
|
||||
|
||||
-- another way to assign an empty string
|
||||
s = {} -- "" and {} are equivalent
|
||||
|
||||
if not length(s) then
|
||||
-- string is empty
|
||||
end if
|
||||
|
||||
if length(s) then
|
||||
-- string is not empty
|
||||
end if
|
||||
8
Task/Empty-string/Gleam/empty-string.gleam
Normal file
8
Task/Empty-string/Gleam/empty-string.gleam
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import gleam/io
|
||||
import gleam/string
|
||||
|
||||
pub fn main() {
|
||||
// "" is an UTF8 encoded empty string in Gleam.
|
||||
io.println("")
|
||||
assert string.length("") == 0
|
||||
}
|
||||
19
Task/Empty-string/OPL/empty-string.opl
Normal file
19
Task/Empty-string/OPL/empty-string.opl
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
REM String variables are initially empty after declaring them.
|
||||
|
||||
PROC main:
|
||||
LOCAL s$(10)
|
||||
checkstr:(s$)
|
||||
s$="not empty."
|
||||
checkstr:(s$)
|
||||
s$=""
|
||||
checkstr:(s$)
|
||||
GET
|
||||
ENDP
|
||||
|
||||
PROC checkstr:(s$)
|
||||
IF s$=""
|
||||
PRINT "String is empty."
|
||||
ELSE
|
||||
PRINT "String is",s$
|
||||
ENDIF
|
||||
ENDP
|
||||
4
Task/Empty-string/PowerShell/empty-string-1.ps1
Normal file
4
Task/Empty-string/PowerShell/empty-string-1.ps1
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[string]$alpha = "abcdefghijklmnopqrstuvwxyz"
|
||||
[string]$empty = ""
|
||||
# or...
|
||||
[string]$empty = [String]::Empty
|
||||
2
Task/Empty-string/PowerShell/empty-string-2.ps1
Normal file
2
Task/Empty-string/PowerShell/empty-string-2.ps1
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[String]::IsNullOrEmpty($alpha)
|
||||
[String]::IsNullOrEmpty($empty)
|
||||
14
Task/Empty-string/Rebol/empty-string.rebol
Normal file
14
Task/Empty-string/Rebol/empty-string.rebol
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
test: func [str [string!]][
|
||||
;; Print a simple report about the string: its literal form, whether it's empty, and the word "empty"
|
||||
print [
|
||||
mold str ;; mold: show the string as a literal (quotes visible)
|
||||
pick ["is" "isn't"] empty? str ;; choose "is" if empty, otherwise "isn't"
|
||||
"empty" ;; trailing label for readability
|
||||
]
|
||||
]
|
||||
|
||||
test str: copy "" ;; create a new empty string and test it
|
||||
append str "abc" ;; add content to the string
|
||||
test str ;; test the non-empty string
|
||||
clear str ;; remove all content, making it empty again
|
||||
test str ;; test the re-emptied string
|
||||
6
Task/Empty-string/Rye/empty-string.rye
Normal file
6
Task/Empty-string/Rye/empty-string.rye
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
str: ""
|
||||
str .is-empty
|
||||
[Boolean: true]
|
||||
str2: "hello"
|
||||
str2 .is-empty
|
||||
[Boolean: false]
|
||||
3
Task/Empty-string/Uiua/empty-string.uiua
Normal file
3
Task/Empty-string/Uiua/empty-string.uiua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
S ← "abc"
|
||||
⍥(&p"S is empty.") =0⧻ S
|
||||
⍥(&p"S is not empty.") ≠0⧻ S
|
||||
Loading…
Add table
Add a link
Reference in a new issue