Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. The best lambda expression I ever saw

The best lambda expression I ever saw

Scheduled Pinned Locked Moved The Weird and The Wonderful
linqfunctional
13 Posts 10 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thomas Daniels
    wrote on last edited by
    #1

    var someVar = someList.SelectMany(λ => λ);

    In some cases, my signature will be longer than my message...

    <em style="color:red"> <b>ProgramFOX</b></em>

    ProgramFOX

    B J R S R 6 Replies Last reply
    0
    • T Thomas Daniels

      var someVar = someList.SelectMany(λ => λ);

      In some cases, my signature will be longer than my message...

      <em style="color:red"> <b>ProgramFOX</b></em>

      ProgramFOX

      B Offline
      B Offline
      Brisingr Aerowing
      wrote on last edited by
      #2

      :laugh: And the best part is that actually works!

      Bob Dole

      The internet is a great way to get on the net.

      :doh: 2.0.82.7292 SP6a

      1 Reply Last reply
      0
      • T Thomas Daniels

        var someVar = someList.SelectMany(λ => λ);

        In some cases, my signature will be longer than my message...

        <em style="color:red"> <b>ProgramFOX</b></em>

        ProgramFOX

        J Offline
        J Offline
        joe_j
        wrote on last edited by
        #3

        does that even work?

        T 1 Reply Last reply
        0
        • T Thomas Daniels

          var someVar = someList.SelectMany(λ => λ);

          In some cases, my signature will be longer than my message...

          <em style="color:red"> <b>ProgramFOX</b></em>

          ProgramFOX

          R Offline
          R Offline
          Robert Rohde
          wrote on last edited by
          #4

          Well that makes sense if someList is a list of objects which implement IEnumerable (like List<List<int>>. A bit weird but no horror.

          B R 2 Replies Last reply
          0
          • J joe_j

            does that even work?

            T Offline
            T Offline
            Thomas Daniels
            wrote on last edited by
            #5

            Yes.

            In some cases, my signature will be longer than my message...

            <em style="color:red"> <b>ProgramFOX</b></em>

            ProgramFOX

            1 Reply Last reply
            0
            • R Robert Rohde

              Well that makes sense if someList is a list of objects which implement IEnumerable (like List<List<int>>. A bit weird but no horror.

              B Offline
              B Offline
              Brisingr Aerowing
              wrote on last edited by
              #6

              Which is why this forum is called "The Weird and The Wonderful"!!

              Bob Dole

              The internet is a great way to get on the net.

              :doh: 2.0.82.7292 SP6a

              1 Reply Last reply
              0
              • R Robert Rohde

                Well that makes sense if someList is a list of objects which implement IEnumerable (like List<List<int>>. A bit weird but no horror.

                R Offline
                R Offline
                Remi BOURGAREL
                wrote on last edited by
                #7

                It's not even weird, if you want to flat a list of lists then that's the best way to do it.

                1 Reply Last reply
                0
                • T Thomas Daniels

                  var someVar = someList.SelectMany(λ => λ);

                  In some cases, my signature will be longer than my message...

                  <em style="color:red"> <b>ProgramFOX</b></em>

                  ProgramFOX

                  S Offline
                  S Offline
                  SortaCore
                  wrote on last edited by
                  #8

                  I think one posted in the chatroom a coupla days ago had C++11...

                  [](){[](){}();}();

                  ... but I suspect he was trolling.

                  P 1 Reply Last reply
                  0
                  • S SortaCore

                    I think one posted in the chatroom a coupla days ago had C++11...

                    [](){[](){}();}();

                    ... but I suspect he was trolling.

                    P Offline
                    P Offline
                    peterchen
                    wrote on last edited by
                    #9

                    The great thing about C++ is: you can never be sure.

                    ORDER BY what user wants

                    P 1 Reply Last reply
                    0
                    • T Thomas Daniels

                      var someVar = someList.SelectMany(λ => λ);

                      In some cases, my signature will be longer than my message...

                      <em style="color:red"> <b>ProgramFOX</b></em>

                      ProgramFOX

                      R Offline
                      R Offline
                      RafagaX
                      wrote on last edited by
                      #10

                      :omg:

                      CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                      1 Reply Last reply
                      0
                      • P peterchen

                        The great thing about C++ is: you can never be sure.

                        ORDER BY what user wants

                        P Offline
                        P Offline
                        phwitti
                        wrote on last edited by
                        #11

                        xD .. If i'm not mistaken, that is just an empty lambda nested inside another one ... I wonder if one could go on and on like that. -- But in the end it would do nothing (besides probably a stack overflow, if you take it too far^^)

                        1 Reply Last reply
                        0
                        • T Thomas Daniels

                          var someVar = someList.SelectMany(λ => λ);

                          In some cases, my signature will be longer than my message...

                          <em style="color:red"> <b>ProgramFOX</b></em>

                          ProgramFOX

                          G Offline
                          G Offline
                          Gates VP
                          wrote on last edited by
                          #12

                          I think I have to classify this as "wonderful", because it's honestly pretty common. The simplest case of SelectMany is to flatten a "List of List of Objects" into a "List of Objects". And that's exactly what this lambda does. I guess the "weird" here is that SelectMany is doing some extra magic merging the lists.

                          B 1 Reply Last reply
                          0
                          • G Gates VP

                            I think I have to classify this as "wonderful", because it's honestly pretty common. The simplest case of SelectMany is to flatten a "List of List of Objects" into a "List of Objects". And that's exactly what this lambda does. I guess the "weird" here is that SelectMany is doing some extra magic merging the lists.

                            B Offline
                            B Offline
                            Brisingr Aerowing
                            wrote on last edited by
                            #13

                            As well as the actual lambda Greek letter.

                            Bob Dole

                            The internet is a great way to get on the net.

                            :doh: 2.0.82.7292 SP6a

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups