Print itself: Difference between revisions

Content added Content deleted
(Add Ecstasy example)
(J)
Line 80: Line 80:
$ go run self_print.go
$ go run self_print.go
</pre>
</pre>

=={{header|J}}==

In J's command line environment, many programs, including the empty program (is nothing, takes no arguments, produces nothing), print themselves to standard output. This is especially true when the language has been configured (with <code>9!:3(5)</code>) to present verbs using their linear representation (which is highly recommendable as part of the system profile for most J users). But numeric constants can be thought of as programs which take no arguments and have themselves as their result.

For example:

<syntaxhighlight lang=J> 1
1
2 3 5
2 3 5
+/ % #
+/ % #</syntaxhighlight>

Though, of course, it's also true that these programs can be assembled as components in larger programs.

<syntaxhighlight lang=J> prim=: 2 3 5
mean=: +/ % #
mean prim
3.33333</syntaxhighlight>


=={{header|jq}}==
=={{header|jq}}==
Line 92: Line 112:
0
0
</pre>
</pre>



=={{header|Julia}}==
=={{header|Julia}}==