From 26d42755d7057b03d5eb4497961f84790e1488c1 Mon Sep 17 00:00:00 2001 From: superseeker13 Date: Tue, 6 Aug 2024 20:03:05 -0400 Subject: [PATCH 1/5] Update core.fs Add forth implementation of ROLL --- lib/core.fs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/core.fs b/lib/core.fs index 475b49e..c4b8dfc 100644 --- a/lib/core.fs +++ b/lib/core.fs @@ -648,3 +648,10 @@ include ../shared/core.fs loop drop drop true then ; + +: roll ( x_u x_u-1 ... x_0 u -- x_u-1 ... x_0 x_u ) + dup 0= if + drop exit + then + swap >R + 1- recurse R> swap ; From 4b6e6106c5edd98f13f880336336a5bc37002ae4 Mon Sep 17 00:00:00 2001 From: superseeker13 Date: Tue, 6 Aug 2024 20:05:01 -0400 Subject: [PATCH 2/5] Create test-roll.fs --- test/core/test-roll.fs | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/core/test-roll.fs diff --git a/test/core/test-roll.fs b/test/core/test-roll.fs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/core/test-roll.fs @@ -0,0 +1 @@ + From 502594fa6a8c0fc7f0ff25b16e478c24c26e0ecf Mon Sep 17 00:00:00 2001 From: superseeker13 Date: Tue, 6 Aug 2024 20:05:15 -0400 Subject: [PATCH 3/5] Create test-roll.js --- test/core/test-roll.js | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/core/test-roll.js diff --git a/test/core/test-roll.js b/test/core/test-roll.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/core/test-roll.js @@ -0,0 +1 @@ + From 367564911e59924c7aafdb43ace9db95f4a3f00c Mon Sep 17 00:00:00 2001 From: superseeker13 Date: Tue, 6 Aug 2024 20:06:34 -0400 Subject: [PATCH 4/5] Update test-roll.js --- test/core/test-roll.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/core/test-roll.js b/test/core/test-roll.js index 8b13789..e07fb8e 100644 --- a/test/core/test-roll.js +++ b/test/core/test-roll.js @@ -1 +1,6 @@ +const gb = require("../gbtest")(__filename); +test("roll", () => { + gb.run(); + expect(gb.stack).toEqual([0x02, 0x01, 0x03]); +}); From 3484aa1f2b3c8a3501d5a57534dd12dbca4f2558 Mon Sep 17 00:00:00 2001 From: superseeker13 Date: Tue, 6 Aug 2024 20:07:33 -0400 Subject: [PATCH 5/5] Update test-roll.fs --- test/core/test-roll.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/test-roll.fs b/test/core/test-roll.fs index 8b13789..0cdc821 100644 --- a/test/core/test-roll.fs +++ b/test/core/test-roll.fs @@ -1 +1 @@ - +: main #1 #2 #3 #2 roll #1 roll #0 roll ;