1 23:59:59,500 --> 00:00:06,054 [BLANK_AUDIO]. 2 00:00:06,054 --> 00:00:09,712 In this video, I'm going to work through a relatively straightforward how to 3 00:00:09,712 --> 00:00:13,842 design functions problem. So this video would be a really good 4 00:00:13,842 --> 00:00:17,937 chance for you to practice what you saw in the HTDF full speed and slow motion 5 00:00:17,937 --> 00:00:22,326 videos. Just get the starter file and start 6 00:00:22,326 --> 00:00:25,962 working the problem yourself. And every now and then, run the video to 7 00:00:25,962 --> 00:00:29,082 kind of catch up to where you are in the problem, so that you could see that 8 00:00:29,082 --> 00:00:34,259 you're doing it kind of the way that I'm doing it in the video myself. 9 00:00:36,289 --> 00:00:37,486 >> Okay. This first function is going to be 10 00:00:37,486 --> 00:00:41,144 simple, a lot like [UNKNOWN]. You need to design a function called Yell 11 00:00:41,144 --> 00:00:45,434 that consumes strings like hello and produces strings like hello bang, where 12 00:00:45,434 --> 00:00:49,990 the exclamation mark has been added to the end. 13 00:00:49,990 --> 00:00:56,710 So let's see, the signature of this function is it consumes string and it 14 00:00:56,710 --> 00:01:03,834 produces string. And what it's supposed to do is produce 15 00:01:03,834 --> 00:01:10,980 [SOUND] string with bang added to end of supplied string. 16 00:01:10,980 --> 00:01:16,836 And that's a little cumbersome. purpose statements are often cumbersome 17 00:01:16,836 --> 00:01:19,730 the first time you write it, let's see if you can do better than that. 18 00:01:19,730 --> 00:01:26,825 What if we just say, add bang to the end of s, where s is the name of the 19 00:01:26,825 --> 00:01:34,753 parameter in the stub. So that's simple. 20 00:01:34,753 --> 00:01:42,051 We'll add bang to the end of s. Okay, let's write a check-expect. 21 00:01:42,051 --> 00:01:48,757 Check-expect. Yell with hello and better produce hello 22 00:01:48,757 --> 00:02:02,536 bang like that. And check-expect yell with bye. 23 00:02:02,536 --> 00:02:06,498 It better produce bye, bang. Like that. 24 00:02:06,498 --> 00:02:10,043 Now we run the test, run the check-expects. 25 00:02:10,043 --> 00:02:15,320 And both are failing but the key thing is that both are running. 26 00:02:15,320 --> 00:02:18,150 So that tells me that they are well formed. 27 00:02:19,520 --> 00:02:22,780 So I'll just ignore the fact that they're failing for now. 28 00:02:22,780 --> 00:02:24,530 I really just want to know if they were running. 29 00:02:24,530 --> 00:02:29,814 And now what we'll do is we'll comment out this stub and we'll label it 30 00:02:29,814 --> 00:02:34,006 [UNKNOWN] stub. And let's see. 31 00:02:34,006 --> 00:02:41,800 The template for this function is dif-, is defined yell of s. 32 00:02:41,800 --> 00:02:48,390 Body of the template is dot dot dot s. What I'm going to do is select the 33 00:02:48,390 --> 00:02:53,572 template, make a copy of it. Paste a copy here. 34 00:02:53,572 --> 00:02:58,250 Comment out the template and label it as being the template. 35 00:02:58,250 --> 00:03:00,970 Later in the course, you won't have to leave the template behind. 36 00:03:00,970 --> 00:03:05,563 But for now we find that it's helpful. There is the template. 37 00:03:05,563 --> 00:03:09,984 And now I need to edit it. And, oh yeah, what this function does is 38 00:03:09,984 --> 00:03:14,410 it produces a new string by adding bang to the end of s. 39 00:03:14,410 --> 00:03:21,690 And so that's just going to be string-append S and bang like that. 40 00:03:21,690 --> 00:03:25,241 Now, we'll want it again and both tests passed. 41 00:03:25,241 --> 00:03:29,864 So there you go. That's the design of the yell function 42 00:03:29,864 --> 00:03:33,094 following the HTDF recipe.