Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/String-comparison/Wren/string-comparison.wren
Normal file
28
Task/String-comparison/Wren/string-comparison.wren
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import "/str" for Str
|
||||
|
||||
var compareStrings = Fn.new { |a, b, sens|
|
||||
System.write("Comparing '%(a)' and '%(b)', ")
|
||||
var c
|
||||
var d
|
||||
if (sens) {
|
||||
System.print("case sensitively:")
|
||||
c = a
|
||||
d = b
|
||||
} else {
|
||||
System.print("case insensitively:")
|
||||
c = Str.lower(a)
|
||||
d = Str.lower(b)
|
||||
}
|
||||
System.print(" %(a) < %(b) -> %(Str.lt(c, d))")
|
||||
System.print(" %(a) > %(b) -> %(Str.gt(c, d))")
|
||||
System.print(" %(a) == %(b) -> %(c == d)")
|
||||
System.print(" %(a) != %(b) -> %(c != d)")
|
||||
System.print(" %(a) <= %(b) -> %(Str.le(c, d))")
|
||||
System.print(" %(a) >= %(b) -> %(Str.ge(c, d))")
|
||||
System.print()
|
||||
}
|
||||
|
||||
compareStrings.call("cat", "dog", true)
|
||||
compareStrings.call("Rat", "RAT", true)
|
||||
compareStrings.call("Rat", "RAT", false)
|
||||
compareStrings.call("1100", "200", true)
|
||||
Loading…
Add table
Add a link
Reference in a new issue