tinefficient_const_table.nim 512 B

12345678910111213141516171819202122232425262728
  1. discard """
  2. output: '''a
  3. long
  4. list
  5. of
  6. words'''
  7. cmd: r"nim c --hints:on $options -d:release $file"
  8. ccodecheck: "! @'genericSeqAssign'"
  9. targets: "c"
  10. """
  11. # bug #4354
  12. import tables
  13. import sets
  14. import strutils
  15. #const FRUITS = ["banana", "apple", "grapes"]
  16. #let FRUITS = ["banana", "apple", "grapes"].toHashSet
  17. const FRUITS = {"banana":0, "apple":0, "grapes":0}.toTable
  18. proc main() =
  19. let L = "a long list of words".split()
  20. for word in L:
  21. if word notin FRUITS:
  22. echo(word)
  23. main()