| @@ -0,0 +1,27 @@ | |||
| # Reverse String | |||
| Reverse a string | |||
| For example: | |||
| input: "cool" | |||
| output: "looc" | |||
| ## Running the tests | |||
| To run the tests, run the command `dotnet test` from within the exercise directory. | |||
| ## Autoformatting the code | |||
| F# source code can be formatted with the [Fantomas](https://github.com/fsprojects/fantomas) tool. | |||
| After installing it with `dotnet tool restore`, run `dotnet fantomas .` to format code within the current directory. | |||
| ## Further information | |||
| For more detailed information about the F# track, including how to get help if | |||
| you're having trouble, please visit the exercism.io [F# language page](http://exercism.io/languages/fsharp/resources). | |||
| ## Source | |||
| Introductory challenge to reverse an input string [https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb](https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb) | |||
| @@ -0,0 +1,3 @@ | |||
| module ReverseString | |||
| let reverse (input: string) = Seq.toList input |> List.rev |> Array.ofList |> System.String | |||
| @@ -0,0 +1,21 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | |||
| <PropertyGroup> | |||
| <TargetFramework>netcoreapp3.0</TargetFramework> | |||
| <IsPackable>false</IsPackable> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Compile Include="ReverseString.fs" /> | |||
| <Compile Include="ReverseStringTests.fs" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" /> | |||
| <PackageReference Include="xunit" Version="2.4.1" /> | |||
| <PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" /> | |||
| <PackageReference Include="FsUnit.xUnit" Version="3.8.1" /> | |||
| </ItemGroup> | |||
| </Project> | |||
| @@ -0,0 +1,33 @@ | |||
| // This file was auto-generated based on version 1.2.0 of the canonical data. | |||
| module ReverseStringTests | |||
| open FsUnit.Xunit | |||
| open Xunit | |||
| open ReverseString | |||
| [<Fact>] | |||
| let ``An empty string`` () = | |||
| reverse "" |> should equal "" | |||
| [<Fact>] | |||
| let ``A word`` () = | |||
| reverse "robot" |> should equal "tobor" | |||
| [<Fact>] | |||
| let ``A capitalized word`` () = | |||
| reverse "Ramen" |> should equal "nemaR" | |||
| [<Fact>] | |||
| let ``A sentence with punctuation`` () = | |||
| reverse "I'm hungry!" |> should equal "!yrgnuh m'I" | |||
| [<Fact>] | |||
| let ``A palindrome`` () = | |||
| reverse "racecar" |> should equal "racecar" | |||
| [<Fact>] | |||
| let ``An even-sized word`` () = | |||
| reverse "drawer" |> should equal "reward" | |||