September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View 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())")

View file

@ -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.
].

View file

@ -0,0 +1,2 @@
PRINT 42,N
42 FORMAT (14HThe answer is ,I9)

View 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)

View 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()}")
}

View file

@ -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)

View 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

View 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