Version 8 of s

Updated 2002-12-17 09:57:22

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}

Category Concept | Arts and crafts of Tcl-Tk programming