The variable arguments are interpolated in reverse order (ie. the
normal top-of-stack down-ward way). I'm not sure how useful it
actually is. Should it take an array for the variable arguments and
take them left-to-right?
On 14/3/23 11:05, luser droog wrote:
The variable arguments are interpolated in reverse order (ie. theI love this game! :-)
normal top-of-stack down-ward way). I'm not sure how useful it
actually is. Should it take an array for the variable arguments and
take them left-to-right?
Here's a slightly different implementation that uses search instead of testing each character.
dup/stringtype eq { pop exit } if
dup/nametype eq { pop (/) exch dup length string cvs exit } if dup/operatortype eq 1 index/integertype eq or 1 index/realtype eq or
{ pop 20 string cvs exit }
if
dup/booleantype eq { pop {(true)}{(false)} ifelse exit } if
dup/marktype eq { pop (MARK) exit } if
dup/nulltype eq { pop (-) exit } if
dup/savetype eq { pop (-save-) exit } if
dup/filetype eq { pop (-file-) exit } if
dup/fonttype eq { pop (-font-) exit } if
dup/gstatetype eq { pop (-gstate-) exit } if
/sprintf_element cvx errordict/typecheck get exec
def
On Wednesday, March 15, 2023 at 2:46:26 AM UTC-5, David Newall wrote:
On 14/3/23 11:05, luser droog wrote:
The variable arguments are interpolated in reverse order (ie. theI love this game! :-)
normal top-of-stack down-ward way). I'm not sure how useful it
actually is. Should it take an array for the variable arguments and
take them left-to-right?
Here's a slightly different implementation that uses search instead of testing each character.Very cool. That ought to run faster and use less memory.
/convert2 {def
On Thursday, March 23, 2023 at 10:54:51 AM UTC-5, luser droog wrote:
On Wednesday, March 15, 2023 at 2:46:26 AM UTC-5, David Newall wrote:
On 14/3/23 11:05, luser droog wrote:
The variable arguments are interpolated in reverse order (ie. the normal top-of-stack down-ward way). I'm not sure how useful it actually is. Should it take an array for the variable arguments and take them left-to-right?I love this game! :-)
Here's a slightly different implementation that uses search instead of testing each character.Very cool. That ought to run faster and use less memory.
A little further inspiration. I first wanted to bust it up into smaller re-usable
functions. This has the disadvantage of creating and discarding more intermediate arrays, but oh well. Then I re-tooled it to use search instead of going char by char, but now it uses more intermediate data.
I'd be tempted to pull these out into a separate dictionary.exec
/_sprintf_dict <<
/stringtype{ pop exit }
/nametype{ pop (/) exch dup length string cvs exit }
...
/default{ pop (-unsupported-type-) exit }
{def
...
//_sprintf_dict 1 index type 2 copy known not {pop/default} if get
...
}
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (0 / 16) |
Uptime: | 107:25:02 |
Calls: | 6,700 |
Files: | 12,232 |
Messages: | 5,348,419 |