aboutsummaryrefslogtreecommitdiffhomepage
path: root/samples/rosetta
diff options
context:
space:
mode:
authorMarvin Borner2024-05-09 16:26:06 +0200
committerMarvin Borner2024-05-09 16:26:06 +0200
commit99ec17a582ce40c35e9be76415b3a4a6dcff65ae (patch)
treea1492df416aef62c440fd36f475a90ff9ee32ec5 /samples/rosetta
parenta25ed8a75d036de252cfe74b5fa0788215194b41 (diff)
Another rosetta sync
Diffstat (limited to 'samples/rosetta')
-rw-r--r--samples/rosetta/harmonic_series.bruijn2
-rw-r--r--samples/rosetta/towers_of_hanoi.bruijn10
2 files changed, 11 insertions, 1 deletions
diff --git a/samples/rosetta/harmonic_series.bruijn b/samples/rosetta/harmonic_series.bruijn
index 2395933..4c2c2d5 100644
--- a/samples/rosetta/harmonic_series.bruijn
+++ b/samples/rosetta/harmonic_series.bruijn
@@ -5,7 +5,7 @@
harmonic [0 &[[(Q.add 1 op) : N.++0]] start [[1]]] ⧗ Unary → Rational
op (+1) : N.--0
- start (+0.0f) : (+1)
+ start (+0.0q) : (+1)
custom-gt? &[[[N.gt? 2 (N.mul 0 N.++1)]]] ⧗ Rational → Νumber → Boolean
diff --git a/samples/rosetta/towers_of_hanoi.bruijn b/samples/rosetta/towers_of_hanoi.bruijn
new file mode 100644
index 0000000..afebb12
--- /dev/null
+++ b/samples/rosetta/towers_of_hanoi.bruijn
@@ -0,0 +1,10 @@
+:import std/Combinator .
+:import std/Number .
+:import std/String .
+
+hanoi y [[[[=?2 empty go]]]]
+ go [(4 --3 2 0) ++ str ++ (4 --3 0 1)] ((+6) - 1 - 0)
+ str "Move " ++ disk ++ " from " ++ source ++ " to " ++ destination ++ "\n"
+ disk number→string 3
+ source number→string 2
+ destination number→string 1