Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
34
Task/Odd-word-problem/F-Sharp/odd-word-problem.fs
Normal file
34
Task/Odd-word-problem/F-Sharp/odd-word-problem.fs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
open System
|
||||
open System.Text.RegularExpressions
|
||||
|
||||
let mutable Inp = Console.In
|
||||
|
||||
let Out c = printf "%c" c; (if c = '.' then Environment.Exit 0)
|
||||
|
||||
let In() = Inp.Read() |> Convert.ToChar
|
||||
|
||||
let (|WordCharacter|OtherCharacter|) c =
|
||||
if Regex.IsMatch(c.ToString(),"[a-zA-Z]") then
|
||||
WordCharacter
|
||||
else
|
||||
OtherCharacter
|
||||
|
||||
let rec forward () =
|
||||
let c = In()
|
||||
let rec backward () : char =
|
||||
let c = In()
|
||||
match c with
|
||||
| WordCharacter ->
|
||||
let s = backward() in Out c; s
|
||||
| OtherCharacter -> c
|
||||
Out c
|
||||
match c with
|
||||
| WordCharacter -> forward()
|
||||
| OtherCharacter -> backward()
|
||||
|
||||
[<EntryPoint>]
|
||||
let main argv =
|
||||
if argv.Length > 0 then Inp <- new System.IO.StringReader(argv.[0])
|
||||
let rec loop () = forward() |> Out; loop()
|
||||
loop()
|
||||
0
|
||||
Loading…
Add table
Add a link
Reference in a new issue