I have heard that R is a functional programming language, so I decided to try it out for statistical computing. I am familiar with functional programming paradigms in Scala and F#, and in each of those languages, there is a neat feature called "pattern matching" where you can do things like this:
object Matcher extends App {
class A
class B extends A
class C extends A
class D(one: A, two: A) {
def work {
(one, two) match {
case (o: B, t: B) => println("B")
case (o: B, t: C) => println("C")
case _ =>
}
}
}
val d1 = new D(new B, new B)
val d2 = new D(new B, new C)
d1.work
//B
d2.work
//C
}
I was wondering if R had such a feature. Pattern matching in scala and F# can get more complicated and do type checks, checks on tuples, conditional checks, and more. But whenever I do a search for "pattern matching in R," all I get are regular expression type results. Does R, a functional language, not have this feature, or do I just not know what it's called?