Spent some time playing with nim today and was successful at creating an example to call J.
It's nice to have the strong typing. I started with the int return type from J. Adding support for char was surprisingly simple with the template syntax.
proc getData[T](t: int, r: int, sptr: ptr int, d: int): seq[seq[T]] = var result: seq[seq[T]] = @ var shapes = getShape(r, sptr) if shapes.len == 0: var row : seq[T] = @ row.add(cast[ptr T](d)) result.add(row) else: for s in shapes: var item = toSeq(0..s-1).mapIt(T, cast[ptr T](cast[int](d) + it * sizeof(T))) result.add(item) result
There were a few parts that weren't intuitive when calling C, but I pushed through it.