t22787.nim 486 B

12345678910111213141516171819202122232425262728293031323334353637
  1. discard """
  2. joinable: false
  3. """
  4. import std/assertions
  5. proc foo =
  6. var s:seq[string]
  7. var res = ""
  8. for i in 0..3:
  9. s.add ("test" & $i)
  10. s.add ("test" & $i)
  11. var lastname:string
  12. for i in s:
  13. var name = i[0..4]
  14. if name != lastname:
  15. res.add "NEW:" & name & "\n"
  16. else:
  17. res.add name & ">" & lastname & "\n"
  18. lastname = name
  19. doAssert res == """
  20. NEW:test0
  21. test0>test0
  22. NEW:test1
  23. test1>test1
  24. NEW:test2
  25. test2>test2
  26. NEW:test3
  27. test3>test3
  28. """
  29. foo()