Jose Maria de la Torre
Jose Maria de la Torre

Reputation: 265

Changing a Tuple element (sequence) to sequence length (int)

I have this noob problem that im trying to fix but I cant

I have an array of tuples in the form of

tuple: (string*(string*seq<string>)[])[] 

I wish to convert the "seq" to the sequence length (int)

I tried in various forms with

Seq.length 

but I haven't been able to do it, can anyone help? thanks!

Upvotes: 0

Views: 68

Answers (2)

scrwtp
scrwtp

Reputation: 13577

This function will map the nested sequence to its length:

let map arg : (string*(string*int)[])[] =
    arg |> Array.map (fun (s1, arr) ->
        s1, arr |> Array.map (fun (s2, coll) -> s2, Seq.length coll))

But seeing how complex the type you have there is, I wonder do you represent with it? You'd almost certainly want to use something more palatable then this.

Upvotes: 1

Gus
Gus

Reputation: 26194

Array.map (fun (s,e) -> s, Array.map (fun (s,e) -> s, Seq.length e) e) tupArray

Upvotes: 1

Related Questions