Atom - G - Format Grid

Characters: G

Tags: string , array , matrix

Arity: monadic

This atom is monadic, which means it takes one argument.

Functionality

Format a 2D array of values into a grid as a string.

Details

Given a 2D array (a matrix) of values, attempt to convert it to a string such that the elements are right-aligned and spaced out evenly. It doesn't tend to work well if the array has more than two dimensions; it will try, but it often mixes spaces and/or newlines without properly converting to a string, which can cause strange output. This is mostly useful for rendering matrices of numbers or strings, either for ascii-art challenges or challenges with strict I/O formatting, or for debugging.