From: Robert D. <rob...@gm...> - 2024-10-29 20:16:22
|
On Tue, Oct 29, 2024 at 11:33 AM Stavros Macrakis <mac...@gm...> wrote: > For one thing, multiline strings don't stay within their matrix cell: I'll try to look at that later -- the key is probably getting the string formatter to start over at some nonzero offset from the left margin. > For another, I don't know how to get a 2d representation output as a string with embedded Newlines. There are a couple of ways. Some version of this is exercised in the tests for the display code -- grepping tests/*.mac for assignments to display2d will find some or all of them. expr: 1/(1 + 1/x); foo1: printf (false, "~m", expr) $ stringp (foo1); foo1; map (cint, charlist (foo1)); Note that cint returns the character code for a 1-element string and charlist returns a list of those; code 10 (decimal) is a newline. Here is the other way: S: make_string_output_stream (); with_stdout (S, print (expr)); foo2: get_output_stream_string (S); stringp (foo2); foo2; map (cint, charlist (foo2)); close (S); Enjoy, Robert |