Merge pull request #2002 from rtfeldman/builtins-list-intersperse

Add builtin `List.intersperse`
This commit is contained in:
Folkert de Vries 2021-11-18 22:00:10 +01:00 committed by GitHub
commit a4fc813ca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 124 additions and 2 deletions

View file

@ -318,6 +318,29 @@ fn list_drop_at() {
assert_evals_to!("List.dropAt [0] 0", RocList::from_slice(&[]), RocList<i64>);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn list_intersperse() {
assert_evals_to!(
indoc!(
r#"
List.intersperse [0, 0, 0] 1
"#
),
RocList::from_slice(&[0, 1, 0, 1, 0]),
RocList<i64>
);
assert_evals_to!(
indoc!(
r#"
List.intersperse [] 1
"#
),
RocList::from_slice(&[]),
RocList<i64>
);
}
#[test]
#[cfg(any(feature = "gen-llvm"))]
fn list_drop_at_shared() {