2020-04-12 00:10:14 +02:00
|
|
|
module Misc exposing (..)
|
|
|
|
|
2020-04-12 17:43:34 +02:00
|
|
|
|
2020-04-12 00:10:14 +02:00
|
|
|
comesAfter : a -> List a -> Maybe a
|
|
|
|
comesAfter x xs =
|
|
|
|
case xs of
|
2020-04-12 17:43:34 +02:00
|
|
|
[] ->
|
|
|
|
Nothing
|
|
|
|
|
|
|
|
_ :: [] ->
|
|
|
|
Nothing
|
|
|
|
|
|
|
|
y :: z :: rest ->
|
|
|
|
if y == x then
|
|
|
|
Just z
|
|
|
|
|
|
|
|
else
|
|
|
|
comesAfter x (z :: rest)
|
|
|
|
|
2020-04-12 00:10:14 +02:00
|
|
|
|
|
|
|
comesBefore : a -> List a -> Maybe a
|
|
|
|
comesBefore x xs =
|
|
|
|
case xs of
|
2020-04-12 17:43:34 +02:00
|
|
|
[] ->
|
|
|
|
Nothing
|
|
|
|
|
|
|
|
_ :: [] ->
|
|
|
|
Nothing
|
|
|
|
|
|
|
|
y :: z :: rest ->
|
|
|
|
if z == x then
|
|
|
|
Just y
|
|
|
|
|
|
|
|
else
|
|
|
|
comesBefore x (z :: rest)
|