Does Dart support functional programming?

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.

Leave a Comment

techhipbettruvabetnorabahisbahis forumu