• 0

Can someone explain where Lambda Expressions would be useful?


Question

I was wondering what the benefits of using Lambda Expressions are. Can someone think of examples of where they would be beneficial to use? Let's say that I have a website where I want to add and manipulate customer and product information from a database. Is that a good place to use them for instance? Thank you in advance!

10 answers to this question

Recommended Posts

  • 0

Lambdas are more than inline functions, they are also closures. Any lambda that captures local variables, fields, etc, is compiled not to a method but to a type. C++ programmers are familiar with this concept under the name of functors; it was the only way to do closures before the advent of lambda expressions in C++11. C# had support for closures before lambdas actually, in C# 2.0 there were already anonymous methods which are basically lambdas with an ugly syntax. With lambdas, LINQ and the Func and Action types, C# 3.0 made functional programming much easier.

  • 0

Lambda expressions are good for one off items that require a function but not necessarily need a full blown function created.

 

One use could be finding an object within a list that contains a certain value for one of it's member attributes.

  • 0

Yes, see the wikipedia entry for some good examples: http://en.wikipedia.org/wiki/Lambda_%28programming%29#Sorting

 

If you're referring to them in the more general sense of being anonymous functions, then they get thrown all over in Javascript.

  • 0
  On 27/06/2013 at 20:38, winlonghorn said:

Ok, so it would be good for searching for information / generating a report on one specific product basically?

 

Just like for anonymous functions it's just to avoid flooding classes with methods with the most basic functionalities.

  • 0

Oh ok! That makes it a lot clearer! I can definitely see now how using Lambdas would be useful instead of having tons of small methods all over the place. That is exactly what I was looking for (the reason they were created). Thank you!

  • 0
  On 28/06/2013 at 13:15, winlonghorn said:

Oh ok, so they can function as classes as well then?

In the very limited sense that they can capture local state (fields, local variables, etc), yes. I suggest you look at the Jon Skeet article I linked to get a better understanding of closures.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • "Microsoft plans to remove the MSN feed..." Yaaay, finally the horrible dumpster fire of badly translated tabloid trash is going away! Good riddance! "...and replace it with Copilot Discover..." Oh ffs...
    • Similar to how Nvidia stopped caring about the consumer market a while ago and now just pays lip service to it because it prints money.
    • Yep same as every company, sadly. The biggest bank in Australia just laid off a bunch of staff even though they made record profits, then advertised the roles in India
    • Kdenlive 25.08 RC1 by Razvan Serea Kdenlive is an acronym for KDE Non-Linear Video Editor. It works on GNU/Linux, Windows and BSD. Through the MLT framework, Kdenlive integrates many plugin effects for video and sound processing or creation. Furthermore Kdenlive brings a powerful titling tool, a DVD authoring (menus) solution, and can then be used as a complete studio for video creation. Kdenlive supports all of the formats supported by FFmpeg or libav (such as QuickTime, AVI, WMV, MPEG, and Flash Video, among others), and also supports 4:3 and 16:9 aspect ratios for both PAL, NTSC and various HD standards, including HDV and AVCHD. Video can also be exported to DV devices, or written to a DVD with chapters and a simple menu. Video editing features: Multi-track editing with a timeline and supports an unlimited number of video and audio tracks. A built-in title editor and tools to create, move, crop and delete video clips, audio clips, text clips and image clips. Ability to add custom effects and transitions. A wide range of effects and transitions. Audio signal processing capabilities include normalization, phase and pitch shifting, limiting, volume adjustment, reverb and equalization filters as well as others. Visual effects include options for masking, blue-screen, distortions, rotations, colour tools, blurring, obscuring and others. Configurable keyboard shortcuts and interface layouts. Rendering is done using a separate non-blocking process so it can be stopped, paused and restarted. Kdenlive also provides a script called the Kdenlive Builder Wizard (KBW) that compiles the latest developer version of the software and its main dependencies from source, to allow users to try to test new features and report problems on the bug tracker. Project files are stored in XML format. An archiving feature allows exporting a project among all assets into a single folder or compressed archive. Built-in audio mixer Kdenlive 25.08 RC1 changelog: Optimized interface for lower resolution screens Project files are now properly recognized and can easily be opened by clicking them on MacOS Fix location of title templates on Windows Fix downloadable keyboard schemes Fix python 3.13 compatibility for Whisper Added power management support to prevent sleep while playing / rendering Support for start timecode Added option to display the markers of all clips in the project in the guides list Show thumbnails in the guides list Redesigned mixer Download: Kdenlive 25.08 RC1 | 117.0 MB (Open Source) Links: Kdenlive Home page | Other Operating Systems Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Week One Done
      Itbob513626 earned a badge
      Week One Done
    • One Month Later
      Itbob513626 earned a badge
      One Month Later
    • Rookie
      EdwardFranciscoVilla went up a rank
      Rookie
    • Week One Done
      MoJo624 earned a badge
      Week One Done
    • Collaborator
      aeganwn earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      618
    2. 2
      ATLien_0
      243
    3. 3
      Xenon
      159
    4. 4
      Michael Scrip
      126
    5. 5
      +FloatingFatMan
      122
  • Tell a friend

    Love Neowin? Tell a friend!