# HG changeset patch # User Chris Cannam # Date 1395069708 0 # Node ID b946346870ae3b30ef62a9fdec3a004eedf64de2 # Parent d8a967b0f909da6374ac604cd1e2ebfbca79b8ec Add json function diff -r d8a967b0f909 -r b946346870ae src/may/matrix.yeti --- a/src/may/matrix.yeti Mon Mar 17 11:09:53 2014 +0000 +++ b/src/may/matrix.yeti Mon Mar 17 15:21:48 2014 +0000 @@ -42,6 +42,8 @@ vec = load may.vector; +load yeti.experimental.json; + typedef opaque matrix_t = { size is { rows is number, columns is number }, data is @@ -894,6 +896,9 @@ print' = println . format; eprint' = eprintln . format; +json m = + jsonList (map do r: jsonList (map jsonNum (vec.list r)) done (asRows m)); + { size, width, @@ -951,6 +956,7 @@ format, print = print', eprint = eprint', + json, } as { @@ -1010,5 +1016,6 @@ format is matrix_t -> string, print is matrix_t -> (), eprint is matrix_t -> (), + json is matrix_t -> json, }