Quine: Difference between revisions

m
→‎Processing - Console with immediate mode: add char and string template explanation
m (→‎Processing - Console with immediate mode: add comment on print vs System.out.printf)
m (→‎Processing - Console with immediate mode: add char and string template explanation)
Line 3,116:
<lang Processing>String p="String p=%c%s%1$c;System.out.printf(p,34,p);";System.out.printf(p,34,p);</lang>
 
This takes advantage of the fact that Processing does not require a wrapping class or main method (unlike the Java it is based on). Further, Processing "immediate mode" without setup() or draw() methods does not require a method or function at all, and instead can compile and run direct commands. Processing normally uses "print", and calling the undocumented "System.out.printf" from Java is not idiomatic. However that is used here because it gives easy access to string templating. In printf(p,34,p) the template p is passed two arguments: 34 is inserted into %c and the back-reference %1$c, where they each become an ASCII quote character, while p (itself) is inserted at %s.
 
=== Graphical output ===