Advertisement
Guest User

strslice.nim

a guest
Jun 28th, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. template cut(s: string, left: Natural = 0, right: Natural = 0): string =
  2.   s[left .. ^(right + 1)]
  3.  
  4. echo cut("Hello World", right = 6)
  5. echo cut("Hello World", left = 6)
  6. echo cut("Hello World", left = 4, right = 4)
  7.  
  8. #[
  9. >nim c -r strslice.nim
  10. Hint: used config file 'C:\Program Files\Nim\config\nim.cfg' [Conf]
  11. Hint: used config file 'C:\Users\Fredrik\AppData\Roaming\nim.cfg' [Conf]
  12. Hint: system [Processing]
  13. Hint: strslice [Processing]
  14. strslice.nim(4, 9) Error: type mismatch: got (string, Slice[system.Natural])
  15. but expected one of:
  16. proc `[]`[Idx, T](a: array[Idx, T]; x: Slice[Idx]): seq[T]
  17. proc `[]`(s: string; x: Slice[int]): string
  18. proc `[]`[T](s: seq[T]; x: Slice[int]): seq[T]
  19. proc `[]`[I: Ordinal, T](a: T; i: I): T
  20. proc `[]`[Idx, T](a: array[Idx, T]; x: Slice[int]): seq[T]
  21. ]#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement