diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/rosetta/Sierpinski_triangle.bruijn | 9 | ||||
-rw-r--r-- | samples/rosetta/harmonic_series.bruijn | 15 |
2 files changed, 24 insertions, 0 deletions
diff --git a/samples/rosetta/Sierpinski_triangle.bruijn b/samples/rosetta/Sierpinski_triangle.bruijn new file mode 100644 index 0000000..22659d1 --- /dev/null +++ b/samples/rosetta/Sierpinski_triangle.bruijn @@ -0,0 +1,9 @@ +y [[1 (0 0)] [1 (0 0)]] + +# infinite depth +triangle [y [[0 1 [[0]] 1 1]]] + +:import std/Number . + +# limited depth +triangle-n [y [[[[1 0 [[0]] 0 0] (=?1 [[1]] (2 --1))]]] (+7)] 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)) |