ttuple1.nim 450 B

123456789101112131415161718192021
  1. discard """
  2. output: '''
  3. M=1000, D=500, C=100, L=50, X=10, V=5, I=1
  4. '''
  5. """
  6. const romanNumbers = [
  7. ("M", 1000), ("D", 500), ("C", 100),
  8. ("L", 50), ("X", 10), ("V", 5), ("I", 1) ]
  9. var c = 0
  10. for key, val in items(romanNumbers):
  11. inc(c)
  12. stdout.write(key & "=" & $val)
  13. if c < romanNumbers.len: stdout.write(", ") else: echo""
  14. #echo""
  15. proc PrintBiTuple(t: tuple[k: string, v: int]): int =
  16. stdout.write(t.k & "=" & $t.v & ", ")
  17. return 0