summary refs log tree commit diff stats
path: root/tests/concepts/t5968.nim
blob: adb374c65a67515ff3ae2359ea8c2f9f7b4ff95b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
discard """
  exitcode: 0
"""

type
  Enumerable[T] = concept e
    for it in e:
      it is T

proc cmap[T, G](e: Enumerable[T], fn: proc(t: T): G): seq[G] =
  result = @[]
  for it in e: result.add(fn(it))

import json

var x = %["hello", "world"]

var z = x.cmap(proc(it: JsonNode): string = it.getStr & "!")
assert z == @["hello!", "world!"]