Next: , Previous: Reference Implementations, Up: Reference Implementations


B.1 Pairwise

This silly code fragment is mentioned in Reduce, in the discussion of reduce, and is provided as an example of a solution to equations E1 to E3. It is written in the style of a higher order function, in that it takes a function f as an argument and returns another function, [[pairwise]] f as a result.

     
     self     = left
     argument = right
     head     = left
     tail     = right
     
     pairwise =
     
     compose(
        refer,
        compose(
           bu(
              conditional,
              conditional(argument,compose(tail,argument),constant nil)),
           couple(
              (hired couple)(
                 (hired compose)(
                    identity,
                    constant (hired fan head)(
                       argument,
                       compose(tail,argument))),
                 constant (hired meta)(
                    self,
                    compose(tail,compose(tail,argument)))),
              constant argument)))
     

To see how this works, one should evaluate it symbolically with an unknown f, which will result in some silly pseudocode, and then evaluate that symbolically with some sample lists.