Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: choose separation character in matrix-export #2

Open
MigAP opened this issue Jul 5, 2024 · 1 comment
Open

feature request: choose separation character in matrix-export #2

MigAP opened this issue Jul 5, 2024 · 1 comment

Comments

@MigAP
Copy link

MigAP commented Jul 5, 2024

Hello,

I think it could be helpful to choose the character used to separate the values in the function matrix-export. This would allow to export to CSV, TSV... Here is a proposition:

;;@returns: **void**, writes **matrix** `mat` values, separated by **character** `sp`, in the file with relative path (**string**) `str`.
(define (matrix-export str mat sp)
  (define (export-mat)
    (apply column-foreach (lambda row
                            (let rho [(lst row)]
                              (if (empty? lst) (newline)
                                               (begin
                                                 (display (head lst))
                                                 (when (not (empty? (tail lst))) (display sp))
                                                 (rho (tail lst))))))
                          (matrix-data mat)))
  (with-output-to-file str export-mat #:text))

Thank you in advance.

Cheers,
Miguel

@gramian
Copy link
Owner

gramian commented Jul 5, 2024

Hi,
that would be a useful extension indeed. I will add it for the next version.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants