过滤序列

时间:2015-06-20 14:55:21

标签: f# f#-interactive f#-data

有三种不同尺寸的seq

a:int   = {1,  2,  3,  4}
b:string= {"a","b","a","d"}
c:string= {"y","y","t","t"}

如何使用条件

seq:a创建新的seq
where b="a" and c="y"

2 个答案:

答案 0 :(得分:6)

Seq.zip3 a b c
|> Seq.choose (function (n, "a", "y") -> Some n | _ -> None)

答案 1 :(得分:1)

Seq.zip a (Seq.zip b c)
|> Seq.filter (snd >> ((=) ("a", "y")))
|> Seq.map fst