A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
5
Task/Empty-string/Fantom/empty-string.fantom
Normal file
5
Task/Empty-string/Fantom/empty-string.fantom
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a := "" // assign an empty string to 'a'
|
||||
a.isEmpty // method on sys::Str to check if string is empty
|
||||
a.size == 0 // what isEmpty actually checks
|
||||
a == "" // alternate check for an empty string
|
||||
!a.isEmpty // check that a string is not empty
|
||||
5
Task/Empty-string/Groovy/empty-string.groovy
Normal file
5
Task/Empty-string/Groovy/empty-string.groovy
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def s = '' // or "" if you wish
|
||||
assert s.empty
|
||||
|
||||
s = '1 is the loneliest number'
|
||||
assert !s.empty
|
||||
16
Task/Empty-string/Icon/empty-string.icon
Normal file
16
Task/Empty-string/Icon/empty-string.icon
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
s := "" # null string
|
||||
s := string('A'--'A') # ... converted from cset difference
|
||||
s := char(0)[0:0] # ... by slicing
|
||||
|
||||
s1 == "" # lexical comparison, could convert s1 to string
|
||||
s1 === "" # comparison won't force conversion
|
||||
*s1 = 0 # zero length, however, *x is polymorphic
|
||||
*string(s1) = 0 # zero length string
|
||||
|
||||
s1 ~== "" # non null strings comparisons
|
||||
s1 ~=== ""
|
||||
*string(s1) ~= 0
|
||||
|
||||
s := &null # NOT a null string, null type
|
||||
/s # test for null type
|
||||
\s # test for non-null type
|
||||
5
Task/Empty-string/J/empty-string.j
Normal file
5
Task/Empty-string/J/empty-string.j
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
variable=: ''
|
||||
0=#variable
|
||||
1
|
||||
0<#variable
|
||||
0
|
||||
5
Task/Empty-string/K/empty-string.k
Normal file
5
Task/Empty-string/K/empty-string.k
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
variable: ""
|
||||
0=#variable
|
||||
1
|
||||
0<#variable
|
||||
0
|
||||
9
Task/Empty-string/LOLCODE/empty-string.lol
Normal file
9
Task/Empty-string/LOLCODE/empty-string.lol
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
HAI 1.3
|
||||
|
||||
I HAS A string ITZ ""
|
||||
string, O RLY?
|
||||
YA RLY, VISIBLE "STRING HAZ CONTENZ"
|
||||
NO WAI, VISIBLE "Y U NO HAS CHARZ?!"
|
||||
OIC
|
||||
|
||||
KTHXBYE
|
||||
3
Task/Empty-string/Lhogho/empty-string.lhogho
Normal file
3
Task/Empty-string/Lhogho/empty-string.lhogho
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
make "str " ;make null-string word
|
||||
print empty? :str ;prints 'true'
|
||||
print not empty? :str ;prints 'false'
|
||||
8
Task/Empty-string/Liberty-BASIC/empty-string.liberty
Normal file
8
Task/Empty-string/Liberty-BASIC/empty-string.liberty
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
'assign empty string to variable
|
||||
a$ = ""
|
||||
'check for empty string
|
||||
if a$="" then print "Empty string."
|
||||
if len(a$)=0 then print "Empty string."
|
||||
'check for non-empty string
|
||||
if a$<>"" then print "Not empty."
|
||||
if len(a$)>0 then print "Not empty."
|
||||
3
Task/Empty-string/Mathematica/empty-string.mathematica
Normal file
3
Task/Empty-string/Mathematica/empty-string.mathematica
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
str=""; (*Create*)
|
||||
str==="" (*test empty*)
|
||||
str=!="" (*test not empty*)
|
||||
9
Task/Empty-string/Maxima/empty-string.maxima
Normal file
9
Task/Empty-string/Maxima/empty-string.maxima
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
s: ""$
|
||||
|
||||
/* check using string contents */
|
||||
sequal(s, "");
|
||||
not sequal(s, "");
|
||||
|
||||
/* check using string length */
|
||||
slength(s) = "";
|
||||
slength(s) # "";
|
||||
6
Task/Empty-string/Mirah/empty-string.mirah
Normal file
6
Task/Empty-string/Mirah/empty-string.mirah
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
empty_string1 = ""
|
||||
empty_string2 = String.new
|
||||
|
||||
puts "empty string is empty" if empty_string1.isEmpty()
|
||||
puts "empty string has no length" if empty_string2.length() == 0
|
||||
puts "empty string is not nil" unless empty_string1 == nil
|
||||
Loading…
Add table
Add a link
Reference in a new issue