procedure swap(s)
   static labels, trans, max
   initial {
      labels := "12"
      trans := "21"
      max := *labels
      trans := swap(string(&cset))
      labels := string(&cset)
      max := *labels
      }
   if *s <= max then
      return map(left(trans,*s),left(labels,*s),s)
   else return swap(left(s,*s - max)) ||
      map(trans,labels,right(s,max))
end
