diff options
author | William Carroll <wpcarro@gmail.com> | 2020-04-11T22·10+0100 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-04-11T22·10+0100 |
commit | 808e6ee4847a92cb763f8776149e97575d9c1961 (patch) | |
tree | ccfef45c0c7bca260963bc44d8d1594213c801ed /website | |
parent | c24c9b7fb940793ef75fa61d00abb31c3d56f94b (diff) |
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.
Diffstat (limited to 'website')
-rw-r--r-- | website/sandbox/chord-drill-sergeant/src/Misc.elm | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/website/sandbox/chord-drill-sergeant/src/Misc.elm b/website/sandbox/chord-drill-sergeant/src/Misc.elm new file mode 100644 index 000000000000..479234ff1546 --- /dev/null +++ b/website/sandbox/chord-drill-sergeant/src/Misc.elm @@ -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) |