disco-lang / disco

Functional teaching language for use in a discrete mathematics course
Other
164 stars 23 forks source link

Nice way to print formatted function tables, or formatted lists #372

Closed byorgey closed 8 months ago

byorgey commented 10 months ago

For example, if we want to print a truth table for a boolean function, right now the only options are:

A simple idea would be just the ability to print lists in table format. Then at least the list comprehension would be formatted more nicely.

More generally we could have a special command for taking a function and printing a formatted table of its input and output values, either an exhaustive table in the case of finite inputs, or truncated in the case of infinite.

So perhaps there could be a special command :table that works in a type-directed way. When given a list expression, it prints a formatted table with one row per list element (and possibly with multiple columns depending on the type of the elements, e.g. lists or tuples). When given a function expression, it prints a table of inputs and outputs.

Related: #86 , #63 .

byorgey commented 8 months ago

Closed by #376 .