diff options
| author | mryouse | 2022-07-15 00:23:46 +0000 |
|---|---|---|
| committer | mryouse | 2022-07-15 00:23:46 +0000 |
| commit | 1db970d78b12443737197e86c0f0d7db5a638bea (patch) | |
| tree | 495a9abee83c75842a556c50ba0f5564edac3685 | |
| parent | 0fd87cd92a3777f8823c466a71c341f9ae0292e3 (diff) | |
bugfix: drop-while wasn't dropping the last element
| -rw-r--r-- | neb/std/core.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/neb/std/core.py b/neb/std/core.py index 9a9e56d..ea80d86 100644 --- a/neb/std/core.py +++ b/neb/std/core.py @@ -126,15 +126,18 @@ def interpretDropWhile(symbol, args, env, ns): ev = None which_idx = None for idx, item in enumerate(coll.args): - which_idx = idx new_env.register("_item_", evaluate(item, env, ns)) for arg in args[1:]: ev = evaluate(arg, new_env, ns) if not isinstance(ev, Bool): raise InterpretPanic(symbol, "condition must evaluate to a :bool", ev) if ev.value is False: + which_idx = idx break - return List(coll.args[which_idx:]) + if which_idx is not None: + return List(coll.args[which_idx:]) + else: + return List([]) CORE.register("drop-while", NebSyntax("drop-while", interpretDropWhile, [for_each_arg, for_body_arg], for_body_arg)) |
