mirror of
https://github.com/correl/elm.git
synced 2024-12-22 11:09:08 +00:00
35 lines
674 B
Text
35 lines
674 B
Text
module Sublist (..) where
|
|
|
|
import List exposing (..)
|
|
import String
|
|
|
|
|
|
sublist : List a -> List a -> String
|
|
sublist alist blist =
|
|
if alist == blist then
|
|
"Equal"
|
|
else if inList alist blist then
|
|
"Superlist"
|
|
else if inList blist alist then
|
|
"Sublist"
|
|
else
|
|
"Unequal"
|
|
|
|
|
|
inList : List a -> List a -> Bool
|
|
inList alist blist =
|
|
let
|
|
getLastInList sublist =
|
|
case (List.tail sublist) of
|
|
Just list ->
|
|
list
|
|
|
|
Nothing ->
|
|
[]
|
|
in
|
|
if (List.length alist) < (List.length blist) then
|
|
False
|
|
else if (List.take (List.length blist) alist) == blist then
|
|
True
|
|
else
|
|
inList (getLastInList alist) blist
|