Implement List.dropIf

This was referenced in the `List` documentation and in the
[tutorial](./TUTORIAL.md), but wasn't actually implemented prior to this
commit!

Part of #2227
This commit is contained in:
ayazhafiz 2021-12-22 12:33:08 -06:00
parent 78a247e6f2
commit ed64ff912a
5 changed files with 180 additions and 1 deletions

View file

@ -634,6 +634,9 @@ impl<'a> Specialized<'a> {
}
fn insert_specialized(&mut self, symbol: Symbol, layout: ProcLayout<'a>, proc: Proc<'a>) {
if format!("{:?}", symbol).contains("joinMapConcat") {
panic!("");
}
for (i, s) in self.symbols.iter().enumerate() {
if *s == symbol && self.proc_layouts[i] == layout {
match &self.procedures[i] {
@ -4294,7 +4297,20 @@ pub fn with_hole<'a>(
ListKeepIf => {
debug_assert_eq!(arg_symbols.len(), 2);
let xs = arg_symbols[0];
match_on_closure_argument!(ListKeepIf, [xs])
let stmt = match_on_closure_argument!(ListKeepIf, [xs]);
// See the comment in `walk!`. We use List.keepIf to implement
// other builtins, where the closure can be an actual closure rather
// than a symbol.
assign_to_symbol(
env,
procs,
layout_cache,
args[1].0, // the closure
Located::at_zero(args[1].1.clone()),
arg_symbols[1],
stmt,
)
}
ListAny => {
debug_assert_eq!(arg_symbols.len(), 2);
@ -6229,6 +6245,7 @@ fn store_record_destruct<'a>(
/// for any other expression, we create a new symbol, and will
/// later make sure it gets assigned the correct value.
#[derive(Debug)]
enum ReuseSymbol {
Imported(Symbol),
LocalFunction(Symbol),