List deletion and selection, list deletion and selection

Source: Internet
Author: User

List deletion and selection, list deletion and selection

The clean function is used to delete list elements that meet the conditions. The filter function is used to select list elements that meet the conditions.

(clean symbol? '(1 2 d 4 f g 5 h))   → (1 2 4 5)(filter symbol? '(1 2 d 4 f g 5 h))  → (d f g h)(define (big? x) (> x 5))        → (lambda (x) (> x 5))(clean big? '(1 10 3 6 4 5 11))  → (1 3 4 5)(clean <= '(3 4 -6 0 2 -3 0))  → (3 4 2)(clean (curry match '(a *)) '((a 10) (b 5) (a 3) (c 8) (a 9)))→  ((b 5) (c 8))


In combination with lambda and member functions, clean can first set a list that contains all the elements to be removed, and then operate on another list. As long as the elements in the list appear in the first list, will be removed.

The following a is a string, first converted to list, then removed extra spaces with unique, leaving only one space, and finally removed the last space with clean + lambda + member. In this way, the string is changed to list.

> a"1 2 3 4"> (explode a)("1" " " "2" " " "3" " " "4")> (unique (explode a))("1" " " "2" "3" "4")> (clean (fn (p) (member p '(" "))) (unique (explode a)))("1" "2" "3" "4")



For example, the following code can be used to delete the files in the directory... and:

(clean (fn (p) (member p '("." ".."))) (directory dir-path))



How does vb Delete the options in the list?

Private Sub commandementclick ()
For I = 0 To List1.ListCount-1
If InStr (List1.List (I), "BC")> 0 Then List1.RemoveItem I
Next
End Sub

Vb list automatically jumps to the next row after deleting the selected row

Private Sub listdomainkeydown (KeyCode As Integer, Shift As Integer)
If KeyCode = 46 And List1.ListIndex>-1 Then
A = List1.ListIndex
List1.RemoveItem List1.ListIndex
If a <> List1.ListCount Then
List1.ListIndex =
Else
List1.ListIndex = a-1
End If
End If
End Sub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.