I wrote some code to solve this problem https://www.hackerrank.com/challenges/string-o-permute which basically states: take an even length string and swap all the even indexed characters. For example the string abcd should become badc. I'm looking for a general code review as I'm very new to F# and specifically I'd really like to get rid of the ignoredTupleValue variable, it seems like a kludge to me. I'd also like to collapse the whole thing into one function but I was running into scoping issues with the StringBuilder.open Systemopen System.Text[<EntryPoint>]let main argv =    let numCases = Console.ReadLine() |> int    for i = numCases downto 1 do        let strIn = Console.ReadLine()        let pairs = Seq.pairwise strIn        let ignoredTupleValue = ('1', '1')        let swappedTuples = pairs |> Seq.mapi (fun idx pair ->                                if idx % 2 = 0 then                                    let (a, b) = pair                                    (b, a)                                else                                    ignoredTupleValue)        let answer = Seq.fold (fun (sb : StringBuilder) pair ->                                if pair <> ignoredTupleValue then                                    let (a, b) = pair                                    sb.Append(a) |> ignore                                    sb.Append(b) |> ignore                                sb)                                (new StringBuilder())                                swappedTuples        printfn %s (answer.ToString())    0
Swap even/odd characters
strings;programming challenge;functional programming;f#
Building off Caridorc's pseudocode, this function would do it:let switchOddAndEven (str : string) =    str.ToCharArray()    |> Array.chunkBySize 2    |> Array.map Array.rev    |> Array.concat    |> System.String.ConcatThe first and last methods are just switching between a char array and a string. Usage is simply:switchOddAndEven abcd;;// val it : string = badcor in your main method[<EntryPoint>]let main argv =    let numCases = Console.ReadLine() |> int    for i = numCases downto 1 do        Console.ReadLine()        |> switchOddAndEven        |> printfn %s    0Note you don't need a full blown console app to do these kind of things. Create a new fsx file in Visual Studio (File -> New -> File -> F# Script File) then type your functions there. To execute just select it all and send it to the F# Interactive with Alt + Enter.EditFrom the comments: one could take advantage of the fact that string is an IEnumerable and use the Seq module, which saves one method call:let switchOddAndEven (str : string) =     str     |> Seq.chunkBySize 2     |> Seq.map Seq.rev     |> Seq.concat     |> System.String.Concat