mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
Merge branch 'trunk' into enewbury/list-sort-desc
This commit is contained in:
commit
a96d5e6abf
4 changed files with 54 additions and 3 deletions
|
@ -51,7 +51,7 @@ macro_rules! macro_magic {
|
|||
/// even those that are relied on transitively!
|
||||
pub fn builtin_dependencies(symbol: Symbol) -> &'static [Symbol] {
|
||||
match symbol {
|
||||
// Symbol::LIST_SORT_ASC => &[Symbol::LIST_SORT_WITH, Symbol::NUM_COMPARE],
|
||||
Symbol::LIST_SORT_ASC => &[Symbol::LIST_SORT_WITH, Symbol::NUM_COMPARE],
|
||||
Symbol::LIST_SORT_DESC => &[
|
||||
Symbol::LIST_SORT_WITH,
|
||||
Symbol::LIST_SORT_DESC_COMPARE,
|
||||
|
@ -146,6 +146,7 @@ pub fn builtin_defs_map(symbol: Symbol, var_store: &mut VarStore) -> Option<Def>
|
|||
LIST_WALK_BACKWARDS => list_walk_backwards,
|
||||
LIST_WALK_UNTIL => list_walk_until,
|
||||
LIST_SORT_WITH => list_sort_with,
|
||||
LIST_SORT_ASC => list_sort_asc,
|
||||
LIST_SORT_DESC => list_sort_desc,
|
||||
LIST_ANY => list_any,
|
||||
LIST_ALL => list_all,
|
||||
|
@ -3424,6 +3425,37 @@ fn list_sort_with(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
|||
lowlevel_2(symbol, LowLevel::ListSortWith, var_store)
|
||||
}
|
||||
|
||||
/// List.sortAsc : List (Num a) -> List (Num a)
|
||||
fn list_sort_asc(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let list_var = var_store.fresh();
|
||||
let closure_var = var_store.fresh();
|
||||
let ret_var = list_var;
|
||||
|
||||
let function = (
|
||||
var_store.fresh(),
|
||||
Loc::at_zero(Expr::Var(Symbol::LIST_SORT_WITH)),
|
||||
var_store.fresh(),
|
||||
ret_var,
|
||||
);
|
||||
|
||||
let body = Expr::Call(
|
||||
Box::new(function),
|
||||
vec![
|
||||
(list_var, Loc::at_zero(Var(Symbol::ARG_1))),
|
||||
(closure_var, Loc::at_zero(Var(Symbol::NUM_COMPARE))),
|
||||
],
|
||||
CalledVia::Space,
|
||||
);
|
||||
|
||||
defn(
|
||||
symbol,
|
||||
vec![(list_var, Symbol::ARG_1)],
|
||||
var_store,
|
||||
body,
|
||||
ret_var,
|
||||
)
|
||||
}
|
||||
|
||||
/// List.sortDesc : List (Num a) -> List (Num a)
|
||||
fn list_sort_desc(symbol: Symbol, var_store: &mut VarStore) -> Def {
|
||||
let list_var = var_store.fresh();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue