Exactly three adjacent 3 in lists: Difference between revisions

Content added Content deleted
Line 76: Line 76:
Or (same test and results):
Or (same test and results):


<lang haskell>import Data.List (elemIndex)
<lang haskell>import Data.Bifunctor (bimap)
import Data.List (elemIndex)


nnPeers :: Int -> [Int] -> Bool
nnPeers :: Int -> [Int] -> Bool
Line 83: Line 84:
p = (n ==)
p = (n ==)
go i =
go i =
let (a, b) = splitAt n (drop i xs)
uncurry (&&) $
bimap
in all p a && not (any p b)</lang>
(all p)
(not . any p)
(splitAt n (drop i xs))</lang>


=={{header|Julia}}==
=={{header|Julia}}==