Advertisement
Guest User

Untitled

a guest
May 13th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. import tables
  2.  
  3.  
  4. const kvPairs* = [
  5. (1i32, 2i16) ,
  6. (97i32, 71i16),
  7. (98i32, 73i16),
  8. (99i32, 74i16),
  9. ]
  10.  
  11. proc toConstantTable*[A, B](pairs: static[openArray[(A, B)]]): Table[A, B] =
  12. ## creates a new hash table that contains the given `pairs`.
  13. result = initTable[A, B](rightSize(pairs.len))
  14. for key, val in items(pairs): result[key] = val
  15.  
  16. const t = kvPairs.toConstantTable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement