Skip to content

Commit

Permalink
feat(stdlib): Add Array.zip function (#719)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Blair <[email protected]>
  • Loading branch information
phated and peblair committed Jun 13, 2021
1 parent 4474f88 commit 1dc7f56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions stdlib/array.gr
Original file line number Diff line number Diff line change
Expand Up @@ -373,3 +373,14 @@ export let unique = (array) => {
array
)
}

export let zip = (a, b) => {
let len = length(a)
if (len != length(b)) {
fail "arguments to zip must be same length"
} else {
init(len, n => {
(a[n], b[n])
})
}
}

0 comments on commit 1dc7f56

Please sign in to comment.