From e688316f1709b72ad0625e579547e0cc7e377209 Mon Sep 17 00:00:00 2001 From: Eric Willigers Date: Sat, 23 May 2026 12:21:27 +1000 Subject: [PATCH] quayside-crew: define crane tuple [no important files changed] --- exercises/concept/quayside-crew/.docs/hints.md | 4 ++-- exercises/concept/quayside-crew/.docs/instructions.md | 6 +++--- .../quayside-crew/quayside-crew-tests.factor | 10 +++++----- .../quayside-crew/quayside-crew/quayside-crew.factor | 2 +- exercises/practice/atbash-cipher/.meta/example.factor | 2 +- exercises/practice/custom-set/.meta/generator.jl | 2 +- .../custom-set/custom-set/custom-set-tests.factor | 6 +++--- .../difference-of-squares/.meta/example.factor | 2 +- exercises/practice/line-up/.meta/example.factor | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/exercises/concept/quayside-crew/.docs/hints.md b/exercises/concept/quayside-crew/.docs/hints.md index 0c72974..5b14138 100644 --- a/exercises/concept/quayside-crew/.docs/hints.md +++ b/exercises/concept/quayside-crew/.docs/hints.md @@ -12,8 +12,8 @@ ## 3. `` -- Define the crane with `TUPLE: crane lock tonnage ;` so the - slots are named. +- The `crane` tuple (slots `lock` and `tonnage`) is already + declared in the exercise file. - Use `` (in [`concurrency.locks`][locks]) for the lock slot and `0` for the starting tonnage. `boa` constructs a tuple from the values on the stack in slot order. diff --git a/exercises/concept/quayside-crew/.docs/instructions.md b/exercises/concept/quayside-crew/.docs/instructions.md index 0694fe4..ab7bded 100644 --- a/exercises/concept/quayside-crew/.docs/instructions.md +++ b/exercises/concept/quayside-crew/.docs/instructions.md @@ -52,8 +52,8 @@ at the same time. ```factor -dup 35 swap hoist-crate -dup 17 swap hoist-crate +35 over hoist-crate +17 over hoist-crate tonnage>> . ! => 52 ``` @@ -66,7 +66,7 @@ hoist. ```factor -dup 35 swap hoist-crate +35 over hoist-crate crane-tonnage . ! => 35 ``` diff --git a/exercises/concept/quayside-crew/quayside-crew/quayside-crew-tests.factor b/exercises/concept/quayside-crew/quayside-crew/quayside-crew-tests.factor index 56cba4b..d9ae5d1 100644 --- a/exercises/concept/quayside-crew/quayside-crew/quayside-crew-tests.factor +++ b/exercises/concept/quayside-crew/quayside-crew/quayside-crew-tests.factor @@ -19,23 +19,23 @@ TASK: 3 ! a fresh crane each call — mutating one doesn't affect another { 5 0 } [ - dup 5 swap hoist-crate tonnage>> + 5 over hoist-crate tonnage>> tonnage>> ] unit-test TASK: 4 hoist-crate -{ 35 } [ dup 35 swap hoist-crate tonnage>> ] unit-test +{ 35 } [ 35 over hoist-crate tonnage>> ] unit-test { 52 } [ - dup 35 swap hoist-crate - dup 17 swap hoist-crate + 35 over hoist-crate + 17 over hoist-crate tonnage>> ] unit-test TASK: 5 crane-tonnage { 0 } [ crane-tonnage ] unit-test -{ 35 } [ dup 35 swap hoist-crate crane-tonnage ] unit-test +{ 35 } [ 35 over hoist-crate crane-tonnage ] unit-test TASK: 6 load-cargo { 32 } [ diff --git a/exercises/concept/quayside-crew/quayside-crew/quayside-crew.factor b/exercises/concept/quayside-crew/quayside-crew/quayside-crew.factor index faf07cb..8f8c053 100644 --- a/exercises/concept/quayside-crew/quayside-crew/quayside-crew.factor +++ b/exercises/concept/quayside-crew/quayside-crew/quayside-crew.factor @@ -7,7 +7,7 @@ IN: quayside-crew : weigh-all ( crates -- weights ) "unimplemented" throw ; -TUPLE: crane ; +TUPLE: crane lock tonnage ; : ( -- crane ) "unimplemented" throw ; diff --git a/exercises/practice/atbash-cipher/.meta/example.factor b/exercises/practice/atbash-cipher/.meta/example.factor index afb368d..0a07000 100644 --- a/exercises/practice/atbash-cipher/.meta/example.factor +++ b/exercises/practice/atbash-cipher/.meta/example.factor @@ -8,7 +8,7 @@ IN: atbash-cipher dup Letter? [ lower-char CHAR: a - CHAR: z swap - ] when ; : atbash-core ( phrase -- seq ) - [ dup Letter? swap digit? or ] filter + [ [ Letter? ] [ digit? ] bi or ] filter [ atbash-char ] map ; : encode ( phrase -- str ) diff --git a/exercises/practice/custom-set/.meta/generator.jl b/exercises/practice/custom-set/.meta/generator.jl index ade0ecc..5437787 100644 --- a/exercises/practice/custom-set/.meta/generator.jl +++ b/exercises/practice/custom-set/.meta/generator.jl @@ -23,7 +23,7 @@ function gen_test_case(case) return "{ $(bool_factor(exp)) }\n[ $(set_factor(inp["set1"])) $(set_factor(inp["set2"])) set= ]\nunit-test" elseif prop == "add" sorted = format_int_array(sort(collect(exp))) - return "{ $(sorted) }\n[ $(set_factor(inp["set"])) dup $(to_int_str(inp["element"])) swap adjoin members natural-sort ]\nunit-test" + return "{ $(sorted) }\n[ $(set_factor(inp["set"])) $(to_int_str(inp["element"])) over adjoin members natural-sort ]\nunit-test" end word = prop == "intersection" ? "intersect" : diff --git a/exercises/practice/custom-set/custom-set/custom-set-tests.factor b/exercises/practice/custom-set/custom-set/custom-set-tests.factor index 8ef3729..5d4fd64 100644 --- a/exercises/practice/custom-set/custom-set/custom-set-tests.factor +++ b/exercises/practice/custom-set/custom-set/custom-set-tests.factor @@ -122,17 +122,17 @@ unit-test "add to empty set" print { { 3 } } -[ dup 3 swap adjoin members natural-sort ] +[ 3 over adjoin members natural-sort ] unit-test "add to non-empty set" print { { 1 2 3 4 } } -[ { 1 2 4 } >custom-set dup 3 swap adjoin members natural-sort ] +[ { 1 2 4 } >custom-set 3 over adjoin members natural-sort ] unit-test "adding an existing element does not change the set" print { { 1 2 3 } } -[ { 1 2 3 } >custom-set dup 3 swap adjoin members natural-sort ] +[ { 1 2 3 } >custom-set 3 over adjoin members natural-sort ] unit-test "intersection of two empty sets is an empty set" print diff --git a/exercises/practice/difference-of-squares/.meta/example.factor b/exercises/practice/difference-of-squares/.meta/example.factor index c0bf39e..3648a3e 100644 --- a/exercises/practice/difference-of-squares/.meta/example.factor +++ b/exercises/practice/difference-of-squares/.meta/example.factor @@ -8,4 +8,4 @@ IN: difference-of-squares [1..b] [ sq ] map sum ; : difference-of-squares ( n -- m ) - dup square-of-sum swap sum-of-squares - ; + [ square-of-sum ] [ sum-of-squares ] bi - ; diff --git a/exercises/practice/line-up/.meta/example.factor b/exercises/practice/line-up/.meta/example.factor index 2235cfe..9a1e82a 100644 --- a/exercises/practice/line-up/.meta/example.factor +++ b/exercises/practice/line-up/.meta/example.factor @@ -9,5 +9,5 @@ IN: line-up if ; : format ( name number -- str ) - dup number>string swap ordinal-suffix append + [ number>string ] [ ordinal-suffix ] bi append "%s, you are the %s customer we serve today. Thank you!" sprintf ;