nicer print output with empty lists/tables

This commit is contained in:
prod2 2022-02-03 05:06:05 +01:00
parent 2aa3a094bb
commit ff9cfd9c39
2 changed files with 4 additions and 0 deletions

View File

@ -139,6 +139,8 @@ proc tableDelete*[U, V](tbl: Table[U, V], key: U): bool =
return true
proc `$`*[U, V](tbl: NdTable[U, V]): string =
if tbl[].count == 0:
return "@{}"
result = "@{ "
for i in countup(0, tbl.cap.int - 1):
let entry = tbl[].entries[i]

View File

@ -82,6 +82,8 @@ proc getLength*[T](list: List[T]): int {.inline.} =
list.len
proc `$`*[T](list: List[T]): string =
if list.len == 0:
return "@[]"
result = "@[ "
for i in countup(0, list.len - 1):
mixin `$`