Write language name in 3D ASCII: Difference between revisions

From Rosetta Code
Content added Content deleted
Line 1: Line 1:
{{Draft task}}
{{Draft task}}
The task is to language's name in 3D ASCII. (We can leave the definition of "3D ASCII" fuzzy, so long as the result is interesting or amusing, not a cheap hack to satisfy the task.)
The task is to language's name in 3D ASCII. (We can leave the definition of "3D ASCII" fuzzy, so long as the result is interesting or amusing, not a cheap hack to satisfy the task.)

=={{header|Icon}} and {{header|Unicon}}==
The following fits under the fuzzy definition of 3D ASCII and pays homage to one of the Icon Newsletter logos.
<lang Icon>procedure main(arglist)
write(ExpandText(
if !arglist == "icon" then
"14/\\\n14\\/\n12/\\\n11/1/\n10/1/1/\\\n10\\/1/2\\\n12/1/\\1\\\n_
12\\1\\1\\/\n10/\\1\\1\\2/\\\n9/2\\1\\/1/2\\\n_
8/1/\\1\\2/1/\\1\\2/\\\n8\\1\\/1/2\\1\\/1/2\\1\\\n_
6/\\1\\2/4\\2/1/\\1\\1\\\n5/1/2\\/6\\/1/2\\1\\/\n_
/\\2/1/1/\\10/1/\\1\\2/\\\n\\/2\\1\\/1/10\\/1/1/2\\/\n_
2/\\1\\2/1/\\6/\\2/1/\n2\\1\\1\\/1/2\\4/2\\1\\/\n_
3\\1\\2/1/\\1\\2/1/\\1\\\n4\\/2\\1\\/1/2\\1\\/1/\n_
9\\2/1/\\1\\2/\n10\\/2\\1\\1\\/\n12/\\1\\1\\\n12\\1\\/1/\n_
13\\2/1/\\\n14\\/1/1/\n16/1/\n16\\/\n14/\\\n14\\/\n"
else
"13/\\\n12/1/\n11/1/1/\\\n11\\1\\/1/\n12\\2/1/\\\n13\\/1/2\\\n_
15/1/\\1\\2/\\\n15\\/1/1/2\\/\n17/1/1/\\18/\\\n17\\/1/1/17/2\\\n_
19/1/1/\\14/1/\\1\\\n19\\/1/2\\13\\1\\1\\/\n21/1/\\1\\10/\\1\\1\\\n_
21\\1\\1\\/10\\1\\1\\/\n19/\\1\\1\\2/\\6/\\1\\1\\\n_
18/2\\1\\/1/2\\5\\1\\/1/\n17/1/\\1\\2/1/\\1\\2/\\1\\2/\n_
17\\1\\/1/2\\1\\/1/2\\1\\1\\/\n15/\\1\\2/4\\2/1/\\1\\1\\\n_
14/1/2\\/6\\/1/2\\1\\/\n9/\\2/1/1/\\10/1/\\1\\2/\\\n_
9\\/2\\1\\/1/10\\/1/1/2\\/\n11/\\1\\2/1/\\6/\\2/1/\n_
11\\1\\1\\/1/2\\4/2\\1\\/\n9/\\1\\1\\2/1/\\1\\2/1/\\1\\\n_
8/2\\1\\/2\\1\\/1/2\\1\\/1/\n7/1/\\1\\5\\2/1/\\1\\2/\n_
7\\1\\1\\/6\\/2\\1\\1\\/\n5/\\1\\1\\10/\\1\\1\\\n_
5\\1\\1\\/10\\1\\/1/\n3/\\1\\1\\13\\2/1/\\\n3\\1\\/1/14\\/1/1/\n_
4\\2/17/1/1/\\\n5\\/18\\/1/1/\n23/\\2/1/1/\\\n23\\/2\\1\\/1/\n_
28\\2/1/\\\n29\\/1/2\\\n31/1/\\1\\\n31\\/1/1/\n33/1/\n33\\/\n"
))
end

procedure ExpandText(s)
s ? until pos(0) do
writes(repl(" ",tab(many(&digits)))|tab(upto(&digits)|0))
end</lang>

Sample output with "icon" as the argument:<pre> /\
\/
/\
/ /
/ / /\
\/ / \
/ /\ \
\ \ \/
/\ \ \ /\
/ \ \/ / \
/ /\ \ / /\ \ /\
\ \/ / \ \/ / \ \
/\ \ / \ / /\ \ \
/ / \/ \/ / \ \/
/\ / / /\ / /\ \ /\
\/ \ \/ / \/ / / \/
/\ \ / /\ /\ / /
\ \ \/ / \ / \ \/
\ \ / /\ \ / /\ \
\/ \ \/ / \ \/ /
\ / /\ \ /
\/ \ \ \/
/\ \ \
\ \/ /
\ / /\
\/ / /
/ /
\/
/\
\/</pre>


=={{header|J}}==
=={{header|J}}==

Revision as of 03:08, 7 August 2011

Write language name in 3D ASCII is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

The task is to language's name in 3D ASCII. (We can leave the definition of "3D ASCII" fuzzy, so long as the result is interesting or amusing, not a cheap hack to satisfy the task.)

Icon and Unicon

The following fits under the fuzzy definition of 3D ASCII and pays homage to one of the Icon Newsletter logos. <lang Icon>procedure main(arglist) write(ExpandText(

  if !arglist == "icon" then 
     "14/\\\n14\\/\n12/\\\n11/1/\n10/1/1/\\\n10\\/1/2\\\n12/1/\\1\\\n_
     12\\1\\1\\/\n10/\\1\\1\\2/\\\n9/2\\1\\/1/2\\\n_
     8/1/\\1\\2/1/\\1\\2/\\\n8\\1\\/1/2\\1\\/1/2\\1\\\n_
     6/\\1\\2/4\\2/1/\\1\\1\\\n5/1/2\\/6\\/1/2\\1\\/\n_
     /\\2/1/1/\\10/1/\\1\\2/\\\n\\/2\\1\\/1/10\\/1/1/2\\/\n_
     2/\\1\\2/1/\\6/\\2/1/\n2\\1\\1\\/1/2\\4/2\\1\\/\n_
     3\\1\\2/1/\\1\\2/1/\\1\\\n4\\/2\\1\\/1/2\\1\\/1/\n_
     9\\2/1/\\1\\2/\n10\\/2\\1\\1\\/\n12/\\1\\1\\\n12\\1\\/1/\n_
     13\\2/1/\\\n14\\/1/1/\n16/1/\n16\\/\n14/\\\n14\\/\n"
  else 
     "13/\\\n12/1/\n11/1/1/\\\n11\\1\\/1/\n12\\2/1/\\\n13\\/1/2\\\n_
    15/1/\\1\\2/\\\n15\\/1/1/2\\/\n17/1/1/\\18/\\\n17\\/1/1/17/2\\\n_
    19/1/1/\\14/1/\\1\\\n19\\/1/2\\13\\1\\1\\/\n21/1/\\1\\10/\\1\\1\\\n_
    21\\1\\1\\/10\\1\\1\\/\n19/\\1\\1\\2/\\6/\\1\\1\\\n_
    18/2\\1\\/1/2\\5\\1\\/1/\n17/1/\\1\\2/1/\\1\\2/\\1\\2/\n_
    17\\1\\/1/2\\1\\/1/2\\1\\1\\/\n15/\\1\\2/4\\2/1/\\1\\1\\\n_
    14/1/2\\/6\\/1/2\\1\\/\n9/\\2/1/1/\\10/1/\\1\\2/\\\n_
    9\\/2\\1\\/1/10\\/1/1/2\\/\n11/\\1\\2/1/\\6/\\2/1/\n_
    11\\1\\1\\/1/2\\4/2\\1\\/\n9/\\1\\1\\2/1/\\1\\2/1/\\1\\\n_
    8/2\\1\\/2\\1\\/1/2\\1\\/1/\n7/1/\\1\\5\\2/1/\\1\\2/\n_
    7\\1\\1\\/6\\/2\\1\\1\\/\n5/\\1\\1\\10/\\1\\1\\\n_
    5\\1\\1\\/10\\1\\/1/\n3/\\1\\1\\13\\2/1/\\\n3\\1\\/1/14\\/1/1/\n_
    4\\2/17/1/1/\\\n5\\/18\\/1/1/\n23/\\2/1/1/\\\n23\\/2\\1\\/1/\n_
    28\\2/1/\\\n29\\/1/2\\\n31/1/\\1\\\n31\\/1/1/\n33/1/\n33\\/\n"
    ))

end

procedure ExpandText(s) s ? until pos(0) do

     writes(repl(" ",tab(many(&digits)))|tab(upto(&digits)|0))

end</lang>

Sample output with "icon" as the argument:

              /\
              \/
            /\
           / /
          / / /\
          \/ /  \
            / /\ \
            \ \ \/
          /\ \ \  /\
         /  \ \/ /  \
        / /\ \  / /\ \  /\
        \ \/ /  \ \/ /  \ \
      /\ \  /    \  / /\ \ \
     / /  \/      \/ /  \ \/
/\  / / /\          / /\ \  /\
\/  \ \/ /          \/ / /  \/
  /\ \  / /\      /\  / /
  \ \ \/ /  \    /  \ \/
   \ \  / /\ \  / /\ \
    \/  \ \/ /  \ \/ /
         \  / /\ \  /
          \/  \ \ \/
            /\ \ \
            \ \/ /
             \  / /\
              \/ / /
                / /
                \/
              /\
              \/

J

<lang j> require 'vrml.ijs' NB. Due to Andrew Nikitin

  view 5#.^:_1]21-~a.i.'j*ez`C3\toy.G)'  NB.  Due to Oleg Kobchenko 
      ________________________    
     |\     \     \     \     \   
     | \_____\_____\_____\_____\  
     | |     |     |     |\     \ 
     |\|     |     |     | \_____\
     | \_____|_____|_____| |     |
     | |     |   | |     |\|     |
      \|     |   |\|     | \_____|
       \_____|   | \_____|        
                 | |     |        
                 |\|     |        
                 | \_____|        
______           | |     |        

|\ \ |\| | | \_____\_________|_\_____| | |\ \ \ \ |

\| \_____\_____\_____\   |        
 | |     |     |     |___|        
  \|     |     |     |            
   \_____|_____|_____|         

</lang>

For the VRML script, see Andrew Nikitin's J page (search for VRML) and for the origin of the 3D J banner, see Oleg Kobchenko's post to the J Forums.

ZX Spectrum Basic

We have used an extended (non ascii) character in this example to produce an inverted space symbol (143 on the spectrum character table), for simplicity. We could substitute another character, and change the handler to cause a colour switch using a traditional space (ascii 32), but the output would still look the same.

<lang zxbasic>10 LET s$="BASIC": REM our language name 20 DIM b(5,5):REM our bigmap characters 30 FOR l = 1 TO 5: REM 5 characters 40 FOR m = 1 TO 5: REM 5 rows 50 READ b(l,m) 60 NEXT m 70 NEXT l

100 PAPER 0: REM black background 110 INK 2: REM our shadow will be red 120 CLS 130 LET r=9: REM shadow will start on row 5 140 LET c=2: REM shadow will start at column 2 150 GO SUB 2000: REM draw shadow 160 INK 6: REM our forground will be yellow 170 LET r=10: REM foreground will start on row 6 180 LET c=3: REM foreground will start on column 3 190 GO SUB 2000: REM display the language name

999 STOP

1000 REM convert to binary bigmap 1010 LET t=n: REM temporary variable 1020 LET g$="": REM this will contain our 5 character binary bigmap 1040 FOR z=5 TO 0 STEP -1 1050 LET d$=" ": REM assume next digit is zero (draw a space) 1060 IF t>=(2^z) THEN LET d$=CHR$(143): LET t=t-(2^z): LET sf=1: REM 143 is a block 1070 LET g$=g$+d$ 1080 NEXT z 1090 RETURN

2000 REM display the big letters 2010 FOR l=1 TO 5: REM our 5 rows 2020 PRINT AT r+l-1,c; 2030 FOR m=1 TO 5: REM bigmap for each character 2040 LET n=b(l,m) 2050 GO SUB 1000 2060 PRINT g$;: REM 5 character bigmap 2070 PRINT " ";: REM space between each letter 2080 NEXT m 2090 NEXT l 2100 RETURN

9000 DATA 30,17,30,17,30: REM B 9010 DATA 14,17,31,17,17: REM A 9020 DATA 15,16,14,1,30: REM S 9030 DATA 31,4,4,4,31: REM I 9040 DATA 14,17,16,17,14: REM C</lang>