-
-
Save ReneSac/6dfe2a72d7d0f1822d43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type | |
| Tunits = tuple | |
| s, m: int | |
| Tsym = object | |
| val: int | |
| unit: Tunits | |
| proc `+` (a, b: Tunits): Tunits = | |
| for i in 0 .. 1: | |
| result[i] = a[i] + b[i] # Error: cannot evaluate at compile time: i | |
| proc `*` (a, b: Tsym): Tsym = | |
| result.val = a.val * b.val | |
| result.unit = a.unit + b.unit | |
| let fourSeconds = Tsym(4, Tunits(1,0)) | |
| echo repr( fourSeconds * fourSeconds ) # should output something like {val: 8, {s: 2, m: 0}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment