Builtin

tag

tag(a, {tag_within_list}, tag_name)

A relation operator. Adds a new attr, named tag_name, with an incrementing sequence, from 0, within each tag_within_list.

If {} is used for the tag_with_list, a unique tag per tuple is given.

Use -attr to reverse the tag within order. You should end with a unique attr for stability in case of tie-breaks.

Examples

tag
tag($S, {STATUS, SNO}, status_seq)
SNOSNAMESTATUSCITYstatus_seq
S1Smith20London0
S2Jones10Paris0
S3Blake30Paris0
S4Clark20London1
S5Adams30Athens1

tag unique
tag($S, {}, seq)
SNOSNAMESTATUSCITYseq
S1Smith20London0
S2Jones10Paris1
S3Blake30Paris2
S4Clark20London3
S5Adams30Athens4