The Where Command

Submitted by Mercutio on Wed, 2011-05-04 22:02

There are god knows how many where commands out there. But what many will often want is a where command that lists things with the location once, then all the players at that location?

Thus as follows:

location 1              player 1, player3, and player 5
location 2              player 2, and player 6
location 3              player 4

Let's leave the 'Unfindable' case out of this for now.

Here is a sample code on how to use fold() to solve this problem!

First, set the fold attribute. We're not going to mess with #lambda here.

&fold OBJ=%0 [switch(loc(last(%0)),loc(%1),%1,%r[name(loc(%1))]: %1)]
&cmd`where OBJ=$@where:@pemit %#=regeditall(iter(fold(me/fold,sort(lwho(),loc),#-1),align(40 37,first(%i0,:),itemize(iter(rest(%i0,:),name(%i0),,|),|)),%r,%r),^\\s+|\\s+$,)

How would you do this?