And here is one way that uses list comprehension and bending, which is a function for recursion:
[for i in 1..10 -> "a"] |> List.fold (+) ""
Fractal tail version
let repeat2 sn = let rec loop acc n = match n with | _ when n > 0 -> loop (acc + s) (n - 1) | _ -> acc loop "" n repeat "oijdfsaoijdoyasjd" 100000 // Process is terminated due to StackOverflowException. [for i in 1..100000 -> "oijdfsaoijdoyasjd"] |> List.fold (+) "" // no stack overflow repeat2 "oijdfsaoijdoyasjd" 100000 // no stack overflow
But prepared for massive quantities of GC2 GC and a few minutes. runtime.
source share