Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #3506
| Newsgroups | comp.lang.postscript |
|---|---|
| Date | 2020-04-16 23:02 -0700 |
| References | <1586905414.bystand@zzo38computer.org> <0d5b203a-884d-4752-95c3-9e5ce46197dd@googlegroups.com> |
| Message-ID | <b6d38855-707a-422a-a1ce-c0795f4bc40c@googlegroups.com> (permalink) |
| Subject | Re: Some general purpose PostScript procedures - multiget scanpath straccum strfinish |
| From | luser droog <luser.droog@gmail.com> |
On Wednesday, April 15, 2020 at 12:30:27 AM UTC-5, luser droog wrote:
> On Tuesday, April 14, 2020 at 6:17:41 PM UTC-5, ne...@zzo38computer.org.invalid wrote:
> > As part of TeXnicard, I wrote many PostScript procedures. Many of them are
> > not usable outside of TeXnicard, but a few of them are. Maybe you might
> > find some of them useful; I don't know. But I found it useful.
> >
> > The multiget procedure is used to retrieve multiple entries from a
> > dictionary, and put them into an array. It might be useful with
> > writeobject or with some other things too. (Unfortunately, this
> > implementation does not work with objects other than dictionaries, since
> > known is only compatible with dictionaries.)
> >
> > /multiget { %( dict array -- array )
> > << >> begin
> > exch /A exch def
> > /B 1 index length def
> > {
> > A 1 index known {
> > A exch get
> > } {
> > pop null
> > } ifelse
> > } forall
> > B array astore
> > end
> > } bind def
> >
>
> Interesting stuff. I came up with a shorter version of this which doesn't
> need a local dict. But it doesn't work with bind since it modifies the
> internal proc.
>
> /map { [ 3 1 roll forall ] } def
> /mg {
> { DICT exch { get } stopped { pop pop null } if }
> dup 0 5 -1 roll put map
> } def
I got it to work with bind. Gotta curry a new array instead of modifying.
/mg { % dict [keys] - [values]
exch
{ exch { get } stopped { pop pop null } if }
/exec cvx
3 array astore cvx
map
} bind def
Back to comp.lang.postscript | Previous | Next — Previous in thread | Find similar
Some general purpose PostScript procedures - multiget scanpath straccum strfinish news@zzo38computer.org.invalid - 2020-04-14 16:17 -0700
Re: Some general purpose PostScript procedures - multiget scanpath straccum strfinish luser droog <luser.droog@gmail.com> - 2020-04-14 22:30 -0700
Re: Some general purpose PostScript procedures - multiget scanpath straccum strfinish luser droog <luser.droog@gmail.com> - 2020-04-16 23:02 -0700
csiph-web