Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions exercises/concept/quayside-crew/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

## 3. `<crane>`

- 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 `<lock>` (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.
Expand Down
6 changes: 3 additions & 3 deletions exercises/concept/quayside-crew/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ at the same time.

```factor
<crane>
dup 35 swap hoist-crate
dup 17 swap hoist-crate
35 over hoist-crate
17 over hoist-crate
tonnage>> .
! => 52
```
Expand All @@ -66,7 +66,7 @@ hoist.

```factor
<crane>
dup 35 swap hoist-crate
35 over hoist-crate
crane-tonnage .
! => 35
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ TASK: 3 <crane>

! a fresh crane each call — mutating one doesn't affect another
{ 5 0 } [
<crane> dup 5 swap hoist-crate tonnage>>
<crane> 5 over hoist-crate tonnage>>
<crane> tonnage>>
] unit-test

TASK: 4 hoist-crate
{ 35 } [ <crane> dup 35 swap hoist-crate tonnage>> ] unit-test
{ 35 } [ <crane> 35 over hoist-crate tonnage>> ] unit-test
{ 52 }
[
<crane>
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> crane-tonnage ] unit-test
{ 35 } [ <crane> dup 35 swap hoist-crate crane-tonnage ] unit-test
{ 35 } [ <crane> 35 over hoist-crate crane-tonnage ] unit-test

TASK: 6 load-cargo
{ 32 } [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ IN: quayside-crew
: weigh-all ( crates -- weights )
"unimplemented" throw ;

TUPLE: crane ;
TUPLE: crane lock tonnage ;

: <crane> ( -- crane )
"unimplemented" throw ;
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/atbash-cipher/.meta/example.factor
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/custom-set/.meta/generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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" :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ unit-test

"add to empty set" print
{ { 3 } }
[ <custom-set> dup 3 swap adjoin members natural-sort ]
[ <custom-set> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 - ;
2 changes: 1 addition & 1 deletion exercises/practice/line-up/.meta/example.factor
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;