diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-04-15 17:41:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-04-15 17:41:23 -0700 |
commit | 8beafd5dc2b663c26502816e3f72adb3de4655ff (patch) | |
tree | 89d1bc88805d8958473b972274929dab1185deb9 /cppawk-include/cons-priv.h | |
parent | 4663bb3b6feeb2bdbe18391336b5b7dd2ededf5e (diff) | |
download | cppawk-8beafd5dc2b663c26502816e3f72adb3de4655ff.tar.gz cppawk-8beafd5dc2b663c26502816e3f72adb3de4655ff.tar.bz2 cppawk-8beafd5dc2b663c26502816e3f72adb3de4655ff.zip |
cons: document and test uniq, new uniqual function.
Diffstat (limited to 'cppawk-include/cons-priv.h')
-rw-r--r-- | cppawk-include/cons-priv.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cppawk-include/cons-priv.h b/cppawk-include/cons-priv.h index 97d410d..4482fa6 100644 --- a/cppawk-include/cons-priv.h +++ b/cppawk-include/cons-priv.h @@ -843,6 +843,23 @@ function __uniq(__lst, return __list_end(__out) } +function __uniqual(__lst, + __out, __item, __itemeq, __seen) +{ + __out = __list_begin(); + + __dolist(__item, __lst) { + __itemq = __equalize(__item) + if (__itemq in __seen) + continue + __seen[__itemq] + __out = __list_add(__out, __item) + } + + return __list_end(__out) +} + + #if __have_indirect_functions function __mapcar(__fun, __lst, |