diff options
Diffstat (limited to 'samples/rosetta/harmonic_series.bruijn')
-rw-r--r-- | samples/rosetta/harmonic_series.bruijn | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/samples/rosetta/harmonic_series.bruijn b/samples/rosetta/harmonic_series.bruijn new file mode 100644 index 0000000..2395933 --- /dev/null +++ b/samples/rosetta/harmonic_series.bruijn @@ -0,0 +1,15 @@ +: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.0f) : (+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)) |