Does Google Dart language allow for functional programming to occur? In particular, are the following features supported?
Other features of functional programming?
It looks like Dart does not support immutable data.
Dart has first-class functions and supports many functional programming constructs. Here are some examples of assigning functions to variables and of a curried function:
main() { f1(x) => x * 2; // Define the function f1 var f2 = f1; // Assign f1 to the variable f2 print(f2(7)); // Feel free to call f2 like any other function add(a) => (b) => a + b; // Curried addition print(add(3)(4)); // Calling curried addition var add3 = add(3); // Combining the print(add3(2)); // concepts }
As expected, this produces:
14 7 5
I don't believe lazy parameters are possible, and you already noted that there is clearly mutable data.
Depends on what you mean by "functional programming". Functions are first-class objects, which covers point 1, there is Function.apply
which lets you implement currying yourself, so that covers point 2, but other than that, Dart isn't very functional (immutability -- no, referential transparency -- no, lazy evaluation -- no, what else have you -- probably also no).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With