Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #2083
| From | Carlos <angus@quovadis.com.ar> |
|---|---|
| Newsgroups | comp.lang.postscript |
| Subject | Re: map and higher order functions |
| Date | 2014-10-30 19:55 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <20141030195524.77fe473f@samara.DOMA> (permalink) |
| References | <20141030172728.0983c6bc@samara.DOMA> <MPG.2ebc7e4067cb96d19898cf@usenet.plus.net> |
[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