12

I have the following function:

let fetchTickerGroup (tickers: string[])  (sqlServer:SQLServerClient) (schema: string) = 
tickers |> Array.map(fun x -> sqlServer.FetchTimeSerie(schema,x))

The function takes an array of strings and, through sqlServer fetches data which is returned by sqlServer.FetchTimeSerie as a List<b> where b is a custom defined object. Now, mapping the array means that the function fetchTickerGroup returns List<b>[].

I was wondering if it would be possible to flatMap the result, rather than just mapping the array values.

1 Answer 1

21

I have no Idea what Flatmap is but I think you want to use *.collect.

I think the best solution would be something like

tickers |> Array.toList |> List.collect (fun x -> sqlServer.FetchTimeSerie(schema,x))

you need to convert so that you have only list or array types

2
  • 11
    FlatMap, Collect and SelectMany are different names for the same concept Nov 4, 2013 at 11:42
  • 2
    @Gustavo: thank you, coming from Scala I have used an improper terminology. Nov 4, 2013 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.