From eef357ebc10246da0da3c8bce427991eeb3f1dce Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Sun, 16 Aug 2026 15:21:39 -0500 Subject: add a logo, changes to css, format older articles --- reversible.html | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'reversible.html') diff --git a/reversible.html b/reversible.html index 378045f..24b5b87 100644 --- a/reversible.html +++ b/reversible.html @@ -2,11 +2,8 @@
- -So remember in math class when you learned to take the inverse of a function?
-For example, say you have y = 3*x + 6.
You can take the inverse by solving for x. In this case, the inverse of our function is x = y/3 - 2.
The idea behind reversible programming is that there's a specific way to write your code such that it can automatically compute the inverse.
+
+ So remember in math class when you learned to take the inverse of a function?
+ For example, say you have y = 3*x + 6.
+ You can take the inverse by solving for x.
+ In this case, the inverse of our function is x = y/3 - 2.
+ The idea behind reversible programming is that there's a specific way to write your code such that it can automatically compute the inverse.
+
This has some wild implications:
up script automatically gives you your down script)up script automatically gives you your down script)- These are just a few of the crazy things you could theoretically do with Reversible Programming. + These are just a few of the crazy things you could theoretically do with reversible programming. But how does it actually work?
@@ -58,7 +58,7 @@
As a nice starter, let's write a block that would compute addition.
- We can model this with a struct and an impl of the Rev trait.
+ We can model this with a struct and an impl of the trait.
struct Addition <A > {
amount : A
@@ -84,7 +84,7 @@
While the generics might look scary, this is just saying "the input and output can be any type that you can add and subtract with."
- Honestly these are light work compared to what's coming up.
+ Honestly these are light work compared to what's coming up.
Oh, and it will look nicer if we have an easy way to construct an Addition block:
fn plus <A >(amount : A ) -> Addition <A > {
@@ -95,7 +95,7 @@
fn main () {
let operation = plus (5 );
- println! ("{}" , operation .forward (6 )); // prints 11 (6 + 5 = 11)
+ println! ("{}" , operation .forward (6 )); // prints 11 (6 + 5 = 11)
println! ("{}" , operation .reverse (11 )); // prints 6 (11 - 5 = 6)
}
@@ -103,14 +103,14 @@
trait impl said.
I've implemented a few more in the source code:
- neg() negates a number
- times(x) multiplies a number by x
- discrete(x: Vec<(A, B)>) creates a reversible block out of a set of discrete inputs and outputs.
+ neg () negates a number
+ times (x) multiplies a number by x
+ discrete (x: Vec <(A , B )>) creates a reversible block out of a set of discrete inputs and outputs.
First Combinators
- The first combinator we'll implement is Pipe.
+ The first combinator we'll implement is Pipe .
This takes in two Revs and and makes one that applies them in sequential order.
struct Pipe <X , Y >(X , Y );
@@ -132,7 +132,7 @@
}
- Additionally, we'll implement Inverse (not to be confused with .reverse()).
+ Additionally, we'll implement Inverse (not to be confused with .reverse ()).
This flips the forward and reverse methods.
struct Inverse <X >(X );
@@ -194,7 +194,7 @@
Under
- under is a higher order combinator, which means it's implemented in terms of other combinators.
+ under is a higher order combinator, which means it's implemented in terms of other combinators.
Under basically says "do a thing, do another thing, then undo the first thing.
With this foundation built up, we can implement it quite easily:
--
cgit v1.3.1