Census: Advanced

Submitted by Mercutio on Thu, 2011-05-05 10:27

In this post we handled a simple census command with limited attribute values. But what if the attribute value is /not/ pre-defined.

So...

&attribute player=value

And assume that one can only use letters, numbers or spaces

@attribute/limit attribute=^[a-zA-Z0-9 ]+$

And we wanted a census command that outputs:

value 1: player, player2, and player3
value 2: player6, and player 8
value 3: player5, and player7
value 4: player9

One way, /abusing/ named registers (which will fail after X amount of unique named registers have been used up - as defined in @config) - is to do the following:

null(iter(lsearch(all,type,player,elock,attribute:*),setq(setr(a,edit(get(%i0/attribute),%b,_)),setunion(%q<%qa>,%i0))[setq(tlist,setunion(%q,%qa))]))

[iter(%q,edit(%i0,_,%b): [itemize(%q<%i0>)],,%r)]

How would /you/ do this?