From 3210e6fbf9168d7cf47bb63b17ae934ff3909689 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 19 May 2025 07:54:05 -0700 Subject: doc: break up remove-if section. * txr.1: The remove and keep functions are missing from their section heading. Adding them in makes the heading overstuffed, so breaking it up. The separate function and the two lazy functions remove-if* and keep-if* go into their own sections. --- txr.1 | 59 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 25 deletions(-) diff --git a/txr.1 b/txr.1 index 719ac2b7..48247fce 100644 --- a/txr.1 +++ b/txr.1 @@ -37375,20 +37375,16 @@ is omitted, then each element itself of is compared to .metn object . -.coNP Functions @, remove-if @, keep-if @, separate @ remove-if* and @ keep-if* +.coNP Functions @, remove @, remove-if @, keep @, keep-if @, separate @ remove-if* and @ keep-if* .synb .mets (remove < key < sequence >> [testfun >> [ keyfun <> [ mapfun ]]]) .mets (remove-if < predfun < sequence >> [ keyfun <> [ mapfun ]]) .mets (keep < key < sequence >> [testfun >> [ keyfun <> [ mapfun ]]]) .mets (keep-if < predfun < sequence >> [ keyfun <> [ mapfun ]]) -.mets (separate < predfun < sequence >> [ keyfun <> [ mapfun ]]) -.mets (remove-if* < predfun < sequence >> [ keyfun <> [ mapfun ]]) -.mets (keep-if* < predfun < sequence >> [ keyfun <> [ mapfun ]]) .syne .desc Functions in this group perform filtering of sequences, -either retaining or rejecting items which satisfy a condition, -or separating the two into two sequences. +either retaining or rejecting items which satisfy a condition. The .code remove-if @@ -37486,6 +37482,28 @@ It retains those items which .code remove will delete and vice versa. +.TP* Examples: +.verb + ;; remove any element numerically equal to 3. + (remove-if (op = 3) '(1 2 3 4 3.0 5)) -> (1 2 4 5) + + ;; remove those pairs whose first element begins with "abc" + [remove-if (op equal [@1 0..3] "abc") + '(("abcd" 4) ("defg" 5)) + car] + -> (("defg" 5)) + + ;; equivalent, without test function + (remove-if (op equal [(car @1) 0..3] "abc") + '(("abcd" 4) ("defg" 5))) + -> (("defg" 5)) +.brev + +.coNP Function @ separate +.synb +.mets (separate < predfun < sequence >> [ keyfun <> [ mapfun ]]) +.syne +.desc The .code separate function combines @@ -37525,32 +37543,23 @@ function may be understood in terms of the following reference implementation: seq]) .brev +.coNP Functions @ remove-if* and @ keep-if* +.synb +.mets (remove-if* < predfun < sequence >> [ keyfun <> [ mapfun ]]) +.mets (keep-if* < predfun < sequence >> [ keyfun <> [ mapfun ]]) +.syne +.desc The .code remove-if* and .code keep-if* -functions are like +have the same argument syntax and semantics as, respectively, .code remove-if and .codn keep-if , -but produce lazy lists. - -.TP* Examples: -.verb - ;; remove any element numerically equal to 3. - (remove-if (op = 3) '(1 2 3 4 3.0 5)) -> (1 2 4 5) - - ;; remove those pairs whose first element begins with "abc" - [remove-if (op equal [@1 0..3] "abc") - '(("abcd" 4) ("defg" 5)) - car] - -> (("defg" 5)) - - ;; equivalent, without test function - (remove-if (op equal [(car @1) 0..3] "abc") - '(("abcd" 4) ("defg" 5))) - -> (("defg" 5)) -.brev +but with lazy semantics. These functions process +.meta sequence +lazily and return a lazy list. .coNP Functions @ keep-keys-if and @ separate-keys .synb -- cgit v1.2.3