3 ms·
Thank you for posting this. When I saw the original version in F# I thought "I think I can do better" after a long absence from using F#. When I got back to my
by darklajid 13y ago
Thank you for posting this.
When I saw the original version in F# I thought "I think I can do better" after a long absence from using F#. When I got back to my laptop and searched for the to-be-improved snippet I saw yours.
Now I'm hooked again.
- daxfohl 13y agoNote given appropriate `MyLinqExt.Scan` and `MyLinqExt.Pairwise`, you could write this in C# just as concisely.
- darklajid 13y agoHmm.. No. :) I guess that's discussed all over the thread here. I do like C# in general and agree that it can be used in a functional style, but 'just as concisely'? Can't agree with that. Needs the boilerplate (class definition, Main vs. .fsx for example), most keywords/methods seem to be longer (especially the Linq ones, SelectMany, FirstOrDefault etc) and there's no inherent way to build a pipeline as in "no |>". Obviously you can write quite similar code in C# and I would agree that C# doesn't make it especially hard, is even a roughly decent language for that sort of stuff. Still, the F# snippet looks a lot nicer to me. Which leads to .. Just a matter of preference, ymmv etc - there's no claim of superiority here.