forked from aarani/NOnion
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Network: use F#'s ChunkBySize method
This commit removes the chunk helper function in favor the already existing F# method named ChunkBySize, not sure why I didn't find it before.
- Loading branch information
Showing
2 changed files
with
1 addition
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,5 @@ | ||
namespace NOnion.Utility | ||
|
||
module SeqUtils = | ||
// Helper function copied from https://stackoverflow.com/a/21615676 | ||
let Chunk chunkSize sequence = | ||
sequence | ||
|> Seq.mapi(fun i x -> i / chunkSize, x) | ||
|> Seq.groupBy fst | ||
|> Seq.map(fun (_, g) -> Seq.map snd g) | ||
|
||
let TakeRandom count sequence = | ||
sequence |> Seq.sortBy(fun _ -> System.Guid.NewGuid()) |> Seq.take count |