I believe this to be correct, where code and data are arguments consisting of binary trees constructed from pairs or can be 'nil:
(define apply
(lambda (code data)
(match (code . data)
[('nil . z) (z . 'nil)] ; rule 0a - construct stem
[((y . 'nil) . z) (y . z)] ; rule 0b - construct fork
[('nil . y) . z) y] ; rule 1 - K combinator
[(((x . 'nil) . y) . z) (apply (apply x z) (apply y z))] ; rule 2 - S Combinator
[(((w . x) . y) . 'nil) w] ; rule 3a - pattern match case of data is leaf
[(((w . x) . y) . (u . 'nil)) (apply x u)] ; rule 3b - pattern match case of data is stem
[(((w . x) . y) . (u . v)) (apply (apply y u) v)] ; rule 3c - pattern match case of data is fork
)))
https://olydis.medium.com/a-visual-introduction-to-tree-calc...