I am trying to implement combinatory logic in J. I succeeded for combinators I and K :
ap =: 4 : 'x @.(]@1) y' I =: ]`] I ap 5 5 K =: ]`(3 : ']`(]@y)') (K ap 6) ap 8 6 but I don't see how to implement the combinator S. It must satisfy : ((S ap a) ap b) ap c = (a ap c) ap (b ap c) For example : ((S ap add) ap double) ap 10 = (add ap 10) ap (double ap 10) where add and double are defined as follow : add =: ]`(3 : ']`(+ & y)') (add ap 3) ap 5 8 double =: ]`+: double ap 10 20 (add ap 10) ap (double ap 10) 30 I found that (S ap add) ap double = ]`((add & ap) ap (double & ap)) : (]`((add & ap) ap (double & ap))) ap 10 30 The next steps consists in defining S ap add by abstracting double from this expression, but I don't see how to do this. Does someone have an idea ? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm