Remove a single non-unique value from a sequence in F#

Posted by mavnn on Stack Overflow See other posts from Stack Overflow or by mavnn
Published on 2010-04-24T20:15:38Z Indexed on 2010/04/24 20:23 UTC
Read the original article Hit count: 157

Filed under:

I have a sequence of integers representing dice in F#.

In the game in question, the player has a pool of dice and can choose to play one (governed by certain rules) and keep the rest.

If, for example, a player rolls a 6, 6 and a 4 and decides to play one the sixes, is there a simple way to return a sequence with only one 6 removed?

Seq.filter (fun x -> x != 6) dice

removes all of the sixes, not just one.

© Stack Overflow or respective owner

Related posts about F#