On Sat, Jul 2, 2022 at 12:21 PM Jacques Bailhache
<jacques.bailha...@gmail.com> wrote:
> 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)

Here's one approach:

ap=: {{ ({. {{ x`:6 y }} }.) x,y }}
I=: ]`''
K=: {{ if. 1<#y do. 1{.y else. K`y end. }}`''
S=: {{ if. 2<#y do. (((0{y) ap (2{y)) ap ((1{y) ap 2{y))`'' else. S`y end. }}`''
N=: 9:`''

a=: K
b=: I
c=: N

   (((S ap a) ap b) ap c) = (a ap c) ap (b ap c)
1

(Note that the result of N is not valid in an argument list for K or S.)

Note also that I have not implemented "parenthesis" here (I have not
implemented encapsulating a function with an incomplete argument list
as a single deferred function with deferred structure but without
immediate structure). The wikipedia writeup on SKI combinators refers
to binary trees, so I thought I should mention that.

I hope this helps,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to