Last active
March 20, 2018 21:33
-
-
Save zzamboni/9c94ce4bb1fdf4f8019d8119de92e46e to your computer and use it in GitHub Desktop.
`run-parallel` with slices in Elvish
This file contains hidden or 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
files = [ "file-"(range 100) ] | |
fn slice-indices [num inc]{ | |
range $num &step=$inc | each [x]{ put $x':'(+ $x $inc) } | |
} | |
fn slices [list inc]{ | |
put $list[(slice-indices (count $list) $inc)] | |
} | |
slices $files 5 | each [slice]{ | |
put [ | |
(each [f]{ | |
put { echo "Processing "$f; sleep (randint 0 4) } | |
} $slice) | |
] | |
} | each [fnslice]{ run-parallel $@fnslice } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment