The S combinator is a sort-of generalised function application from combinator theory, the other most basic one being K.
proc S {f g x} { $f $x [$g $x] }
See Hot curry or Combinator engine for much more.
[Can someone provide some context here on this page as to how this would be used in the real world?]
RS: It certainly is less evidently usable than K, but rather of theoretical interest (like e.g. particle physics) - one of the smallest building blocks of functions. You can for example compose identity out of S and two instances of K:
I = S K K
but in the "real Tcl world" one would of course code identity (which is useful at times) as
proc I x {set x}
[PT] writes: Note that to do the above you need to define K in such a manner that it has optional arguments. To actually do this in Tcl we can do:
proc K {a args} {set a} proc S {a b c} {$a $c [$b $c]} proc I {a} {S K K $a}