У нас вы можете посмотреть бесплатно Rust By Example: Higher Order Functions или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
High-order functions, a math term, means a function that receives or outputs another function for later use or both. It sounds hard, but Rust programming language makes it easy. Here's an example: suppose we want to find the sum of numbers that have odd squares under 1,000. A complex scenario, not usually faced in daily life, but an interesting one nonetheless. We start with quite a bit of code, including a 'for' loop with an infinity operator which will stop at our limit, 1,000. It’s easy to get lost in this with all the bits and pieces and changes of direction. But consider this, a simpler version. Just five lines of packed code that achieve the same goal, without missing the logic. How is this possible? We create our infinity, square our number, make sure it's within limit, filter out odds, and sum. A simpler process to read and follow. Is it more efficient in terms of performance too? Challenging to say. Both versions include a multiplication operation, which isn't cheap in computing terms. The less code version grows an array, maybe using more memory. But in terms of readability, the shorter code clinches it. It's definitely worth exploring high-order functions for complexities like these.