You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Work on #2182 (see comments there) suggests we should revisit this module and tidy up various things, the to{Nat}Digits function in particular.
Specifically, regarding:
toNatDigits : (base : ℕ) {base≤16 : True (1 ≤? base)} → ℕ → List ℕ
toNatDigits base@(suc zero) n = replicate n 1
toNatDigits base@(suc (suc _)) n = aux (<-wellFounded-fast n) []
whereaux : {n : ℕ} → Acc _<_ n → List ℕ → List ℕ
aux {zero} _ xs = (0 ∷ xs)
aux {n@(suc _)} (acc wf) xs with does (0 <? n / base)
... | false = (n % base) ∷ xs -- n here is already sufficient?
... | true = aux (wf (m/n<m n base sz<ss)) ((n % base) ∷ xs)
the precondition {base≤16 : True (1 ≤? base)} is now simply {{NonZero base}};
the comment about the false branch in aux: why not simply branch on does (n <? base), noting that in the true branch of such a choice, n % base is already given by n...
Activity