langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
2
Task/Empty-string/Nemerle/empty-string-1.nemerle
Normal file
2
Task/Empty-string/Nemerle/empty-string-1.nemerle
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
def empty = "";
|
||||
mutable fill_later = "";
|
||||
2
Task/Empty-string/Nemerle/empty-string-2.nemerle
Normal file
2
Task/Empty-string/Nemerle/empty-string-2.nemerle
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
a_string == ""; a_string != 0;
|
||||
a_string.Length == 0; a_string.Length > 0;
|
||||
21
Task/Empty-string/NetRexx/empty-string.netrexx
Normal file
21
Task/Empty-string/NetRexx/empty-string.netrexx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols binary
|
||||
|
||||
s1 = '' -- assignment
|
||||
s2 = "" -- equivalent to s1
|
||||
parse '.' . s3 . -- parsing a token that doesn't exist results in an empty string
|
||||
|
||||
strings = [s1, s2, s3, ' ']
|
||||
|
||||
loop s_ = 0 to strings.length - 1
|
||||
say (Rexx s_).right(3)':\-'
|
||||
select
|
||||
when strings[s_] == '' then say ' "'strings[s_]'" is really empty'
|
||||
when strings[s_].length = 0 then say ' "'strings[s_]'" is empty'
|
||||
when strings[s_] = '' then say ' "'strings[s_]'" looks empty but may not be'
|
||||
when strings[s_].length > 0 then say ' "'strings[s_]'" is not empty'
|
||||
otherwise nop
|
||||
end
|
||||
end s_
|
||||
|
||||
return
|
||||
9
Task/Empty-string/OCaml/empty-string.ocaml
Normal file
9
Task/Empty-string/OCaml/empty-string.ocaml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
let is_string_empty s =
|
||||
(s = "")
|
||||
|
||||
let () =
|
||||
let s1 = ""
|
||||
and s2 = "not empty" in
|
||||
Printf.printf "s1 empty? %B\n" (is_string_empty s1);
|
||||
Printf.printf "s2 empty? %B\n" (is_string_empty s2);
|
||||
;;
|
||||
6
Task/Empty-string/Objeck/empty-string.objeck
Normal file
6
Task/Empty-string/Objeck/empty-string.objeck
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
s := "";
|
||||
if(s->IsEmpty()) {
|
||||
"s is empty"->PrintLine();
|
||||
} else{
|
||||
"s is not empty"->PrintLine();
|
||||
};
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
DEFINE VARIABLE cc AS CHARACTER.
|
||||
|
||||
IF cc > '' THEN
|
||||
MESSAGE 'not empty' VIEW-AS ALERT-BOX.
|
||||
ELSE IF cc = ? THEN
|
||||
MESSAGE 'unknown' VIEW-AS ALERT-BOX.
|
||||
ELSE /* IF cc = '' */
|
||||
MESSAGE 'empty' VIEW-AS ALERT-BOX.
|
||||
5
Task/Empty-string/PARI-GP/empty-string.pari
Normal file
5
Task/Empty-string/PARI-GP/empty-string.pari
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a="";
|
||||
isEmpty(s)=s=="" \\ Alternately:
|
||||
isEmpty(s)=#s==0
|
||||
isNonempty(s)=s!="" \\ Alternatively:
|
||||
isNonempty(s)=#s
|
||||
3
Task/Empty-string/PL-I/empty-string.pli
Normal file
3
Task/Empty-string/PL-I/empty-string.pli
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
s = ''; /* assign an empty string to a variable. */
|
||||
if length(s) = 0 then ... /* To test whether a string is empty */
|
||||
if length(s) > 0 then ... /* to test for a non-empty string */
|
||||
3
Task/Empty-string/Perl-6/empty-string.pl6
Normal file
3
Task/Empty-string/Perl-6/empty-string.pl6
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
my $s = '';
|
||||
say 'String is empty' unless $s.chars;
|
||||
say 'String is not empty' if $s.chars;
|
||||
17
Task/Empty-string/PureBasic/empty-string.purebasic
Normal file
17
Task/Empty-string/PureBasic/empty-string.purebasic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Procedure.s isStringEmpty(a.s)
|
||||
If a
|
||||
ProcedureReturn "String is not empty, it contains '" + a + "'."
|
||||
Else
|
||||
ProcedureReturn "String is empty, or null."
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
Define a.s = ""
|
||||
Define b.s = "stuff"
|
||||
PrintN(isStringEmpty(a))
|
||||
PrintN(isStringEmpty(b))
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
3
Task/Empty-string/Rascal/empty-string-1.rascal
Normal file
3
Task/Empty-string/Rascal/empty-string-1.rascal
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
str s = "";
|
||||
if (s=="") print("string s is empty");
|
||||
if (s!="") print("string s is not empty");
|
||||
3
Task/Empty-string/Rascal/empty-string-2.rascal
Normal file
3
Task/Empty-string/Rascal/empty-string-2.rascal
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import String;
|
||||
if (isEmpty(s)) print("string s is empty");
|
||||
if (isEmpty(s)) print("string s is not empty");
|
||||
5
Task/Empty-string/Retro/empty-string-1.retro
Normal file
5
Task/Empty-string/Retro/empty-string-1.retro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
( by creating a variable )
|
||||
"" keepString variable: foo
|
||||
|
||||
( by setting an existing variable 'foo' )
|
||||
"" keepString !foo
|
||||
4
Task/Empty-string/Retro/empty-string-2.retro
Normal file
4
Task/Empty-string/Retro/empty-string-2.retro
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
: emtpy? ( $-f ) getLength 0 = ;
|
||||
|
||||
"" empty? putn
|
||||
"hello" empty? putn
|
||||
4
Task/Empty-string/Retro/empty-string-3.retro
Normal file
4
Task/Empty-string/Retro/empty-string-3.retro
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
: notEmpty? ( $-f ) getLength 0 > ;
|
||||
|
||||
"" notEmpty? putn
|
||||
"hello" notEmpty? putn
|
||||
11
Task/Empty-string/Run-BASIC/empty-string.run
Normal file
11
Task/Empty-string/Run-BASIC/empty-string.run
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
var$ = ""
|
||||
' --------------
|
||||
'empty string
|
||||
' -------------
|
||||
if var$="" then print "String is Empty"
|
||||
if len(var$)=0 then print "String is Empty"
|
||||
' -------------
|
||||
'not empty string
|
||||
' -------------
|
||||
if var$<>"" then print "String Not empty."
|
||||
if len(var$)>0 then print "String Not empty."
|
||||
8
Task/Empty-string/Seed7/empty-string.seed7
Normal file
8
Task/Empty-string/Seed7/empty-string.seed7
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
# assign empty string to a variable
|
||||
s := ""
|
||||
|
||||
# check that string is empty
|
||||
s = ""
|
||||
|
||||
# check that string is not empty
|
||||
s <> ""
|
||||
4
Task/Empty-string/TUSCRIPT/empty-string.tuscript
Normal file
4
Task/Empty-string/TUSCRIPT/empty-string.tuscript
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$$ MODE TUSCRIPT
|
||||
s=""
|
||||
IF (s=="") PRINT "s is an empty string"
|
||||
IF (s!="") PRINT "s is a non-empty string"
|
||||
1
Task/Empty-string/TXR/empty-string-1.txr
Normal file
1
Task/Empty-string/TXR/empty-string-1.txr
Normal file
|
|
@ -0,0 +1 @@
|
|||
@(bind a "")
|
||||
6
Task/Empty-string/TXR/empty-string-2.txr
Normal file
6
Task/Empty-string/TXR/empty-string-2.txr
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
@(do (defvar *a* "")
|
||||
(if (equal *a* "")
|
||||
(format t "empty string\n"))
|
||||
(set *a* "nonempty")
|
||||
(if (zerop (length *a*))
|
||||
(format t "guess what?\n")))
|
||||
13
Task/Empty-string/UNIX-Shell/empty-string.sh
Normal file
13
Task/Empty-string/UNIX-Shell/empty-string.sh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# assign an empty string to a variable
|
||||
s=""
|
||||
|
||||
# the "test" command can determine truth by examining the string itself
|
||||
if [ "$s" ]; then echo "not empty"; else echo "empty"; fi
|
||||
|
||||
# compare the string to the empty string
|
||||
if [ "$s" = "" ]; then echo "s is the empty string"; fi
|
||||
if [ "$s" != "" ]; then echo "s is not empty"; fi
|
||||
|
||||
# examine the length of the string
|
||||
if [ -z "$s" ]; then echo "the string has length zero: it is empty"; fi
|
||||
if [ -n "$s" ]; then echo "the string has length non-zero: it is not empty"; fi
|
||||
14
Task/Empty-string/VBA/empty-string.vba
Normal file
14
Task/Empty-string/VBA/empty-string.vba
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
dim s as string
|
||||
|
||||
' assign an empty string to a variable:
|
||||
s = ""
|
||||
|
||||
' test if a string is empty:
|
||||
if s = "" then Debug.Print "empty!"
|
||||
' or:
|
||||
if Len(s) = 0 then Debug.Print "still empty!"
|
||||
|
||||
'test if a string is not empty:
|
||||
if s <> "" then Debug.Print "not an empty string"
|
||||
'or:
|
||||
if Len(s) > 0 then Debug.Print "not empty."
|
||||
10
Task/Empty-string/XPL0/empty-string.xpl0
Normal file
10
Task/Empty-string/XPL0/empty-string.xpl0
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
code Text=12;
|
||||
string 0; \use zero-terminated convention, instead of MSb set
|
||||
char S;
|
||||
[S:= ""; \assign an empty string
|
||||
if S(0) = 0 then Text(0, "empty
|
||||
");
|
||||
S:= "Hello";
|
||||
if S(0) # 0 then Text(0, "not empty
|
||||
");
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue