# Is This F# Recursive Example Tail Recursive?

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 string [].

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
.
.
.

• Yes, this is tail recursive, although a bit hard to read because of all the underscores in identifiers. Also, you're not using the array_idx parameter. – Fyodor Soikin Jul 13 '17 at 20:29
• @FyodorSoikin I know in F# libraries, Visual Studio 2015 frowns on mixed case names, so what do you suggest for naming convention? – octopusgrabbus Jul 13 '17 at 20:31
• javaCase is traditional for F# - e.g. arrayIdx, testArray, newArray, etc. – Fyodor Soikin Jul 13 '17 at 20:33
• Also, Visual Studio doesn't down on mixed case. Where did you get that idea? – Fyodor Soikin Jul 13 '17 at 20:33
• @FyodorSoikin When using mixed case in an F# library, Visual Studio popped up a warning. I've also edited the OP to remove the unwanted parameter (as well as in the test code). Thanks. – octopusgrabbus Jul 13 '17 at 20:34