the merge labels function

Now, so far virtually all of the operators have been literal operators. The only two non-literal operators I have used are "pick-elt" and "apply()".
Today, briefly mention merge-labels().

Does pretty much what it says:
sa: merge-labels(|a> + |b> + |c>)
|abc>
ie, it merges the labels of the kets in the superposition into one ket.
Simple, but turns out to be relatively useful.

There is a hidden problem though!
Kets in superpositions add, so for example:
sa: merge-labels(|a> + |b> + |c> + |a> + |a>)
|abc>
When you might legitimately expect |abcaa>.

We can't currently solve this, but I'm thinking of promoting merge-labels to a built in feature of the parser.
Maybe using _ to separate kets.
eg, something like:
sa: |a> _ |b> _  |c> _ |a> _ |a>
returning:
|abcaa>
That would certainly be much cleaner than the current notation, and solve the superposition bug.

That's it for now. One use of merge-label() in the next post!


Home
previous: the methanol molecule in sw format
next: learning plurals in bko

updated: 19/12/2016
by Garry Morrison
email: garry -at- semantic-db.org