Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    eyes explode Point-free style is clever, but unreadable and unmaintainable. fun x -> x |> List.map fst |> List.filter (fun y -> y = identifier) expresses the same thing without sacrificing readability. Commented Mar 4, 2010 at 22:22
  • Point taken. I hope this revision is better. :) Commented Mar 4, 2010 at 22:43
  • True, tryFind would be the best use of the language since I was only temporarily using -1 as a stand-in for None. But I'm glad I learned a little more about pattern matching and variable binding. Commented Mar 5, 2010 at 8:01
  • In that case the function getValue would look something like this: let getValue identifier = List.tryFind (fun (x,y) -> x = identifier) >> Option.map snd //val getValue : 'a -> (('a * 'b) list -> 'b option) when 'a : equality Commented Mar 5, 2010 at 14:49