Skip to content
  • 0 Votes
    49 Posts
    0 Views
    D
    Sander Rossel wrote: How is that any different from calling Console.WriteLine("test"); etc.? It's just more code to call Console.WriteLine and you aren't chaining anything or using the Tee output :confused: Using a Hello World example would be so much more useful! CQ de W5ALT Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
  • 0 Votes
    3 Posts
    0 Views
    D
    The golden rule at work, and the CEO has all the gold. :rolleyes: Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
  • 0 Votes
    6 Posts
    0 Views
    Richard DeemingR
    If you're using a recent version of the C# compiler, you might want to consider local functions: Local functions (C# Programming Guide) | Microsoft Docs[^] Using the function from the blog post that Eddy linked to, it works almost without change: int Fib(int n) => n > 1 ? Fib(n - 1) + Fib(n - 2) : n; Console.WriteLine(Fib(6)); // displays 8 (Of course, the best solution for calculating Fibonacci numbers is to avoid recursion. :) ) "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • When functional programming isn’t

    The Insider News com business functional
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • How to convert a query to lambda based

    C# tutorial database linq docker functional
    8
    0 Votes
    8 Posts
    0 Views
    OriginalGriffO
    Linq queries and Linq methods aren't executed immediately, they use something called "Deferred execution" which (basically) means that nothing is done until you actually need the final results. There is a basic example of this here: Deferred Execution Example (C#) | Microsoft Docs[^] Deferred execution means better efficiency (sometimes) because you can "combine operations" instead of having to loop each time to produce the intermediate result which you then pass to the next section of the evaluation. Remember: Linq isn't "no loops" it's about "hiding loops" where you can't see them and evaluating them only when it has to. But ... when you say "ToList" you are explicitly requesting an object be created holding the whole results - so the whole operation has to be performed immediately to generate the collection you asked for. So when you then continue to process it, you need to do another loop to process the next operation. Every time you call ToList, you make Linq work harder, and that takes both more time, and uses more memory. Only ever "Collapse the operation" when you actually need the results! Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
  • 0 Votes
    4 Posts
    0 Views
    B
    Hi Nathan, While there is, indeed, only one 'Marc Clifton,' I did not intend to diminish the radiance of any of we 'lesser lights' by attempting to draw his attention to this thread. You may enjoy some recent posts by Marc on this thread: [^] At this point, vis-a-vis functional programming, I am just a voyeur attempting to figure out what the shadows on the walls of the cave ... refer to. cheers, Bill «... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
  • 0 Votes
    5 Posts
    0 Views
    M
    We should have a contest to see which ZDNet author can use the most number of words to say absolutely nothing useful. Latest Article - Code Review - What You Can Learn From a Single Line of Code Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
  • 0 Votes
    7 Posts
    0 Views
    K
    Hi Homer, I thought the query might return all results in the collection where value == 802.11g and Object2 wasn't equal to null. I have so much to learn :) I did a test run and you were right! all objects came back in the collection. I have since implemented your recommendation and that worked :) Here's my test code for ref. using System.Collections.Generic; using System.Linq; namespace ConsoleApp3 { class Program { static void Main(string[] args) { List origCollection = new List() { new Object1() {ID = 1, theList = new List() { new Object2() { Name = "Mode", Value = "802.11b" }, new Object2() { Name = "BW", Value = "20" }, new Object2() { Name = "Chan", Value = "1" }, new Object2() { Name = "Tech", Value = "SISO" } } }, new Object1() { ID = 2, theList = new List() { new Object2(){ Name = "Mode", Value = "802.11g" }, new Object2(){ Name = "BW", Value = "20" }, new Object2(){ Name = "Chan", Value = "1" }, new Object2(){ Name = "Tech", Value = "SISO" } } } }; var theCollection0 = origCollection.Where(m => m.theList.Select(n => n.Value == "802.11b") != null); // Broken var theCollection1 = origCollection.Where(m => m.theList.Any(n => n.Value == "802.11b")); // Works! var theCollection3 = origCollection.Where(m => m.theList.Any(n => n.Value == "802.11z")); // Returns Empty as expected. } }; class Object1 { public int ID { get; set; } public List theList; } class Object2 { public string Name { get; set; } public string Value { get; set; } } } Many thanks for spotting and fixing this! your a star :) Br Nigel
  • An argument for functional programming

    The Insider News functional
    5
    0 Votes
    5 Posts
    0 Views
    Sander RosselS
    "As a bonus functional programming filters even better in the hiring process for top developers." Yeah, it filters out the few programmers you were able to get... :~ Best, Sander Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly
  • 0 Votes
    2 Posts
    0 Views
    J
    One suggestion would be to post a question in one of the programming forums, though by your vague description I'm not sure which one, this forum is for bug reporting and suggestions for the CodeProject site. Maybe the Database Discussion Boards[^] is what you need? "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
  • 0 Votes
    4 Posts
    0 Views
    Richard DeemingR
    The benefits would probably be more obvious if you were passing around the base Stream class. That way, your methods could work with anything stream-like, and wouldn't be limited to byte arrays. private static Stream DecorateStream(Stream input, IEnumerable<Func<Stream, Stream>> decorators) { Stream result = input; foreach (Func<Stream, Stream> decorator in decorators) { result = decorator(result); } return result; } ... var decorators = new List>(); if (useDecryption) decorators.Add(decryptor); if (useDecompression) decorators.Add(decompressor); using (Stream input = DecorateStream(File.OpenRead(filePath), decorators))) { result = (T)dcs.ReadObject(input); } Now your code can work on the file in chunks, rather than having to read the whole thing into memory first. "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
  • No time for new!

    The Lounge database design data-structures functional question
    11
    0 Votes
    11 Posts
    0 Views
    M
    OriginalGriff wrote: because you have no time to properly design, test, or even - probably - specify the project Careful you are talking about my life there. A year into the project where one of the data sources is Excel and they are still deciding on the other data sources. They were wanted delivery last month and yet they can't decide what they want delivered. It's a good thing they pay well... Never underestimate the power of human stupidity RAH
  • Is C++ now a "safe" language?

    The Lounge help c++ com functional question
    15
    0 Votes
    15 Posts
    0 Views
    S
    I've also seen projects go to crawl trying to locate the memory leak. Every time, it was proven that the 3rd party library was to blame.
  • Pragmatic functional programming

    The Insider News html com functional
    7
    0 Votes
    7 Posts
    0 Views
    D
    Years later I still can't decide which part is my favorite, Lambda Calculus and Pascal being denounced for being insufficiently C like, Ritchie's project prior to C/Unix, or the Java/C# descriptions (although C#'s more rapid evolution since the piece was written has gone a large way to undermining the implication Iry made for them). Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
  • 0 Votes
    2 Posts
    0 Views
    M
    > That’s why Luna features both visual and textual representations. It's nice to see someone getting behind that idea, but they still don't have a cool acronym like [V.A.P.O.R.](https://www.codeproject.com/Articles/1156593/V-A-P-O-R-ware-Visual-Assisted-Programming-Organiz) ;) Marc Latest Article - Create a Dockerized Python Fiddle Web App Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
  • Functional programming is a lie

    The Insider News com functional learning
    7
    0 Votes
    7 Posts
    0 Views
    T
    I C WHAT U DID THERE! #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
  • MSDN Magazine - March

    The Insider News visual-studio com functional
    6
    0 Votes
    6 Posts
    0 Views
    M
    Kent Sharkey wrote: Don't you like the Thing reference at least? Yes, that was cute. A friend of mine once defined the word "cute" as meaning "nice but useless." Unfortunately, the context there was when I told him that my gf said that I was "cute." Ahhh, the teenage years. ;) Marc V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
  • Lambda Overdose

    The Insider News c++ linq functional
    6
    0 Votes
    6 Posts
    0 Views
    M
    > The readability has improved vastly Uh, how is for (auto&& e : container) vastly improved? OK, granted, I haven't done C++ for so long that while I imagine I used to understand that syntax without thinking, I'm really don't miss it. I guess knowing a language's syntax and nuances is not like riding a bicycle. I've certainly forgotten how! ;) Marc V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802
  • How do .NET delegates work?

    The Insider News csharp linq dotnet functional tutorial
    1
    0 Votes
    1 Posts
    0 Views
    No one has replied
  • Why Python?

    The Lounge csharp ruby visual-studio question functional
    25
    0 Votes
    25 Posts
    1 Views
    M
    A few years ago I really, really, finally had to learn web technologies after spending most of my career in the *Nix, C/C++ and Informix world. I was utterly horrified to learn that the internet is essentially cobbled together with a mish-mash of scripting languages. In some software houses its like the Wild West! In the end you have to be responsive to the job market but a little part of my programming soul died when I had to work with Perl on Apple Macs. If you have to make the transition into a new environment like Python, then so be it. But lets not kid ourselves that it is the best thing since sliced bread. Learning a new fangled scripting language is just another obstacle to earning a living IMO. I'd much rather the industry settle on one language and set of frameworks and make it universal. Then I can spend my time doing my job and learning to do it better, instead of having to keep back tracking over the same basic stuff over and over again. The patron saint of Software Developers should be the mercurial David Bowie forever singing "Changes". Whenever a another smart arsed dev invents a new language, just for fun and says this is cool everyone should use it, all I hear is Madonna singing "Like A Virgin".