Earlier quoted context omitted.
This is why we say > We're going to sidestep the issue of what, exactly, functional programming is or is not, and instead show off some features of Rust that are similar to features in many languages referred to as functional. Many people think of "programming with higher order functions" to be a feature of functional languages, and that may be wrong, but it's also okay. The goal is to teach the stuff, not worry abou…
OK, but if you avoided calling non-functional patterns part of functional programming, you would avoid invoking the topic of "what constitutes functional programming" altogether.
Functional Language Features in Rust – Iterators and Closures
11–20 of 42 posts
Re: Functional Language Features in Rust – Iterators and Closures
#12 let add_one = |x| x + 1;
let five = add_one(4);
I thought to myself "hmm I wonder what happens if I were to call the code with a float rather than an int?"Answered my question a few paragraphs down. Kudos.
Is it possible to write a generic closure? i.e something that would add 1 to any numeric type.
Re: Functional Language Features in Rust – Iterators and Closures
#13Earlier quoted context omitted.
This is why we say > We're going to sidestep the issue of what, exactly, functional programming is or is not, and instead show off some features of Rust that are similar to features in many languages referred to as functional. Many people think of "programming with higher order functions" to be a feature of functional languages, and that may be wrong, but it's also okay. The goal is to teach the stuff, not worry abou…
OK, but if you avoided calling non-functional patterns part of functional programming, you would avoid invoking the topic of "what constitutes functional programming" altogether.
Re: Functional Language Features in Rust – Iterators and Closures
#14Iterators of this form are not functional construct, they are a pattern from object-oriented programming.
Re: Functional Language Features in Rust – Iterators and Closures
#15That was really well written. As I was reading through the example code in the section about closures let add_one = |x| x + 1; let five = add_one(4); I thought to myself "hmm I wonder what happens if I were to call the code with a float rather than an int?" Answered my question a few paragraphs down. Kudos. Is it possible to write a generic closure? i.e something that would add 1 to any numeric type.
To answer your last question, not yet. There was an RFC for this, but it was recently postponed; closures rely heavily on traits and we are in the process of re-doing the internals of the trait system. If I remember the reason correctly.
Re: Functional Language Features in Rust – Iterators and Closures
#16Please don't take over my Cmd+Left arrow key for going back, Chrome already took away my backspace :(
I've never had any issues with it.
Re: Functional Language Features in Rust – Iterators and Closures
#17That was really well written. As I was reading through the example code in the section about closures let add_one = |x| x + 1; let five = add_one(4); I thought to myself "hmm I wonder what happens if I were to call the code with a float rather than an int?" Answered my question a few paragraphs down. Kudos. Is it possible to write a generic closure? i.e something that would add 1 to any numeric type.
I absolutely love it when a blog post, talk, or docs like these do that.
Especially during talks. Often the speaker will say something and it will immediately pop up questions in my mind which I really really want to ask but of course I should wait till the end. And then they answer it in the next slide. Perfect :)
Re: Functional Language Features in Rust – Iterators and Closures
#18Earlier quoted context omitted.
This is why we say > We're going to sidestep the issue of what, exactly, functional programming is or is not, and instead show off some features of Rust that are similar to features in many languages referred to as functional. Many people think of "programming with higher order functions" to be a feature of functional languages, and that may be wrong, but it's also okay. The goal is to teach the stuff, not worry abou…
OK, but if you avoided calling non-functional patterns part of functional programming, you would avoid invoking the topic of "what constitutes functional programming" altogether.
Re: Functional Language Features in Rust – Iterators and Closures
#19Please don't take over my Cmd+Left arrow key for going back, Chrome already took away my backspace :(