Re: [stack] Combining Combinators
Manfred Von Thun <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative,gmane.spam.detected |
|---|---|
| Message-ID | <C2B97842.A76%[email protected]> |
On 5/7/07 4:42 AM, "kuwabatake" <[email protected]> wrote: > >> > At level one there are functions which take zero level entities >> > as arguments. At level two there are combinators which take >> > level one entities as arguments but cannot take level zero >> > entities as arguments. Examples: dip, nullary, map, filter, fold. >> > At level three there would be functions which take level two >> > entities as arguments but cannot take level one entities as >> > arguments. The last sentence was supposed to mean: but cannot take ANY level one entities as arguments. (And I really intended: and cannot take any level zero entities as arguments.) > Interesting. > > I propose a function called `compose'. It takes a quoted combinator > [C1] and alters that combinator to expect TWO functions on top of the > stack, compose them, and then execute C1. > > For example: > [1 2 3] [2 *] [1 +] [map] compose i > => [3 5 7] > ['a] 123 ['b] [cons] [dip] compose i > => ['a 'b] > > This can be written in Joy as follows: > compose == [concat] swap concat > Your compose is not a combinator, of course, it is a level one entity. So I conclude that you really intend as your example combinator the combination: compose i. Let us see. Suppose I replace the [map] in your example by [cons]: [1 2 3] [2 *] [1 +] [cons] compose i == [1 2 3] [2 *] [1 +] [cons] [concat] swap concat i == [1 2 3] [2 *] [1 +] [concat] [cons] concat i == [1 2 3] [2 *] [1 +] [[concat] cons] i == [1 2 3] [2 *] [1 +] [concat] cons == [1 2 3] [2 *] [[1 +] concat] This is a perfectly meaningful program. (Incidentally, the first two arguments, [1 2 3] and [2 *] are not being used here, they just stay there, but that is OK.) But: here is at least one quoted level one function, [cons], which can serve as the argument to your combination: compose i. So this example shows that your combination is not a level three entity of the kind I was looking for. > Note that applying compose to a non-combinator is not `meaningful': > [+] compose > => [concat +] > it results in the meaningless function [concat +] which will throw an > error no matter what kind of input you give it. > See my qualification at the top: ANY level one entities.. > I think we can construct other third- and even higher-level functions > using a similar technique. Of course, they are all really functions > stack->stack at heart; the distinction comes with the fact that > third-level functions only make sense when they modify second-level > functions (combinators). > ~Daniel As far as I can see, it is still an open question, although after trying and failing for a long time one is tempted to conclude that the search must fail. But a proof of impossibility is needed, not a failed search. > Nice try, Daniel. Welcome to the group, and stay with us. > - Manfred [Non-text portions of this message have been removed]