19

Is there a shorter notation for identity function (fun x -> x), other then defining your own? Writing

Seq.countBy (fun x -> x)

looks so wordy.

1 Answer 1

26

There is a short version id which is equal to fun x -> x

Also, for your case you can just do Seq.sort

3
  • Ooops, I meant countBy (edited the question). id is what I was looking for, thank you. Mar 16, 2013 at 5:05
  • Not quite, I need counts of unique elements provided by countBy, sum does something else. Mar 16, 2013 at 5:14
  • Sorry, I had forgotten what that function did Mar 16, 2013 at 5:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.