W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
for pattern in enumerable-expression do body-expression實例
// Looping over a list. let list1 = [ 10; 25; 34; 45; 78 ] for i in list1 do printfn "%d" i // Looping over a sequence. let seq1 = seq { for i in 1 .. 10 -> (i, i*i) } for (a, asqr) in seq1 do printfn "%d squared is %d" a asqr當編譯和執(zhí)行程序時,它會產生以下輸出
10 25 34 45 78 1 squared is 1 2 squared is 4 3 squared is 9 4 squared is 16 5 squared is 25 6 squared is 36 7 squared is 49 8 squared is 64 9 squared is 81 10 squared is 100
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: