nim / J integration on [2015-01-02 Fri 21:07]

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)[])
      for s in shapes:
        var item = toSeq(0..s-1).mapIt(T, cast[ptr T](cast[int](d) + it * sizeof(T))[])

There were a few parts that weren't intuitive when calling C, but I pushed through it.

Prev: nim socketserver  Next: New Year / New Language - Nim