Enabled appending to arbitrary grid lists, refactored for DRY, documented

1. Added an optional argument `$append-to-list`
   that is used as a source list for appending.
   Defaults to $grids.

2. Refactored the code to remove duplicate expressions
   and make it much cleaner.

3. Documented the function and every part of it
   with well-written comments.