Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, terminal
- iterator digit(c: char): string =
- var i = 0
- while i < 3:
- case i:
- of 0:
- case c:
- of '0', '2', '3', '7', '8', '9': yield "/\\"
- of '1', '4': yield " \\"
- of '5', '6': yield "/"
- else: yield ""
- of 1:
- case c:
- of '0': yield "\\ \\"
- of '1', '7': yield " \\"
- of '2', '-': yield " /"
- of '3': yield " /\\"
- of '4', '5', '6', '8', '9': yield "\\/\\"
- else: yield ""
- of 2:
- case c:
- of '0', '2', '6', '8': yield " \\/"
- of '3', '5', '9': yield " /"
- else: yield ""
- else: discard
- inc i
- proc display(s: string) =
- var
- offset = (s.len)*2
- index = s.high
- if s[0] notin {'-', '0'..'9'}:
- echo "Error: Not a number."
- return
- for c in s[1..^1]:
- if c notin {'0'..'9'}:
- echo "Error: Not a number."
- return
- while index >= 0:
- for line in digit(s[index]):
- terminal.setCursorXPos(offset)
- echo line
- terminal.cursorUp()
- dec index
- offset -= 2
- if paramCount() > 0:
- display(paramStr(1))
Advertisement
Add Comment
Please, Sign In to add comment