Self-describing numbers: Difference between revisions

add CLU
(Add Cowgol)
(add CLU)
Line 863:
6210001000
</pre>
 
=={{header|CLU}}==
<syntaxhighlight lang="clu">self_describing = proc (n: int) returns (bool)
digits: array[int] := array[int]$predict(10, 10)
counts: array[int] := array[int]$fill(0, 10, 0)
 
while n > 0 do
digit: int := n // 10
n := n/10
array[int]$addl(digits, digit)
counts[digit] := counts[digit] + 1
end
 
array[int]$set_low(digits, 0)
 
for pos: int in array[int]$indexes(digits) do
if counts[pos] ~= digits[pos] then return(false) end
end
return(true)
end self_describing
 
start_up = proc ()
po: stream := stream$primary_output()
for n: int in int$from_to(1, 100000000) do
if self_describing(n) then
stream$putl(po, int$unparse(n))
end
end
end start_up</syntaxhighlight>
{{out}}
<pre>1210
2020
21200
3211000
42101000</pre>
 
=={{header|Common Lisp}}==
2,112

edits