Skip to content

Commit

Permalink
less abstract implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
jmagaram committed Mar 27, 2024
1 parent 1f9f833 commit c6f27a6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Seq.res
Original file line number Diff line number Diff line change
Expand Up @@ -931,4 +931,15 @@ let chunkBySize = (xx, length) => {
)
}

let at = (xx, inx) => xx->indexed->findMap(((item, i)) => i == inx ? Some(item) : None)
let at = (xx, inx) => {
let rec go = (xx, inxCurrent) =>
switch xx->next {
| End => None
| Next(x, xx) =>
switch inxCurrent == inx {
| true => Some(x)
| false => go(xx, inxCurrent + 1)
}
}
go(xx, 0)
}

0 comments on commit c6f27a6

Please sign in to comment.