From aeca5d81592de6bdbf485505fa867e36301d726a Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 14 Apr 2022 21:29:25 -0700 Subject: cons: document nth and nthcdr; add tests Fixing semantics of nth for negative values. --- cppawk-include/cons-priv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cppawk-include') diff --git a/cppawk-include/cons-priv.h b/cppawk-include/cons-priv.h index 4c0a767..2f5bdce 100644 --- a/cppawk-include/cons-priv.h +++ b/cppawk-include/cons-priv.h @@ -693,7 +693,7 @@ function __nth(__pos, __lst) { for (; __pos > 0 && !__endp(__lst); __pos--) __lst = __cdr(__lst) - return __car(__lst) + return __pos == 0 ? __car(__lst) : __nil } function __nthcdr(__pos, __lst) -- cgit v1.2.3