Equation Function to Format Lists Using Natural Language


#1

Given a list, if would be nice to have an equation function to format a list using natural language.

Potentially, this could be done by extending the join() function such that if a deliminator isn’t specified it uses natural language.

For instance:

join(["a", "b"]) :arrow_right: “a and b”
join(["a"]) :arrow_right: “a”
join(["a", "b", "c", "d]) :arrow_right: “a, b, c and d”


#2

Hi scott,

blaze has been a love at first sight for me so thank you. I would really love to have more power with the dynamic equations, and lists seem like the best way to do this. Particularly, this would be useful so that I can create functions which take an arbitrary amount of inputs (in a list) and perform operations on them like sum or average for simple examples, but also like t-test or other statistical calculations. Lists would also be useful for non-mathematical functions like 'countunique' or 'reverse'...

just my hopes!


#3

@williamsharpless.2 Text Blaze already has support for lists which can be used to implement things like a sum or average. Here's a quick example:

Define reusable functions to calculate sum and average
{sum=(list) -> reduce(list, 0, (v, acc) -> v + acc) } Function to sum a list
{mean=(list) -> sum(list) / count(list)} Function to find the mean of a list

Use them
{=sum([1, 4, 9, 16])}
{=mean([1, 4, 9, 16])}

You can learn more about lists here: