Jewels and stones: Difference between revisions

Add CLU
(Add Red)
(Add CLU)
Line 625:
<pre>3
0</pre>
 
=={{header|CLU}}==
<lang clu>count_jewels = proc (jewels, stones: string) returns (int)
is_jewel: array[bool] := array[bool]$fill(0, 256, false)
for c: char in string$chars(jewels) do
is_jewel[char$c2i(c)] := true
end
n_jewels: int := 0
for c: char in string$chars(stones) do
if is_jewel[char$c2i(c)] then n_jewels := n_jewels + 1 end
end
return (n_jewels)
end count_jewels
 
show = proc (jewels, stones: string)
po: stream := stream$primary_output()
stream$putl(po, "\"" || jewels || "\" in \"" || stones || "\": "
|| int$unparse(count_jewels(jewels, stones)))
end show
 
start_up = proc ()
show("aA", "aAAbbbb")
end start_up</lang>
{{out}}
<pre>"aA" in "aAAbbbb": 3</pre>
 
=={{header|Cowgol}}==
2,114

edits