mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 16:44:33 +00:00
add List.range
This commit is contained in:
parent
4ce520fed6
commit
d718e21fd3
11 changed files with 253 additions and 2 deletions
|
@ -7,7 +7,7 @@ use crate::llvm::build_hash::generic_hash;
|
|||
use crate::llvm::build_list::{
|
||||
allocate_list, empty_list, empty_polymorphic_list, list_append, list_concat, list_contains,
|
||||
list_get_unsafe, list_join, list_keep_errs, list_keep_if, list_keep_oks, list_len, list_map,
|
||||
list_map2, list_map3, list_map_with_index, list_prepend, list_product, list_repeat,
|
||||
list_map2, list_map3, list_map_with_index, list_prepend, list_product, list_range, list_repeat,
|
||||
list_reverse, list_set, list_single, list_sum, list_walk, list_walk_backwards,
|
||||
};
|
||||
use crate::llvm::build_str::{
|
||||
|
@ -3879,6 +3879,26 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
|
||||
list_contains(env, layout_ids, elem, elem_layout, list)
|
||||
}
|
||||
ListRange => {
|
||||
// List.contains : List elem, elem -> Bool
|
||||
debug_assert_eq!(args.len(), 2);
|
||||
|
||||
let (low, low_layout) = load_symbol_and_layout(scope, &args[0]);
|
||||
let high = load_symbol(scope, &args[1]);
|
||||
|
||||
let builtin = match low_layout {
|
||||
Layout::Builtin(builtin) => builtin,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
list_range(
|
||||
env,
|
||||
layout_ids,
|
||||
*builtin,
|
||||
low.into_int_value(),
|
||||
high.into_int_value(),
|
||||
)
|
||||
}
|
||||
ListWalk => {
|
||||
debug_assert_eq!(args.len(), 3);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue