aern2-real 0.2.14.1 → 0.2.15
raw patch · 3 files changed
+49/−3 lines, 3 filesdep ~aern2-mpPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aern2-mp
API changes (from Hackage documentation)
+ AERN2.Real.CKleenean: instance AERN2.Select.CanSelectCountable AERN2.Real.CKleenean.CKleenean
Files
- aern2-real.cabal +3/−3
- changelog.md +2/−0
- src/AERN2/Real/CKleenean.hs +44/−0
aern2-real.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: aern2-real-version: 0.2.14.1+version: 0.2.15 synopsis: Real numbers as convergent sequences of intervals description: Please see the README on GitHub at <https://github.com/michalkonecny/aern2/#readme> category: Math@@ -60,7 +60,7 @@ ghc-options: -Wall build-depends: QuickCheck- , aern2-mp >=0.2.14+ , aern2-mp >=0.2.15.0 , base ==4.* , collect-errors >=0.1.5 , hspec@@ -92,7 +92,7 @@ ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: QuickCheck- , aern2-mp >=0.2.14+ , aern2-mp >=0.2.15.0 , aern2-real , base ==4.* , collect-errors >=0.1.5
changelog.md view
@@ -1,6 +1,8 @@ # Change log for aern2-real * current+* v 0.2.15 2023-04-11+ * CanSelectCountable instance for CKleenean * v 0.2.14.1 2023-04-10 * fix compilation errors * v 0.2.13 2023-04-07
src/AERN2/Real/CKleenean.hs view
@@ -30,6 +30,7 @@ import AERN2.MP import AERN2.Real.Type+import Data.List (uncons) type CKleenean = CSequence Kleenean @@ -114,6 +115,49 @@ CN.noValueNumErrorCertain $ CN.NumError "select: Both branches failed!" _ -> aux rest1 rest2 aux _ _ = CN.noValueNumErrorCertain $ CN.NumError "select: internal error"++instance CanSelectCountable CKleenean where+ type SelectCountableType CKleenean = Integer+ selectCountable ckleeneans = + findTrue $ concatInfiniteLists (map (unCSequence . ckleeneans) [0..])+ where+ findTrue ((ki, i) : rest) =+ case (CN.toEither ki) of+ Right CertainTrue -> i+ _ -> findTrue rest+ findTrue [] = error "selectCountable: internal error"++{-|+ Take an infinite list of infinite lists and concatenate all the elements+ in a single infinite list in such a way that no element is lost.+ Moreoved, each element has the number of the original list added to it+ so that it is possible to work out which of the lists it came from.++ This function orders the elements as follows (where each item corresponds+ to one of the lists and the numbers show the positions in the result list):++ * 1 3 6 10 ... + * 2 5 9 ... + * 4 8 ...+ * 7 ...+ * ...++-}+concatInfiniteLists :: [[t]] -> [(t, Integer)]+concatInfiniteLists lists = + aux [] listsWithNumbers + where+ aux openedLists (nextList:remainingLists) =+ heads ++ (aux tails remainingLists)+ where+ (heads, tails) = unzip (map (removeJust . uncons) (nextList:openedLists))+ aux _ [] = e+ removeJust (Just x) = x+ removeJust Nothing = e+ e = error "concatInfiniteLists can be applied only to a list of infinite lists"+ listsWithNumbers = + [zip list (repeat listNumber) + | (list, listNumber) <- zip lists [0..]] instance (CanUnionCNSameType t) => HasIfThenElse CKleenean (CSequence t)