File: comparer.fsx

package info (click to toggle)
fsharp 4.0.0.4%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 58,824 kB
  • ctags: 1,395
  • sloc: cs: 2,983; ml: 1,098; makefile: 410; sh: 409; xml: 113
file content (21 lines) | stat: -rw-r--r-- 591 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// #NoMT #CompilerOptions #RequiresENU #NETFX20Only #NETFX40Only 
let fn1 = fsi.CommandLineArgs.[1]
let fn2 = fsi.CommandLineArgs.[2]
let File2List(filename : string) = System.IO.File.ReadAllLines filename |> Array.toList
let f1 = File2List fn1
let f2 = File2List fn2
let mutable i = 0

let compare f1 f2 = 
    (f1,f2) ||> List.forall2 (fun a b -> 
        i <- i + 1
        if (a = b) then true
        else 
            printfn "Files differ at line %d:" i
            printfn "\t>> %s" a
            printfn "\t<< %s" b
            false) 

exit (if compare f1 f2 then 0
      else 1)