Hello,
I've tried to use writeVector like this:
foreign export ccall vec :: Ptr (SEXP s R.Vector) -> Ptr (SEXP s R.Vector) -> IO ()
vec :: Ptr (SEXP s R.Vector) -> Ptr (SEXP s R.Vector) -> IO ()
vec input result = do
input <- peek input
let x = DV.toSEXP $ DV.fromList ([5] :: [Int32]) :: SEXP s R.Int
out <- writeVector input 2 x
poke result out
I compile to a DLL and I call in R like this:
> .C("vec", input=list(list(1L,2L,3L,4L)), result=list(0L))$result
[[1]]
[1] 5
Why the output is 5 ? I expected list(1,2,5,4).
Another but related question. Assume I have e.g. two SEXP s R.Int objects in Haskell. Is it possible to create the object SEXP s R.Vector corresponding to the list of the two SEXP s R.Int objects ?