source: examples/ArrayN.c @ 73abe95

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since 73abe95 was 73abe95, checked in by Thierry Delisle <tdelisle@…>, 6 years ago

Replace extension-less headers with .hfa

  • Property mode set to 100644
File size: 491 bytes
Line 
1#include <fstream.hfa>
2
3// [unsigned, unsigned] offset_to_index(unsigned offset, unsigned sx, unsigned sy)
4// {
5//     return [offset / sx, offset % sy];
6// }
7
8forall(otype index_t)
9index_t offset_to_index(unsigned offset, index_t size)
10{
11    return [offset / size.0, offset % size.1];
12}
13
14int main(int argc, char* argv[])
15{
16    unsigned x = 0, y = 0, i = 0;
17    unsigned sx = 4, sy = 4;
18
19    i = 6;
20    [x, y] = offset_to_index(6, [sx, sy]);
21
22    sout | x | ' ' | y | endl;
23
24    return 0;
25}
Note: See TracBrowser for help on using the repository browser.