F# Flatten argv Into A Flat String Using Tail Recursion

let squashStrArray (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

Advertisements

Leave a comment

Filed under F#, Programming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s