Draw a cuboid: Difference between revisions

Content added Content deleted
(→‎{{header|MiniScript}}: corrected solution to use required 2x3x4 dimensions)
(Added Forth entry)
Line 1,064: Line 1,064:
{{out}}
{{out}}
[https://i.imgur.com/JQMPjhk.png]
[https://i.imgur.com/JQMPjhk.png]

=={{header|Forth}}==
{{works with|gforth|0.7.3}}
{{trans|PicoLisp}}

<syntaxhighlight lang="Forth">: line ( e dy d dx c n -- )
spaces dup >r emit
9 * 1- 0 do dup emit loop drop
r> emit
spaces emit cr
;

: cuboid { dz dy dx -- }
cr
bl 0 '- dx '+ dy 1+ line
dy 0 ?do
'| i bl dx '/ dy i - line loop
'| dy '- dx '+ 0 line
dz 4 * dy - 2 - 0 ?do
'| dy bl dx '| 0 line loop
'+ dy bl dx '| 0 line
dy 0 ?do
'/ dy i - 1- bl dx '| 0 line loop
bl 0 '- dx '+ 0 line
;</syntaxhighlight>
{{Out}}
<pre>
4 3 2 cuboid
+-----------------+
/ /|
/ / |
/ / |
+-----------------+ |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | +
| | /
| | /
| |/
+-----------------+
ok
1 1 1 cuboid
+--------+
/ /|
+--------+ |
| | |
| | +
| |/
+--------+
ok
1 2 6 cuboid
+-----------------------------------------------------+
/ /|
/ / |
+-----------------------------------------------------+ |
| | +
| | /
| |/
+-----------------------------------------------------+
ok
</pre>





=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==