paulo Posted September 24, 2018 Posted September 24, 2018 How do I remove an item from a list using a wildcard query: ("big23" "large25" "superlarge26" "superlarge-27" "superlarge_28" and so on) to ("big23" "large25" and so on), just removing the "superlarge..." parts) Thanks in advance, guys. Quote
Tharwat Posted September 24, 2018 Posted September 24, 2018 Hi, One way with mapcar & lambda functions. (mapcar '(lambda (x) (if (wcmatch x "superlarge*") (substr x 12) x ) ) '("big23" "large25" "superlarge26" "superlarge-27" "superlarge_28") ) Quote
ziele_o2k Posted September 24, 2018 Posted September 24, 2018 (edited) @Tharwat I think that @paulo whant to remove item, not part of string: Here are my solutions: Use parse list function from this post And example of use: (pz:LST_Parse '("big23" "large25" "superlarge26" "superlarge-27" "superlarge_28") '(lambda (%) (wcmatch % "superla*")) t ) Or simply use vl-remove-if function (vl-remove-if '(lambda (%) (wcmatch % "superla*")) '("big23" "large25" "superlarge26" "superlarge-27" "superlarge_28") ) EDIT: I notice today my forum rank: Rising Star - I love it Edited September 24, 2018 by ziele_o2k 1 Quote
Grrr Posted September 24, 2018 Posted September 24, 2018 Another variation for vl-remove-if behaviour: (apply 'append (mapcar '(lambda (x) (if (wcmatch x "superla*") (list x)) ) '("big23" "large25" "superlarge26" "superlarge-27" "superlarge_28") ) ) Quote
paulo Posted September 25, 2018 Author Posted September 25, 2018 as usual, this forum is the way to go for the 'learners' like me. What more to say, another happy camper here, so thanks big time. Till the next time... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.