Playing with numbers: Number range expander

Playing with numbers: Number range expander Mercutio Tue, 2011-05-24 19:11

There's plenty of programs where the user will sometimes expect it, or it would be convenient, if something accepted a number range. For example: +bbread 5/6-9, if they want to read bboard 5, posts 6, 7, 8 and 9.

So, say we have an unsorted number range as follows:

5 7-10 3 8-9

And we want that to output:

3 5 7 8 9 10

One way of going about this, is to do as follows:

unique(sort(iter(%0,lnum(max([first(%i0,-)],[last(%i0,-)]),min([first(%i0,-)],[last(%i0,-)])))))

How would you do this?