Jump to content

Recommended Posts

Posted

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.

Posted

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")
)

 

Posted (edited)

@Tharwat I think that @paulo whant to remove item, not part of string:

Here are my solutions:

  1. 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
    )

     

  2. 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 by ziele_o2k
  • Like 1
Posted

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")
  )
)

 

Posted

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...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...