File: rectangle.c

package info (click to toggle)
metalang99 1.13.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,428 kB
  • sloc: ansic: 6,748; python: 53; sh: 48; makefile: 18
file content (25 lines) | stat: -rw-r--r-- 662 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Computes the area of a rectangle.

#include <metalang99.h>

#define rect(width, height) ML99_tuple(width, height)
#define rectWidth           ML99_tupleGet(0)
#define rectHeight          ML99_tupleGet(1)

#define rectArea(rect) ML99_mul(rectWidth(rect), rectHeight(rect))

/*
 *                15
 * +------------------------------+
 * |                              |
 * |                              |
 * |                              | 7
 * |                              |
 * |                              |
 * +------------------------------+
 */
#define RECTANGLE rect(v(15), v(7))

ML99_ASSERT_EQ(rectArea(RECTANGLE), v(15 * 7));

int main(void) {}