Created
November 3, 2012 06:18
-
-
Save ApprenticeGC/4006263 to your computer and use it in GitHub Desktop.
Function Composition Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
let sizeOfFolderComposed folder = | |
let getFiles folder = | |
Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories) | |
let totalSize = | |
folder | |
|> getFiles | |
|> Array.map (fun file -> new FileInfo(file)) | |
|> Array.map (fun info -> info.Length) | |
|> Array.sum | |
// The last statement of function will be used as return statement | |
totalSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
let sizeOfFolderComposed folder = | |
let getFiles folder = | |
Directory.GetFiles(folder, "*.*", SearchOption.AllDirectories) | |
// This serves as the last return statement | |
getFiles | |
>> Array.map (fun file -> new FileInfo(file)) | |
>> Array.map (fun info -> info.Length) | |
>> Array.sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment