From 1db970d78b12443737197e86c0f0d7db5a638bea Mon Sep 17 00:00:00 2001 From: mryouse Date: Fri, 15 Jul 2022 00:23:46 +0000 Subject: bugfix: drop-while wasn't dropping the last element --- neb/std/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'neb/std/core.py') 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)) -- cgit v1.2.3