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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.