rlwhitcomb / utilities

Some of my personal utility programs
MIT License
2 stars 0 forks source link

Make a way to pass a range (as in 2..10) to a function as a parameter #612

Open rlwhitcomb opened 1 year ago

rlwhitcomb commented 1 year ago

Say I want to apply a function to a range of values:

define l(n, p) = { loop v over n { p(v, n) } }
l(2..10, op)

Right now this is a syntax error because ranges (loop controls) are not allowed as parameters.

rlwhitcomb commented 1 year ago

Would also need to update "typeof" to return "range" for this. Don't know how to handle "cast" or "~~" or other conversions.

rlwhitcomb commented 10 months ago

Note that we already allow a range in "sumof" and "productof" so the same principles ought to apply.

rlwhitcomb commented 7 months ago

The difficulty in this is that formal parameters are identified as a single variable name, while a range expression has from one to three variables. How would we refer to them inside the function????