99 個 Elm 問題/問題 1
外觀
找到列表的最後一個元素。
在這個測試應用程式中實現 lastElement。
module Main exposing (..)
import Html exposing (text)
import List
import Maybe
lastElement : List a -> Maybe a
lastElement list =
-- your implementation goes here
Nothing
main =
case lastElement [1,2,3,4] of
Just a -> text (toString a)
Nothing -> text "No element found"
4