A R list to a Haskell list, with the `clipr` package

Posted on March 14, 2018 by Stéphane Laurent
Tags: R, haskell

In the previous post, I have shown how to convert a R matrix to a Haskell list. Now I will show how to convert a R list to a Haskell list.

Let’s take this list for illustration:

So, for Haskell, you want:

Again, the clipr package is your friend. First, write the matrix in the clipboard, like this:

No we will deal with gsub, sub and finally cat to write the output to a file.

And then, here is the content of list.txt:

Now copy-paste to Haskell, it is ready.

Update 2018-04-18

I’ve realized there is an issue in the case when some elements of the list are vectors of length one. It is fixed in the following function:

Let’s test it.

Here is the content of list.txt:

Fine.