Let's go about implementing that.
Let's say I had my old definition of sequence of (x,y),
and we say return the tuple consisting of a sequence x and y.
Now I want to change that. How would I change that?
Well, instead of x and y, I think I'm going to insist that we have at least 1 argument,
so I can say x and then the rest of the args,
and I can say, if the length of the rest of the args equals 1,
then I've got this binary case and then I can take sequence of x.
The second arg is now no longer called y.
It's called args at 0.
Else: now I've got a recursive case with more than 2 args, and I can do something there.
So it's not that hard, but I had to do a lot of violence to this definition of sequence,
and come to think of it, I may be repeating myself because I had to do this for sequence,
and I'm also going to have to do it for alt,
and if I expand my program, let's say I start wanting to take on arithmetic
as well as regular expressions, then I may have functions for addition and multiplication
and others, and I'm going to have to make exactly the same changes
to all these binary functions.
So that seems to violate the "Don't Repeat Yourself" principle.
I'm making the same changes over and over again.
It's more work for me. There's a possibility of introducing bugs.
Is there a better way?
So let's back up and say, what are we doing in general?
Well, we're taking a binary function f of (x,y), and we want to transform that somehow
into an n_ary function--f prime, which takes x and any number of arguments.
The question is, can we come up with a way to do that to automatically--
change one function or modify or generate a new function from the definition
of that original function.