examples: rename a word to make an example a little clearer
FossilOrigin-Name: 4b087b4d34742d0fed2348cebe215d8d4ae16c3edccf8b5a862c66d33cc291f2
This commit is contained in:
parent
d696221f2a
commit
4bf3b26d3b
1 changed files with 6 additions and 6 deletions
|
@ -7,14 +7,14 @@ combinator, but this can lead to ugly code.
|
|||
Consider:
|
||||
|
||||
'Counter var
|
||||
:test (...n-v)
|
||||
:average (...n-v)
|
||||
&Counter [ #0 !Counter
|
||||
[ + &Counter v:inc ] times @Counter / ] v:preserve ;
|
||||
:run-tests
|
||||
#0 !Counter
|
||||
#1 #2 #3 #4 #3 test n:put nl &Counter v:inc
|
||||
#10 #20 #30 #40 #3 test n:put nl &Counter v:inc
|
||||
#11 #21 #31 #41 #3 test n:put nl &Counter v:inc
|
||||
#1 #2 #3 #4 #3 average n:put nl &Counter v:inc
|
||||
#10 #20 #30 #40 #3 average n:put nl &Counter v:inc
|
||||
#11 #21 #31 #41 #3 average n:put nl &Counter v:inc
|
||||
@Counter n:put sp '_tests_finished s:put nl ;
|
||||
|
||||
run-tests
|
||||
|
@ -23,13 +23,13 @@ The code implemented here allows for wrapping the most recent
|
|||
word within a `v:preserve` clause, letting the above definition
|
||||
of `test` become:
|
||||
|
||||
:test (...n-v)
|
||||
:average (...n-v)
|
||||
#0 !Counter [ + &Counter v:inc ] times @Counter / ;
|
||||
&Counter make-local
|
||||
|
||||
And if you need multiple variables to be localized:
|
||||
|
||||
:test ... ;
|
||||
:average ... ;
|
||||
{ &Array &Of &Variables } locals
|
||||
|
||||
# The Code
|
||||
|
|
Loading…
Reference in a new issue