September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
14
Task/String-comparison/Astro/string-comparison.astro
Normal file
14
Task/String-comparison/Astro/string-comparison.astro
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
fun main(args): ## Array[Str]
|
||||
let a = "astro"
|
||||
let b = "astro"
|
||||
print
|
||||
..("Case sensitive comparisons:\n")
|
||||
..("astro and astro are equal = $(a == b)")
|
||||
..("astro and astro are not equal = $(a != b)")
|
||||
..("astro comes before astro = $(a < b)")
|
||||
..("astro comes after astro = $(a > b)")
|
||||
..("\nCase insensitive comparisons:\n")
|
||||
..("astro and astro are equal = $(a == b.lower())")
|
||||
..("astro and astro are not equal = $(a != b.lower())")
|
||||
..("astro comes before astro = $(a < b.lower())")
|
||||
..("astro comes after astro = $(a > b.lower())")
|
||||
|
|
@ -1,19 +1,20 @@
|
|||
#import system.
|
||||
#import extensions.
|
||||
import extensions.
|
||||
|
||||
#symbol compareStrings = (:val1 :val2)
|
||||
compareStrings = (:val1 :val2)
|
||||
[
|
||||
(val1 == val2)? [ console writeLine:"The strings ":val1:" and ":val2:" are equal". ].
|
||||
(val1 != val2)? [ console writeLine:"The strings ":val1:" and ":val2:" are not equal". ].
|
||||
(val1 > val2)? [ console writeLine:"The string ":val1:" is lexically after than ":val2. ].
|
||||
(val1 < val2)? [ console writeLine:"The string ":val1:" is lexically before than ":val2. ].
|
||||
(val1 >= val2)? [ console writeLine:"The string ":val1:" is not lexically before than ":val2. ].
|
||||
(val1 <= val2)? [ console writeLine:"The string ":val1:" is not lexically after than ":val2. ].
|
||||
if (val1 == val2) [ console printLine("The strings ",val1," and ",val2," are equal") ].
|
||||
if (val1 != val2) [ console printLine("The strings ",val1," and ",val2," are not equal") ].
|
||||
if (val1 > val2) [ console printLine("The string ",val1," is lexically after than ",val2) ].
|
||||
if (val1 < val2) [ console printLine("The string ",val1," is lexically before than ",val2) ].
|
||||
if (val1 >= val2) [ console printLine("The string ",val1," is not lexically before than ",val2) ].
|
||||
if (val1 <= val2) [ console printLine("The string ",val1," is not lexically after than ",val2) ].
|
||||
].
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
#var s1 := "this".
|
||||
#var s2 := "that".
|
||||
compareStrings :s1 :s2.
|
||||
var s1 := "this".
|
||||
var s2 := "that".
|
||||
compareStrings eval(s1,s2).
|
||||
|
||||
console readChar.
|
||||
].
|
||||
|
|
|
|||
2
Task/String-comparison/Fortran/string-comparison.f
Normal file
2
Task/String-comparison/Fortran/string-comparison.f
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
PRINT 42,N
|
||||
42 FORMAT (14HThe answer is ,I9)
|
||||
17
Task/String-comparison/Julia/string-comparison.julia
Normal file
17
Task/String-comparison/Julia/string-comparison.julia
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
function compare(a, b)
|
||||
println("\n$a is of type $(typeof(a)) and $b is of type $(typeof(b))")
|
||||
if a < b println("$a is strictly less than $b") end
|
||||
if a <= b println("$a is less than or equal to $b") end
|
||||
if a > b println("$a is strictly greater than $b") end
|
||||
if a >= b println("$a is greater than or equal to $b") end
|
||||
if a == b println("$a is equal to $b") end
|
||||
if a != b println("$a is not equal to $b") end
|
||||
if a === b println("$a has object identity with $b") end
|
||||
if a !== b println("$a has negated object identity with $b") end
|
||||
end
|
||||
|
||||
compare("YUP", "YUP")
|
||||
compare('a', 'z')
|
||||
compare("24", "123")
|
||||
compare(24, 123)
|
||||
compare(5.0, 5)
|
||||
16
Task/String-comparison/Kotlin/string-comparison.kotlin
Normal file
16
Task/String-comparison/Kotlin/string-comparison.kotlin
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val k1 = "kotlin"
|
||||
val k2 = "Kotlin"
|
||||
println("Case sensitive comparisons:\n")
|
||||
println("kotlin and Kotlin are equal = ${k1 == k2}")
|
||||
println("kotlin and Kotlin are not equal = ${k1 != k2}")
|
||||
println("kotlin comes before Kotlin = ${k1 < k2}")
|
||||
println("kotlin comes after Kotlin = ${k1 > k2}")
|
||||
println("\nCase insensitive comparisons:\n")
|
||||
println("kotlin and Kotlin are equal = ${k1 == k2.toLowerCase()}")
|
||||
println("kotlin and Kotlin are not equal = ${k1 != k2.toLowerCase()}")
|
||||
println("kotlin comes before Kotlin = ${k1 < k2.toLowerCase()}")
|
||||
println("kotlin comes after Kotlin = ${k1 > k2.toLowerCase()}")
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
import strutils
|
||||
|
||||
var s1: string = "The quick brown"
|
||||
var s2: string = "The Quick Brown"
|
||||
echo("== : ", s1 == s2)
|
||||
echo("!= : ", s1 != s2)
|
||||
echo("< : ", s1 < s2)
|
||||
echo("<= : ", s1 <= s2)
|
||||
echo("> : ", s1 > s2)
|
||||
echo(">= : ", s1 >= s2)
|
||||
5
Task/String-comparison/OoRexx/string-comparison.rexx
Normal file
5
Task/String-comparison/OoRexx/string-comparison.rexx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a=.array~of('A 1','B 2','a 3','b 3','A 5')
|
||||
a~sortwith(.caselesscomparator~new)
|
||||
Do i=1 To 5
|
||||
Say a[i]
|
||||
End
|
||||
18
Task/String-comparison/Zkl/string-comparison.zkl
Normal file
18
Task/String-comparison/Zkl/string-comparison.zkl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
"foo" == "foo" //True
|
||||
"foo" == "FOO" //False
|
||||
"foo" == "foobar" //False
|
||||
Op("==")("foo","foo") //True
|
||||
Op("==","foo")("foo") //True
|
||||
|
||||
"abc"<"cde" //True
|
||||
"abc">"cde" //False
|
||||
|
||||
"foo" == "FOO" //False
|
||||
"abc".toUpper()=="ABC" //True
|
||||
|
||||
123=="123" //False
|
||||
123=="123".toInt() //True
|
||||
|
||||
123<"123" //False, int on left forces "123".toInt()
|
||||
123<"1234" //True
|
||||
2345<"1234" //False
|
||||
Loading…
Add table
Add a link
Reference in a new issue