mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Implement List.sublist
This commit is contained in:
parent
d4a741d483
commit
9f5d3f521b
5 changed files with 118 additions and 0 deletions
|
@ -985,6 +985,22 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
Box::new(list_type(flex(TVAR1))),
|
||||
);
|
||||
|
||||
// sublist : List elem, { start : Nat, len : Nat } -> List elem
|
||||
add_top_level_function_type!(
|
||||
Symbol::LIST_SUBLIST,
|
||||
vec![
|
||||
list_type(flex(TVAR1)),
|
||||
SolvedType::Record {
|
||||
fields: vec![
|
||||
("start".into(), RecordField::Required(nat_type())),
|
||||
("len".into(), RecordField::Required(nat_type())),
|
||||
],
|
||||
ext: Box::new(SolvedType::EmptyRecord),
|
||||
},
|
||||
],
|
||||
Box::new(list_type(flex(TVAR1))),
|
||||
);
|
||||
|
||||
// drop : List elem, Nat -> List elem
|
||||
add_top_level_function_type!(
|
||||
Symbol::LIST_DROP,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue