Created
December 4, 2014 19:21
-
-
Save mayth/f5c8bfacf6f09a6c92f9 to your computer and use it in GitHub Desktop.
Slice array
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
let slice n arr = | |
let len = int (ceil ((float (Array.length arr)) / (float n))) | |
Array.init len (fun i -> arr.[(i * n)..(i * n + (n - 1))]) | |
// test code | |
[<EntryPoint>] | |
let main args = | |
let arr = [|1; 2; 3; 10; 20; 30; 100; 200; 300|] | |
let result = slice 3 arr | |
printfn "%A" result | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment