

There are two main features that are necessary for an effective recursive function: This is done recursively by calling the function within itself.Ī recursive function is a function that calls itself in order to iterate or loop through a problem. If we reach the last word in needle and find a match, then we return 1 or true. If a match is not found and we reach the end of the haystack, we return 0 or false. Once a match is found, we move on to the next word in needle. If that match fails, we move on to the next word in haystack.

In short, we start by comparing the first word in the needle with the first characters in the first word in haystack. If you are curious to know just how this function works, read on… Function Details If you give the function a different name, you will need to change the two calls to that function in the function text above. Don’t forget to add the three parameters listed above in the order listed and name the function FindWordPartsInText. Left ( word Length ( needle ) ) = needle įindWordPartsInText ( RightWords ( needles WordCount ( needles ) - 1 ) haystack 1 )įindWordPartsInText ( needles haystack start + 1 )Īt this point, you can copy and paste the above function and skip to step three if you wish. The function, which I am calling FindWordPartsInText, is as follows: If ( The function will return true if, for each word in needles, there is at least one word in haystack that begins with that word. This will be used to iterate through all the words in the haystack. When calling this function, we would almost always pass the number 1.

start: This is a number representing the word within haystack where we will start searching.It will most likely be the contents of one or more fields.

