score:0
i would try pattern matching
with guard conditions
, as an example:
def concat[a](a: seq[a]) = {
a match {
case(h::_) if h.isinstanceof[int] => // do multiply and return as ....
case(h::_) if h.isinstanceof[string] => // do concat and return as ....
case _ => throw new nosuchelementexception
}
}
Source: stackoverflow.com
Related Query
- Multiply each element of generic class
- In Scala 2.10 how to add each element in two generic lists together
- Scala Multiply list element to next to each other
- Get companion object of class by given generic type Scala
- How do I make a class generic for all Numeric Types?
- Scala - obtaining a class object from a generic type
- cannot find class manifest for element type T
- Split up a list at each element satisfying a predicate (Scala)
- Generic customisation of case class ToString
- Insert an element between each two adjacent elements of Seq
- Shapeless: generic lens parameterized by case class or field
- Scala copy case class with generic type
- Infer multiple generic types in an abstract class that should be available to the compiler
- Scala: Is it possible to indicate a generic class which implements a certain method
- Scala method to combine each element of an iterable with each element of another?
- Count occurrences of each element in a List[List[T]] in Scala
- Unable to convert generic case class to json using "writes"
- How to cast each element in Scala List?
- Circe encoder for generic case class with default parameters
- About Scala generics: cannot find class manifest for element type T
- How to get evidence that each type element in Shapeless HList belongs to a typeclass
- Scala: Constraint on generic class type
- scala generic encoder for spark case class
- Implicit class for subtypes of a generic class
- Jackson mapper with generic class in scala
- How to do generic tuple -> case class conversion in Scala?
- generic trait taking a class and it's companion object as a type parameter
- Scala/ Spark- Multiply an Integer with each value in a Dataframe Column
- Return copy of case class from generic function without runtime cast
- Scala class inheriting from a Java generic class
More Query from same tag
- Spark 1.6.1: creating DataFrame from RDD[Array[Error]]
- Does spark supports multiple output file with parquet format
- Spark words in a column should not be present in another column
- Scala: how to change this code in functional way?
- Setting an immutable field for later use
- What is the #:: operator in a scala Stream?
- how is flatMap working with custom monads
- Scala Spark get sum by time bucket across team spans and key
- Arguments in Auxiliary Constructor in Scala
- Play framework async action: Future recover not working
- Changing variable inside a class
- DataFrame with groupBy versus RDD with reduceByKey
- Hive sql - between multiple partitions
- Scala: Are Pattern Matching and Match Expression the Same in Scala?
- Difference between two rows in Spark Java API
- De-/Serializing with readObject/writeObject
- toChar is not a value of Unit
- Using Option and None in a spark RDD in scala
- How do I import a java classname with a dollar sign ($), or refer to a field or method with one, in Jython?
- Scala Spark Convert Dataframe and get all Unique IDs and its type from each row
- In Scala, is it possible to "curry" type parameters of a def?
- How to pass Set/HashSet as argument into UDF in spark?
- Regex to extract part of string between parenthesis
- Is there any built in method to find similarity score between two text files in apache spark scala
- How to execute dynamic query with sql""select c from T""".as[T] interpolation in slick
- Apply map function to every element of NumericRange wrapped in Array in Scala
- Spark "Task not serializable" when using field variables
- Scala vs. C++ for a distributed graph processing
- Scala - Inner map returns value ( not an option of that value )
- the equivalent of scalac -print from within sbt?