#include <fstream.hfa>

// [unsigned, unsigned] offset_to_index(unsigned offset, unsigned sx, unsigned sy)
// {
//     return [offset / sx, offset % sy];
// }

forall(otype index_t)
index_t offset_to_index(unsigned offset, index_t size) {
    return [offset / size.0, offset % size.1];
}

int main(int argc, char* argv[]) {
    unsigned x = 0, y = 0, i = 0;
    unsigned sx = 4, sy = 4;

    i = 6;
    [x, y] = offset_to_index(6, [sx, sy]);

    sout | x | ' ' | y;

    return 0;
}
