hw-balancedparens-0.4.1.1: Balanced parentheses

Safe HaskellNone
LanguageHaskell2010

HaskellWorks.Data.BalancedParens.Internal.Slow.FindCloseN.Generic

Synopsis

Documentation

findCloseN :: (BitLength a, CloseAt a, TestBit a) => a -> Count -> Count -> Maybe Count Source #

Find the position of the corresponding close parenthesis carrying in a number of open parentheses starting from a given position.

All positions are one based.

This is a reference implementation.

>>> :set -XTypeApplications
>>> import HaskellWorks.Data.Bits.BitRead
>>> import Data.Maybe
>>> import Data.Word
>>> findCloseN (fromJust (bitRead @Word64 "1100000")) 0 1
Just 4
>>> findCloseN (fromJust (bitRead @Word64 "1100000")) 0 2
Just 3
>>> findCloseN (fromJust (bitRead @Word64 "1100000")) 1 1
Just 5
>>> findCloseN (fromJust (bitRead @Word64 "1100000")) 1 2
Just 4