I'm trying to use FAKE to build F# files that are located in several sub directories. The filesInDirMatching is from FAKE.
#r @"packages/FAKE/tools/FakeLib.dll"
open System.IO
open Fake
open Fake.FileSystemHelper
open Fake.FscHelper
let allDirs = DirectoryInfo(__SOURCE_DIRECTORY__).GetDirectories "*"
let all = allDirs |> Array.map(fun d -> filesInDirMatching "Example.fs" d)
This all kind of works except that, in the last line, it's creating a 2-dimensional array (since filesInDirMatching creates a new FileDirectory array, I'm guessing). Is it possible to reduce the 2-dimensional array into a one-dimensional array? Or is there a better way of doing this?
I guess by a 2 dimensional array you mean an array of array (a jagged array).
If so, just replace your Array.map
with Array.collect
You can flatten the array into a single dimension with Array.concat
:
let all = allDirs
|> Array.map(fun d -> filesInDirMatching "Example.fs" d)
|> Array.concat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With