轉到內容

99 埃爾姆問題/第 8 個問題

來自維基文庫,一個開放世界的開放書籍

編寫一個函式來移除列表元素中的連續重複項。

import Html exposing (text)
import List

compress : List a -> List a
-- your implementation goes here

main = text (toString (compress [1, 1, 2, 2, 3, 3, 3, 4, 5, 4, 4, 4, 4]))

結果

[1, 2, 3, 4, 5, 4]

解決方案

華夏公益教科書