From 9ab322751a732d8cbc1ddf4f2ecf5022d7242baa Mon Sep 17 00:00:00 2001 From: Marijn Besseling Date: Sun, 7 Sep 2025 20:56:09 +0200 Subject: WIP migration --- Blog/Components/Pages/Concat.razor | 138 +++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 Blog/Components/Pages/Concat.razor (limited to 'Blog/Components/Pages/Concat.razor') diff --git a/Blog/Components/Pages/Concat.razor b/Blog/Components/Pages/Concat.razor new file mode 100644 index 0000000..856d4e0 --- /dev/null +++ b/Blog/Components/Pages/Concat.razor @@ -0,0 +1,138 @@ +@page "/Concat" +Concatenator + +
+

A "concatenative language"

+
+ + +
+
+
+
+ +
+ Predefined operations +
+ dup +

Duplicates the top value on the stack

+
+ [1, 2, 3] + dup +
+
+ [1, 1, 2, 3] + +
+
+ +
+ drop +

Drops the top value on the stack

+
+ [1, 2, 3] + drop +
+
+ [2, 3] + +
+
+ +
+ swap +

Swaps the top two values on the stack

+
+ [1, 2, 3] + swap +
+
+ [2, 1, 3] + +
+
+ +
+ skip +

Skips forward in the program by the amount on the top of the stack. + If the value on the top of the stack is 0 or negative, + the value is dropped and the program does not skip ahead. +

+
+ [1, 2, 3] + skip drop dup +
+
+ [2, 3] + dup +
+
+ [2, 2, 3] + +
+ Or +
+ [-1, 2, 3] + skip drop dup +
+
+ [2, 3] + drop dup +
+
+ [3] + dup +
+
+ [3, 3] + +
+
+ +
+ : word ... ; +

Creates a new definition.

+

Example: ": double 2 * ;" defines a new word called double. Any subsequent mention of double will + replace the word with its definition.

+
+ [] + : double 2 * ; 3 double +
+
+ [] + 3 double +
+
+ [3] + double +
+
+ [3] + 2 * +
+
+ [2, 3] + * +
+
+ [6] <== + +
+
+
+
+ Example programs +
+ Factorial + + Replace program + +
+                : counter   dup 2 swap - ;
+                : !   dup 1 - counter skip ! * ;
+                7 !
+            
+
+
+
\ No newline at end of file -- cgit v1.2.3