diff options
-rw-r--r-- | txr.1 | 59 |
1 files changed, 34 insertions, 25 deletions
@@ -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 |