News for hackers. Stuff that matters.
Re:A History of Clojure [pdf] by caseymarquis on Friday June 05, 2020 @10:19PM (#23436241)
I'm a little late to the party, but I don't think I would hire an experienced C# developer that didn't immediately know this could be a one liner:

  var csv = ImmutableList<ImmutableList<string>>.Empty;
  var map = csv.ToImmutableDictionary(y => y.First(), y => y.Skip(1).ToImmutableList());
I would hope they would then tell me that this will throw an exception when there is a repeat header in the csv data. I'm not sure the functional and safe version is that much cleaner than a for loop:

  var map = csv
    .Where(x => !string.IsNullOrWhiteSpace(x.FirstOrDefault()))
    .GroupBy(x => x.First())
    .ToImmutableDictionary(x => x.Key, x => x.First().Skip(1).ToImmutableList());
Edit: But I would hire a developer that knew how to do the equivalent in Clojure without hesitation.

There are no comments on this comment yet.