RosettaCodeData/Task/Simple-turtle-graphics/Quackery/simple-turtle-graphics.quackery
2023-07-01 13:44:08 -04:00

52 lines
1.2 KiB
Text

[ $ "turtleduck.qky" loadfile ] now!
[ behead do
rot witheach
[ do 2over 2over
v< if 2swap
2drop ] ] is largest ( [ --> n/d )
[ 2 times
[ 2dup walk
-1 4 turn
2over walk
-1 4 turn ]
2drop 2drop ] is rectangle ( n/d n/d --> )
[ 2dup rectangle ] is square ( n/d --> )
[ 3 times
[ 2dup walk
1 3 turn ]
2drop ] is triangle ( n/d --> )
[ 1 2 turn
2dup square triangle
1 2 turn ] is house ( n/d --> )
[ stack ] is bar.width ( --> s )
[ stack ] is bar.scale ( --> s )
[ join temp put
dup size n->v
temp share do v/ 1/v
join bar.width put
dup largest
temp share do v/
join bar.scale put
witheach
[ do
bar.scale share do v/
bar.width share do
rectangle
bar.width share do fly ]
temp take do -v fly
bar.width release
bar.scale release ] is barchart ( [ n/d --> )
turtle
150 1 house
10 1 fly
' [ [ 1 2 ] [ 1 3 ] [ 2 1 ] [ 13 10 ] [ 1 2 ] ] 200 1 barchart
-10 1 fly