list刪除和挑選,list刪除挑選

來源:互聯網
上載者:User

list刪除和挑選,list刪除挑選

clean函數用於刪除合格list元素,filter函數用於挑選合格list元素

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


clean 結合lambda以及member函數,可以先定一個list,裡麵包含所有要剔除的元素,然後對另一個list操作,該list中的元素只要出現在第一個list中,就一定會被剔除。

下面的a是一個字串,先轉換成list,然後用unique去掉多餘的空格,只留下一個空格,最後用clean + lambda + member將最後一個空格去除。 這樣string就變成了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")



比如下面的代碼可以用來將目錄下.和..的檔案刪除掉:

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



vb怎刪除list中的選項

Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
If InStr(List1.List(i), "BC") > 0 Then List1.RemoveItem i
Next
End Sub
 
vb list刪除選定行後自動跳到下一個

Private Sub List1_KeyDown(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 = a
Else
List1.ListIndex = a - 1
End If
End If
End Sub
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.