interpolate: number stack arguments from top of stack.

db4
John Benediktsson 2015-04-20 11:10:27 -07:00
parent c0c54d8919
commit 162f75a7e5
3 changed files with 5 additions and 5 deletions

View File

@ -7,7 +7,7 @@ HELP: interpolate
{ $examples
{ $example
"USING: interpolate ;"
"\"Bob\" \"Alice\" \"Hi ${0}, it's ${1}.\" interpolate"
"\"Bob\" \"Alice\" \"Hi ${1}, it's ${0}.\" interpolate"
"Hi Bob, it's Alice."
}
{ $example

View File

@ -3,9 +3,9 @@
USING: interpolate io.streams.string namespaces tools.test locals ;
IN: interpolate.tests
{ "A B" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
{ "B A" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
{ "C A" } [ "A" "B" "C" "${2} ${0}" interpolate>string ] unit-test
{ "A B" } [ "A" "B" "${1} ${0}" interpolate>string ] unit-test
{ "B A" } [ "A" "B" "${0} ${1}" interpolate>string ] unit-test
{ "C A" } [ "A" "B" "C" "${0} ${2}" interpolate>string ] unit-test
{ "Hello, Jane." } [
"Jane" "name" set

View File

@ -44,7 +44,7 @@ TUPLE: stack-var n ;
name>> quot call '[ _ @ present write ]
] [
dup stack-var? [
n>> vars swap - 1 + '[ _ npick present write ]
n>> 1 + '[ _ npick present write ]
] [
'[ _ write ]
] if