1

I noticed that v.11.3 got released the other day; it was exciting so I went through the Summary of New Features in 11.3 to catch a glimpse of what's new and see if there is something I should keep in mind when writing code, from now on.

There are two new features that caught my attention, namely Construct and Curry. The later one is marked as experimental, so after skimming through the documentation, I rushed over to Construct.

This later symbol seemed promising and as I kept reading the documentation, I was trying to visualize ways to incorporate it in my coding. Eventually, I wrote down each individual use case that-in my understanding-corresponded to the examples in the documentation. I have bundled them together in the end of this question.

It became clear to me that Construct is introduced as a more elegant-for lack of a better description-way of... 'constructing' expressions from base parts (symbols). It seems to render obsolete the need for using raw functions when performing such constructions; imo, the Applications section is replete with... 'applications' of Construct that, at one point or another, can become complex enough to warrant the beneficial application of Construct.

I was wondering if there are other use cases of Construct that didn't occur to me. Can anyone think of other applications of Construct where it proves superior to whatever&@something or whatever&@@something constructs? Is it safe to assume that Construct is indeed introduced to address the issues raised in this question? Are there any other ways that it's application might seem productive?


(* Examples *)

  (* Basic exmaples *)

    f@x === Construct[f, x];

    f @@ {x, y, z} === Construct[f, x, y, z];

    Fold[#1@#2 &, f, {a, b, c}] === Fold[Construct, f, {a, b, c}];


(* Applications *)

  Outer[#1@##2 &, {f1, f2, f3}, {x1, x2}, {y1, y2, y3}] === Outer[Construct, {f1, f2, f3}, {x1, x2}, {y1, y2, y3}];

  MapThread[#1 @@ {##2} &, {{f1, f2, f3}, {x1, x2, x3}, {y1, y2, y3}}] === MapThread[Construct, {{f1, f2, f3}, {x1, x2, x3}, {y1, y2, y3}}];

  Inner[#1@#2 &, {f1, f2, f3}, {x1, x2, x3}, List] === Inner[Construct, {f1, f2, f3}, {x1, x2, x3}, List];


(* Properties and relations *)

  Fold[#2@#1 &, x, {h, g, f}] === Construct[Composition[f, g, h], x];

  f[] === Construct[f];
user42582
  • 4,195
  • 1
  • 10
  • 31

0 Answers0