tinefficient_const_table.nim 494 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. """
  10. # bug #4354
  11. import tables
  12. import sets
  13. import strutils
  14. #const FRUITS = ["banana", "apple", "grapes"]
  15. #let FRUITS = ["banana", "apple", "grapes"].toSet
  16. const FRUITS = {"banana":0, "apple":0, "grapes":0}.toTable
  17. proc main() =
  18. let L = "a long list of words".split()
  19. for word in L:
  20. if word notin FRUITS:
  21. echo(word)
  22. main()