Merge pull request #3399 from rtfeldman/pure-roc-map-with-index

Pure Roc `List.mapWithIndex`
This commit is contained in:
Folkert de Vries 2022-07-06 00:25:46 +02:00 committed by GitHub
commit 93dbda9ac5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 231 additions and 367 deletions

View file

@ -561,13 +561,6 @@ impl<'a> BorrowInfState<'a> {
self.own_var(*xs);
}
}
ListMapWithIndex { xs } => {
// List.mapWithIndex : List before, (before, Nat -> after) -> List after
// own the list if the function wants to own the element (before, index 0)
if !function_ps[0].borrow {
self.own_var(*xs);
}
}
ListMap2 { xs, ys } => {
// own the lists if the function wants to own the element
if !function_ps[0].borrow {
@ -910,7 +903,7 @@ pub fn lowlevel_borrow_signature(arena: &Bump, op: LowLevel) -> &[bool] {
StrToNum => arena.alloc_slice_copy(&[borrowed]),
ListPrepend => arena.alloc_slice_copy(&[owned, owned]),
StrJoinWith => arena.alloc_slice_copy(&[borrowed, borrowed]),
ListMap | ListMapWithIndex => arena.alloc_slice_copy(&[owned, function, closure_data]),
ListMap => arena.alloc_slice_copy(&[owned, function, closure_data]),
ListMap2 => arena.alloc_slice_copy(&[owned, owned, function, closure_data]),
ListMap3 => arena.alloc_slice_copy(&[owned, owned, owned, function, closure_data]),
ListMap4 => arena.alloc_slice_copy(&[owned, owned, owned, owned, function, closure_data]),