I have a payment/lockbox file archiving utility that is called several times per day and with different parameters depending on the files that need archiving.
I know I can flatten
argv into a string using a simple method like the following:
let r = Array.toList(argv) let a = r |> String.concat " "
so the utility can send me email with the parameters used to call it without all the brackets from a
However, I wanted to see if I could flatten
argv using tail recursion, so is the following example tail-recursive?
let squash_str_array (str_arg : string) = let array_len = str_arg.Length let rec inner_squash (inner_str_arg : string ) (build_up_list : string) idx = if idx = array_len then build_up_list else let build_up_list = inner_str_arg.[idx] + " " + build_up_list inner_squash inner_str_arg build_up_list (idx + 1) inner_squash str_arg "" 0 [<EntryPoint>] let main argv = let test_array = [| "/mu"; "/al"|] let new_list = squash_str_array test_array . . .
newArray, etc. \$\endgroup\$