rosetta/harmonic_series.bruijn
Problem description
:import std/List .
:import std/Combinator .
:import std/Math/Rational Q
:import std/Number N
harmonic [0 &[[(Q.add 1 op) : N.++0]] start [[1]]] ⧗ Unary → Rational
op (+1) : N.--0
start (+0.0q) : (+1)
custom-gt? &[[[N.gt? 2 (N.mul 0 N.++1)]]] ⧗ Rational → Νumber → Boolean
main [φ cons first-20 first-10-above (harmonic <$> (iterate [[[1 (2 1 0)]]] (+0u)))]
first-20 take (+20)
first-10-above [take (+10) first-above]
first-above [find-index [custom-gt? 0 1] 1] <$> (iterate N.inc (+0))