1 00:00:00,000 --> 00:00:01,000 Let's go about implementing that. 2 00:00:01,000 --> 00:00:07,000 Let's say I had my old definition of sequence of (x,y), 3 00:00:07,000 --> 00:00:14,000 and we say return the tuple consisting of a sequence x and y. 4 00:00:14,000 --> 00:00:16,000 Now I want to change that. How would I change that? 5 00:00:16,000 --> 00:00:23,000 Well, instead of x and y, I think I'm going to insist that we have at least 1 argument, 6 00:00:23,000 --> 00:00:27,000 so I can say x and then the rest of the args, 7 00:00:27,000 --> 00:00:33,000 and I can say, if the length of the rest of the args equals 1, 8 00:00:33,000 --> 00:00:38,000 then I've got this binary case and then I can take sequence of x. 9 00:00:38,000 --> 00:00:41,000 The second arg is now no longer called y. 10 00:00:41,000 --> 00:00:44,000 It's called args at 0. 11 00:00:44,000 --> 00:00:49,000 Else: now I've got a recursive case with more than 2 args, and I can do something there. 12 00:00:49,000 --> 00:00:53,000 So it's not that hard, but I had to do a lot of violence to this definition of sequence, 13 00:00:53,000 --> 00:00:59,000 and come to think of it, I may be repeating myself because I had to do this for sequence, 14 00:00:59,000 --> 00:01:02,000 and I'm also going to have to do it for alt, 15 00:01:02,000 --> 00:01:08,000 and if I expand my program, let's say I start wanting to take on arithmetic 16 00:01:08,000 --> 00:01:14,000 as well as regular expressions, then I may have functions for addition and multiplication 17 00:01:14,000 --> 00:01:17,000 and others, and I'm going to have to make exactly the same changes 18 00:01:17,000 --> 00:01:18,000 to all these binary functions. 19 00:01:18,000 --> 00:01:23,000 So that seems to violate the "Don't Repeat Yourself" principle. 20 00:01:23,000 --> 00:01:26,000 I'm making the same changes over and over again. 21 00:01:26,000 --> 00:01:29,000 It's more work for me. There's a possibility of introducing bugs. 22 00:01:29,000 --> 00:01:30,000 Is there a better way? 23 00:01:30,000 --> 00:01:33,000 So let's back up and say, what are we doing in general? 24 00:01:33,000 --> 00:01:41,000 Well, we're taking a binary function f of (x,y), and we want to transform that somehow 25 00:01:41,000 --> 00:01:48,000 into an n_ary function--f prime, which takes x and any number of arguments. 26 00:01:48,000 --> 00:01:52,000 The question is, can we come up with a way to do that to automatically-- 27 00:01:52,000 --> 00:01:57,000 change one function or modify or generate a new function from the definition 28 00:01:57,000 --> 99:59:59,999 of that original function.