Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2083
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Carlos <angus@quovadis.com.ar> |
| Newsgroups | comp.lang.postscript |
| Subject | Re: map and higher order functions |
| Date | Thu, 30 Oct 2014 19:55:24 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 42 |
| Message-ID | <20141030195524.77fe473f@samara.DOMA> (permalink) |
| References | <20141030172728.0983c6bc@samara.DOMA> <MPG.2ebc7e4067cb96d19898cf@usenet.plus.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | mx02.eternal-september.org; posting-host="f4fcdd466dcf73c2e008a0d28a614b04"; logging-data="1376"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/NhnAHuqbBGzguNwWq2ngrnAlwM/+ywMQ=" |
| X-Newsreader | Claws Mail 3.10.1 (GTK+ 2.24.24; x86_64-pc-linux-gnu) |
| Cancel-Lock | sha1:sqKQHSBlJTCjsV+1gaNOVWqK5g0= |
| Xref | csiph.com comp.lang.postscript:2083 |
Show key headers only | View raw
[ken <ken@spamcop.net>, 2014-10-30 16:57]
> In article <20141030172728.0983c6bc@samara.DOMA>,
> angus@quovadis.com.ar says...
> >
> > How would you implement map and other higher order functions
> > (procedures taking one or more procedures)?
>
> I'm not sure what your 'map' function is intended to do, but...
This is what it's intended to do:
GS>[ 1 2 3 4 ] { 1 add } map ==
[2 3 4 5]
Inside map, I have to exec the proc ({ 1 add } in this case) without
having anything on the stack. Otherwise, this
GS> 3 [ 1 2 3 4 ] { 1 index add } map ==
[4 5 6 7]
wouldn't work, since "1 index" would retrieve some value used
internally by map, and not what the user expects.
I can't also simply use an entry in userdict, because it would get
clobbered if the function re-enters, and this would fail:
GS>[ [ 1 2 3 ] [ 4 5 6 ] ] { { 1 add } map } map ==
[[2 3 4] [5 6 7]]
Nor can I have anything on the dictionary stack (using "n dict
begin ... end" to hold "local variables"), because the user might
execute a "def" inside the procedure, and the entry would be stored in
the wrong dictionary.
I'd like to know what the options are to solve this problem.
I hope it is clearer now.
> [...]
--
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
map and higher order functions Carlos <angus@quovadis.com.ar> - 2014-10-30 17:27 +0100
Re: map and higher order functions ken <ken@spamcop.net> - 2014-10-30 16:57 +0000
Re: map and higher order functions Carlos <angus@quovadis.com.ar> - 2014-10-30 19:55 +0100
Re: map and higher order functions ken <ken@spamcop.net> - 2014-10-31 12:17 +0000
Re: map and higher order functions Ross Presser <rpresser@gmail.com> - 2014-10-30 20:30 -0700
Re: map and higher order functions Carlos <angus@quovadis.com.ar> - 2014-11-01 23:58 +0100
Re: map and higher order functions luser- -droog <mijoryx@yahoo.com> - 2014-10-30 22:56 -0700
Re: map and higher order functions Carlos <angus@quovadis.com.ar> - 2014-11-02 00:15 +0100
Re: map and higher order functions luser- -droog <mijoryx@yahoo.com> - 2014-11-15 00:43 -0800
Re: map and higher order functions Carlos <angus@quovadis.com.ar> - 2014-11-16 01:37 +0100
Re: map and higher order functions luser- -droog <mijoryx@yahoo.com> - 2014-11-21 00:17 -0800
Re: map and higher order functions luser- -droog <mijoryx@yahoo.com> - 2015-02-27 00:59 -0800
csiph-web