Support Misc module
Define two functions for attempting to return an element in a list that precedes or succeeds another element. I prefer having something like Utils.List. Perhaps I will refactor.
This commit is contained in:
parent
c24c9b7fb9
commit
808e6ee484
1 changed files with 15 additions and 0 deletions
15
website/sandbox/chord-drill-sergeant/src/Misc.elm
Normal file
15
website/sandbox/chord-drill-sergeant/src/Misc.elm
Normal file
|
@ -0,0 +1,15 @@
|
|||
module Misc exposing (..)
|
||||
|
||||
comesAfter : a -> List a -> Maybe a
|
||||
comesAfter x xs =
|
||||
case xs of
|
||||
[] -> Nothing
|
||||
_::[] -> Nothing
|
||||
y::z::rest -> if y == x then Just z else comesAfter x (z::rest)
|
||||
|
||||
comesBefore : a -> List a -> Maybe a
|
||||
comesBefore x xs =
|
||||
case xs of
|
||||
[] -> Nothing
|
||||
_::[] -> Nothing
|
||||
y::z::rest -> if z == x then Just y else comesAfter x (z::rest)
|
Loading…
Reference in a new issue