Jewels and stones: Difference between revisions

Scala contribution added.
(Scala contribution added.)
Line 484:
</pre>
 
=={{header|Scala}}==
<lang Scala>object JewelsStones extends App {
def countJewels(s: String, j: String): Int = s.count(i => j.contains(i))
 
println(countJewels("aAAbbbb", "aA"))
println(countJewels("ZZ", "z"))
}</lang>
{{Out}}See it in running in your browser by [https://scalafiddle.io/sf/Cz1HXAT/0 ScalaFiddle (JavaScript)] or by [https://scastie.scala-lang.org/7ZCCN5hISRuDqLWTKVBHow Scastie (JVM)].
=={{header|Sidef}}==
{{Output?}}
<lang ruby>func countJewels(s, j) {
s.chars.count { |c|
Anonymous user