aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/content.template2
-rwxr-xr-xdocs/gensamples.sh15
-rwxr-xr-xdocs/genstd.sh2
-rw-r--r--samples/euler/001.bruijn2
-rw-r--r--samples/euler/006.bruijn2
-rw-r--r--samples/io/echo.bruijn9
-rw-r--r--samples/io/random.bruijn6
-rw-r--r--samples/io/reverse.bruijn7
-rw-r--r--samples/rosetta/Universal_Lambda_Machine.bruijn (renamed from samples/rosetta/universal_lambda_machine.bruijn)0
-rw-r--r--samples/rosetta/ackermann-function.bruijn (renamed from samples/rosetta/ackermann.bruijn)0
-rw-r--r--samples/rosetta/fizzBuzz.bruijn (renamed from samples/rosetta/fizzbuzz.bruijn)0
-rw-r--r--samples/rosetta/hailstone_sequence.bruijn (renamed from samples/rosetta/hailstone.bruijn)0
-rw-r--r--samples/rosetta/special_factorials.bruijn (renamed from samples/rosetta/special_factorial.bruijn)0
-rw-r--r--samples/rosetta/validate_international_securities_identification_number.bruijn (renamed from samples/rosetta/validate_isin.bruijn)0
14 files changed, 18 insertions, 27 deletions
diff --git a/docs/content.template b/docs/content.template
index 470acb4..57cbd47 100644
--- a/docs/content.template
+++ b/docs/content.template
@@ -8,7 +8,7 @@
<title>bruijn std/NAME</title>
</head>
<body>
- <h1>NAME</h1>
+ <h1>NAME</h1> INFO
<pre>
<code class="language-bruijn">
CONTENT
diff --git a/docs/gensamples.sh b/docs/gensamples.sh
index 1734e0a..174d28d 100755
--- a/docs/gensamples.sh
+++ b/docs/gensamples.sh
@@ -17,8 +17,21 @@ for file in $files; do
fi
filename=$(sed s@/@_@g <<<"$name")
links="$links\n<li><a href="$filename.html">$name</a></li>"
+
+ if [ "$prefix" = "euler" ]; then
+ info="<a href='https://projecteuler.net/problem=$(basename "$name" .bruijn)'>Problem description</a>"
+ elif [ "$prefix" = "aoc" ]; then
+ year=$(cut -c5-8 <<<"$name")
+ day=$(cut -c10-11 <<<"$name" | sed 's/^0*//')
+ info="<a href='https://adventofcode.com/$year/day/$day'>Problem description</a>"
+ elif [ "$prefix" = "rosetta" ]; then
+ info="<a href='https://rosettacode.org/wiki/$(basename "$name" .bruijn)'>Problem description</a>"
+ else
+ info=""
+ fi
+
awk 'NR==FNR { gsub("<", "\\&lt;", $0); gsub(">", "\\&gt;", $0); a[n++]=$0; next } /CONTENT/ { for (i=0;i<n;++i) print a[i]; next } 1' "$file" content.template >"samples/$filename.html"
- sed -i -e "s@NAME@$name@g" "samples/$filename.html"
+ sed -i -e "s@NAME@$name@g" -e "s@INFO@$info@g" "samples/$filename.html"
done
sed -e "s@LINKS@$links@g" samples.template >samples/index.html
diff --git a/docs/genstd.sh b/docs/genstd.sh
index e290063..f2c0dd4 100755
--- a/docs/genstd.sh
+++ b/docs/genstd.sh
@@ -22,7 +22,7 @@ for file in $files; do
ntests=$(grep -cP "^:test" "$file" || true)
links="$links\n<li><span class='com'>:import</span> <a href=$filename.html>$(basename "$name" .bruijn)</a> <span class='stats'>($ndefs definitions, $ntests tests)</span></li>"
awk 'NR==FNR { gsub("<", "\\&lt;", $0); gsub(">", "\\&gt;", $0); a[n++]=$0; next } /CONTENT/ { for (i=0;i<n;++i) print a[i]; next } 1' "$file" content.template >"std/$filename.html"
- sed -i -e "s@NAME@$name@g" "std/$filename.html"
+ sed -i -e "s@NAME@$name@g" -e "s@INFO@@g" "std/$filename.html"
tot_ndefs=$((tot_ndefs + ndefs))
tot_ntests=$((tot_ntests + ntests))
diff --git a/samples/euler/001.bruijn b/samples/euler/001.bruijn
index 1678b58..72b605f 100644
--- a/samples/euler/001.bruijn
+++ b/samples/euler/001.bruijn
@@ -3,7 +3,7 @@
:import std/Math .
solve [∑(crit <#> ({ (+0) → --0 }))]
- crit φ m ((\mod (+3)) → zero?) ((\mod (+5)) → zero?)
+ crit [ψ m ((mod 0) → zero?) (+3) (+5)]
:test ((solve (+10)) =? (+23)) ([[1]])
diff --git a/samples/euler/006.bruijn b/samples/euler/006.bruijn
index 75582c7..4de0d10 100644
--- a/samples/euler/006.bruijn
+++ b/samples/euler/006.bruijn
@@ -1,7 +1,7 @@
:import std/Combinator .
:import std/Math .
-solve [|(sum-of-squares - square-of-sum)]
+solve [square-of-sum - sum-of-squares]
sum-of-squares ∑ (+1) → 0 | (\pow (+2))
square-of-sum (∑ (+1) → 0 | i) ** (+2)
diff --git a/samples/io/echo.bruijn b/samples/io/echo.bruijn
deleted file mode 100644
index b17bda1..0000000
--- a/samples/io/echo.bruijn
+++ /dev/null
@@ -1,9 +0,0 @@
-# "echo text | bruijn echo.bruijn"
-
-:import std/Monad .
-
-# returning the binary encoded argument ⇒ echo
-main [0]
-
-# alternative using monads
-main* read >>= return
diff --git a/samples/io/random.bruijn b/samples/io/random.bruijn
deleted file mode 100644
index ab23f91..0000000
--- a/samples/io/random.bruijn
+++ /dev/null
@@ -1,6 +0,0 @@
-# "cat /dev/random | bruijn random.bruijn"
-# prints number between 0 and 255 - stdin laziness!
-
-:import std/Pair .
-
-main [^0]
diff --git a/samples/io/reverse.bruijn b/samples/io/reverse.bruijn
deleted file mode 100644
index 7a3553f..0000000
--- a/samples/io/reverse.bruijn
+++ /dev/null
@@ -1,7 +0,0 @@
-# "echo tacocat | bruijn reverse.bruijn"
-
-:import std/List .
-
-# stdin is encoded as binary numbers in a list
-# reversing the list reverses the input!
-main [<~>0]
diff --git a/samples/rosetta/universal_lambda_machine.bruijn b/samples/rosetta/Universal_Lambda_Machine.bruijn
index 60ba551..60ba551 100644
--- a/samples/rosetta/universal_lambda_machine.bruijn
+++ b/samples/rosetta/Universal_Lambda_Machine.bruijn
diff --git a/samples/rosetta/ackermann.bruijn b/samples/rosetta/ackermann-function.bruijn
index c0689f1..c0689f1 100644
--- a/samples/rosetta/ackermann.bruijn
+++ b/samples/rosetta/ackermann-function.bruijn
diff --git a/samples/rosetta/fizzbuzz.bruijn b/samples/rosetta/fizzBuzz.bruijn
index 7f61704..7f61704 100644
--- a/samples/rosetta/fizzbuzz.bruijn
+++ b/samples/rosetta/fizzBuzz.bruijn
diff --git a/samples/rosetta/hailstone.bruijn b/samples/rosetta/hailstone_sequence.bruijn
index d98c235..d98c235 100644
--- a/samples/rosetta/hailstone.bruijn
+++ b/samples/rosetta/hailstone_sequence.bruijn
diff --git a/samples/rosetta/special_factorial.bruijn b/samples/rosetta/special_factorials.bruijn
index 588a95f..588a95f 100644
--- a/samples/rosetta/special_factorial.bruijn
+++ b/samples/rosetta/special_factorials.bruijn
diff --git a/samples/rosetta/validate_isin.bruijn b/samples/rosetta/validate_international_securities_identification_number.bruijn
index 7608ed5..7608ed5 100644
--- a/samples/rosetta/validate_isin.bruijn
+++ b/samples/rosetta/validate_international_securities_identification_number.bruijn