Fix scalar_type in all programs.

There was a problem stemming from the flexibility of scalars, which can be a list or a list of lists.