This comment is reply for 2850 にしお: パターンマッチがうらやましい…(重複する要素を取り除く). Go to thread root.
yuin #2858(2007/09/03 08:37 GMT) [ Scala ] Rating1/1=1.00
そこでScalaですよ。
同じやり方で書いてみました。
1 2 3 4
def uniqOnly[A](xs:List[A]) = for(x::Nil <- (for(y<-xs) yield (for(z<-xs if z==y) yield z))) yield x println(uniqOnly(List(3, 1, 4, 1, 5, 9, 2, 6, 5)))
Rating1/1=1.00-0+
[ reply ]
yuin
#2858()
[
Scala
]
Rating1/1=1.00
そこでScalaですよ。
同じやり方で書いてみました。
Rating1/1=1.00-0+