Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
33
Task/String-comparison/F-Sharp/string-comparison.fs
Normal file
33
Task/String-comparison/F-Sharp/string-comparison.fs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
open System
|
||||
|
||||
// self defined operators for case insensitive comparison
|
||||
let (<~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) < 0
|
||||
let (<=~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) <= 0
|
||||
let (>~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) > 0
|
||||
let (>=~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) >= 0
|
||||
let (=~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) = 0
|
||||
let (<>~) a b = String.Compare(a, b, StringComparison.OrdinalIgnoreCase) <> 0
|
||||
|
||||
let compare a b = // standard operators:
|
||||
if a < b then printfn "%s is strictly less than %s" a b
|
||||
if a <= b then printfn "%s is less than or equal to %s" a b
|
||||
if a > b then printfn "%s is strictly greater than %s" a b
|
||||
if a >= b then printfn "%s is greater than or equal to %s" a b
|
||||
if a = b then printfn "%s is equal to %s" a b
|
||||
if a <> b then printfn "%s is not equal to %s" a b
|
||||
// and our case insensitive self defined operators:
|
||||
if a <~ b then printfn "%s is strictly less than %s (case insensitive)" a b
|
||||
if a <=~ b then printfn "%s is less than or equal to %s (case insensitive)" a b
|
||||
if a >~ b then printfn "%s is strictly greater than %s (case insensitive)" a b
|
||||
if a >=~ b then printfn "%s is greater than or equal to %s (case insensitive)" a b
|
||||
if a =~ b then printfn "%s is equal to %s (case insensitive)" a b
|
||||
if a <>~ b then printfn "%s is not equal to %s (case insensitive)" a b
|
||||
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
compare "YUP" "YUP"
|
||||
compare "BALL" "BELL"
|
||||
compare "24" "123"
|
||||
compare "BELL" "bELL"
|
||||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue