Yin and yang: Difference between revisions

Add CLU
(Add Modula-2)
(Add CLU)
Line 1,692:
 
Image: [https://upload.wikimedia.org/wikipedia/commons/a/af/Yin_and_yang_problem_c_sharp.png Yin_and_yang_problem_c_sharp.png]
 
=={{header|CLU}}==
<lang clu>taijitu = cluster is make
rep = null
circle = proc (x,y,c,r: int) returns (bool)
return (r**2 >= (x/2)**2 + (y-c)**2)
end circle
pixel = proc (x,y,r: int) returns (char)
if circle(x,y,-r/2,r/6) then return('#')
elseif circle(x,y, r/2,r/6) then return('.')
elseif circle(x,y,-r/2,r/2) then return('.')
elseif circle(x,y, r/2,r/2) then return('#')
elseif circle(x,y, 0, r) then
if x<0 then return('.') else return('#') end
end
return(' ')
end pixel
make = proc (r: int) returns (string)
chars: array[char] := array[char]$predict(1, r*r*2+r)
for y: int in int$from_to(-r, r) do
for x: int in int$from_to(-2*r, 2*r) do
array[char]$addh(chars, pixel(x,y,r))
end
array[char]$addh(chars, '\n')
end
return (string$ac2s(chars))
end make
end taijitu
 
start_up = proc ()
po: stream := stream$primary_output()
stream$putl(po, taijitu$make(4))
stream$putl(po, taijitu$make(8))
end start_up</lang>
{{out}}
<pre> ..
........##
......##....##
..........####
..........#######
....##########
..####..######
..########
##
 
..
............##
..................####
............##......######
..........######......####
..............##......########
......................########
....................##########
..................###############
..........####################
........######################
........######..##############
....######......##########
......######..############
....##################
..############
##</pre>
 
=={{header|D}}==
2,093

edits