On Tue, Mar 21, 2017 at 5:34 PM, Marc Kaufmann <marc.kaufman...@gmail.com> wrote: > Hi, > > I want to store matrices of the following form (but larger) in a database: > > (define m '((0 1) (1 0))) > > Currently I manage to store them by turning them into strings first via: > > (~a (serialize m)); Or just drop the serialize, but I figured I might benefit > from it later. > > The problem is that I can only get a string out of the database. Obviously I > could write a parser for this, but it feels a little odd having to write one > for such a simple, and probably common, task. > > The question I have is whether there is a common best practice for storing > such things in a database, or whether I should write a parser? And if I > should write a parser, I presume I should use either Parsack or Megaparsack?
Depends on your needs. However, postgres (if that's what you're using) has multidimensional arrays as a native type, so you could use those [https://www.postgresql.org/docs/current/static/arrays.html]. The Racket db package has a `pg-array` struct with conversion to/from lists to help you. If you're not using postgres and you don't actually need to query against the data, just store and retrieve it, then serialize/deserialize is fine. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.