Though you can now search the grid horizontally, you want to do it in all directions. The easiest way to do this isn't to make your function more complicated, but rather to learn how to transform your grid. Learn to use a toolkit including map, reverse, transpose, and your own recursive functions to do this.
- [Instructor] In the previous video,…we saw how to search the grid for words…from left to right and right to left.…In this video, we're going to extend that work…and look at how to search in all directions.…In this video, we're going to use the reverse function…that we've already seen, and also the transpose function.…And we'll see how to write our own recursive functions…to manipulate the grid in order to search diagonally.…So, as we can see, if we look at the grid,…we've already searched from left to right and right to left…by using the reverse function.…
What we want to do now is to search from top to bottom.…We'd like to search a line containing the characters…of the first column, the second column,…the third column, and the fourth column, and so on.…It's a good idea, as always, to look at Hoogle…and see what kind of functions are available.…So, we know that we have a grid, which is a list…of a list of characters.…And we want to return another grid,…but with the characters in a different order.…
So, let's see what kind of existing functions there are…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Discovering Haskell with GHCI
- Haskell datatypes and functions
- Using higher order functions for data manipulation and code reuse
- Editing Haskell source code
- Creating a project with Stack
- Writing and conducting tests