Seq module

문자열 뒤집기
문자열 뒤집기 F#에서
module ReverseString

let reverse input =
    input
    |> Seq.rev
    |> Seq.toArray
    |> System.String

The string class implements the seq interface (which is an abbreviation of the CLI IEnumerable interface), which means we can use functions from the Seq module on it.

First, we pipe the input string into Seq.reverse, which returns an enumerable with the input in reverse order.

To convert the seq<char> returned by Seq.reverse back to a string, we first use Seq.toArray to convert it to a char[].

Finally, we convert the char array back to a string by piping it into the System.String constructor.

2026년 10월 14일 · 유용했나요?