第18回オフラインリアルタイムどう書くの参考問題をF#で

問題は「[山折り谷折り](http://nabetani.sakura.ne.jp/hena/ord18mafovafo/)」
やってることはC#とあんまり変わらないけど、型をきっちりしてみたので余計に長くなっている。

```fsharp:Program.fs
type Paper = Front | Back
type Folding = Mountain | Volley
type Tree = Leaf of Paper | Node of Paper * Folding * Tree

let rec add f x y =
  match x with
  | Leaf p           -> Node (p, f, y)
  | Node (p, f', x') -> Node (p, f', add f x' y)

let fold p c =
    match (p, c) with
    | (Front, 'L') -> Node (Back, Volley, Leaf Front)
    | (Front, 'J') -> Node (Front, Volley, Leaf Back)
    | (Front, 'Z') -> Node (Front, Mountain, Node (Back, Volley, Leaf Front))
    | (Front, 'U') -> Node (Back, Volley, Node (Front, Volley, Leaf Back))
    | (Front, 'S') -> Node (Front, Volley, Node (Back, Mountain, Leaf Front))
    | (Back,  'L') -> Node (Back, Mountain, Leaf Front)
    | (Back,  'J') -> Node (Front, Mountain, Leaf Back)
    | (Back,  'Z') -> Node (Back, Mountain, Node (Front, Volley, Leaf Back))
    | (Back,  'U') -> Node (Front, Mountain, Node (Back, Mountain, Leaf Front))
    | (Back,  'S') -> Node (Back, Volley, Node (Front, Mountain, Leaf Back))
    | _            -> Leaf Front

let rec foldRec = function
    | Leaf p         -> fold p
    | Node (p, f, x) -> fun c -> add f (fold p c) (foldRec x c)

let rec openRec = function
    | Leaf _ -> []
    | Node (x, f, y) -> f :: openRec y

let solve (s: string) =
    s
    |> Seq.fold foldRec (Leaf Front)
    |> openRec
    |> List.map (function|Mountain->'m'|Volley->'V')
    |> List.toArray
    |> fun x -> new string(x)

(* for test *)

type TestResult = Success | Failure

let test target expected =
  let actual = solve target
  printfn "%A" (if expected = actual then Success else Failure)

[<EntryPoint>]
let main argv = 
    test "JZ" "mVVmV"
    test "J" "V"
    test "L" "V"
    test "Z" "mV"
    test "U" "VV"
    test "S" "Vm"
    test "JL" "VVm"
    test "JS" "VmVVm"
    test "JU" "VVVmm"
    test "LU" "mmVVV"
    test "SL" "VVmmV"
    test "SS" "VmVVmmVm"
    test "SU" "VVVmmmVV"
    test "SZ" "mVVmVmmV"
    test "UL" "mVVVm"
    test "UU" "mmVVVVmm"
    test "UZ" "mVVmVVmV"
    test "ZJ" "VmmVV"
    test "ZS" "VmmVmVVm"
    test "ZZ" "mVmmVVmV"
    test "JJJ" "VVmVVmm"
    test "JJZ" "mVVmVVmVmmV"
    test "JSJ" "VVmmVVmVVmm"
    test "JSS" "VmVVmmVmVVmVVmmVm"
    test "JUS" "VmVVmVVmVVmmVmmVm"
    test "JUU" "mmVVVVmmVVVmmmmVV"
    test "JUZ" "mVVmVVmVVmVmmVmmV"
    test "LJJ" "VmmVVVm"
    test "LLS" "VmmVmVVmVVm"
    test "LLU" "mmmVVVmmVVV"
    test "LLZ" "mVmmVVmVVmV"
    test "LSU" "mmVVVmmmVVVVmmmVV"
    test "LSZ" "mVVmVmmVVmVVmVmmV"
    test "LZL" "mmVVmVVmmVV"
    test "LZS" "VmmVmVVmVVmmVmVVm"
    test "LZU" "mmmVVVmmVVVmmmVVV"
    test "SJL" "VVmVVmmmVVm"
    test "SLU" "mmVVVVmmmVVmmmVVV"
    test "SLZ" "mVVmVVmVmmVmmVVmV"
    test "SSU" "VVVmmmVVVmmVVVmmmmVVVmmmVV"
    test "SUJ" "mVVVmVVmmmVmmVVVm"
    test "SUS" "VmVVmVVmVVmmVmmVmmVmVVmVVm"
    test "SZZ" "mVmmVVmVVmVmmVVmVmmVmmVVmV"
    test "UJJ" "VmmVVVmVVmm"
    test "ULU" "mmmVVVmmVVVVmmmVV"
    test "ULZ" "mVmmVVmVVmVVmVmmV"
    test "UUU" "VVmmmmVVVmmVVVVmmVVVmmmmVV"
    test "ZJU" "VVVmmmVVmmmVVVVmm"
    test "ZLS" "VmVVmmVmmVmVVmVVm"
    test "ZSJ" "VVmmVmmVVmmVVVmmV"
    test "ZUJ" "mVVVmmVmmmVVmVVVm"
    test "JJLJ" "mVVVmmVVmVVmmmV"
    test "JLJJ" "VmmVVVmVVmmmVVm"
    test "JLJL" "VmmVVVmVVmmmVVm"
    test "LJJL" "VVmmVmmVVVmVVmm"
    test "LLJJ" "VmmmVVmVVmmVVVm"
    test "SZUS" "VmVVmVVmmVmmVmmVmVVmVVmVVmVVmmVmmVmmVmVVmVVmVVmmVmmVmmVmVVmVVmmVmmVmmVmVVmVVmVVm"
    test "ULLS" "VmmVmmVmVVmVVmmVmVVmVVmVVmmVmmVmVVm"
    test "JJJJZJ" "VmmVVVmmVVmVVmmVVmmmVVmVVmmVVVmmVVmmVmmVVmmmVVmVVmmVVVmmVVmVVmmVVmmmVVmmVmmVVVmmVVmmVmmVVmmmVVm"
    test "JULLLJ" "mmVmmVVmmmVVmVVVmmVmmVVVmmVVmVVVmmVmmVVmmmVVmVVVmmVmmVVVmmVVmVVmmmVmmVVmmmVVmVVmmmVmmVVVmmVVmVV"
    test "LJJJUL" "mVVVmVVmmmVVmVVVmmVmmmVmmVVVmVVmmmVmmVVVmmVmmmVVmVVVmVVmmmVVmVVVmmVmmmVVmVVVmVVmmmVmmVVVmmVmmmV"
    test "LJSJJL" "VVmVVmmVVVmmVmmmVVmVVmmmVVmmVmmVVVmVVmmmVVmmVmmVVVmVVmmVVVmmVmmmVVmVVmmVVVmmVmmVVVmVVmmmVVmmVmm"
    test "LZLLLJ" "mmVmmVVmmmVVmVVmmmVmmVVVmmVVmVVVmmVmmVVmmmVVmVVVmmVmmVVVmmVVmVVmmmVmmVVmmmVVmVVVmmVmmVVVmmVVmVV"
    test "SJJJJL" "VVmVVmmVVVmmVmmVVVmVVmmmVVmmVmmVVVmVVmmVVVmmVmmmVVmVVmmmVVmmVmmmVVmVVmmVVVmmVmmVVVmVVmmmVVmmVmm"
    test "ZLJLJL" "VmmVVVmmVmmmVVmVVmmVVVmVVmmmVVmmVmmVVVmmVmmmVVmmVmmVVVmVVmmmVVmVVmmVVVmmVmmmVVmVVmmVVVmVVmmmVVm"
    0
```