well that's why functional programming is here
this code works on OCAML and F #, you can easily run it in C #
let generate str = let rec gen_aux s index = match index with | String.length s -> [s] | _ -> let part1 = String.substr s 0 index in let part2 = String.substr s index (String.length s) in (part1 ^ "'" ^ part2)::gen_aux s (index + 1) in gen_aux str 1;; generate "murrays";;
this code returns the original word as the end of the list, you can workaround :)
source share