Hello world/Newline omission: Difference between revisions

m
(Omit Craft Basic)
(15 intermediate revisions by 8 users not shown)
Line 242:
 
<syntaxhighlight lang="befunge">"!dlroW ,eybdooG">:#,_@</syntaxhighlight>
 
=={{header|Binary Lambda Calculus}}==
 
Starting a program with any of the 16 ASCII characters from space to slash will copy the remainder to stdout, so for example
 
DISPLAY '<pre>*Goodbye, World!'</pre>
 
=={{header|Blade}}==
Line 248 ⟶ 254:
=={{header|bootBASIC}}==
"Goodbye, w" and "orld!" are printed on different lines because not enough characters are allowed per line to complete this task in one line, even for the most code golfed version.
<syntaxhighlight lang="bootbasicBASIC">10 print "Goodbye, w";
20 print "orld!";</syntaxhighlight>
 
Line 303 ⟶ 309:
 
=={{header|COBOL}}==
<syntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. GOODBYE-WORLD.
PROCEDURE DIVISION.
 
DISPLAY 'Goodbye, World!' WITH NO ADVANCING.
PROCEDURE DIVISION.
STOP RUN.
DISPLAY 'Goodbye, World!'
END PROGRAM GOODBYE-WORLD.</syntaxhighlight>
WITH NO ADVANCING
END-DISPLAY
.
STOP RUN.</syntaxhighlight>
 
=={{header|CoffeeScript}}==
Line 439 ⟶ 442:
 
=={{header|EasyLang}}==
<syntaxhighlight lang="easylang">write "Goodbye, World!"</syntaxhighlight>
# write omits newline
write echo("Goodbye, World!")
 
STOP RUN.</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 510 ⟶ 517:
=={{header|Fantom}}==
 
<syntaxhighlight lang="fantomjava">
class Main {
Void main() {
// Print with newline
echo("Goodbye, World!")
echo("Hello, World!")
// Or
Env.cur.out.printLine("Hello, World!")
 
// Print without a newline
Env.cur.out.print("Goodbye, world!")
 
// Also can get a reference to the standard output stream
out := Env.cur.out
 
out.print("Goodbye, world!")
out.flush() // and flush buffer if needed
// or method chain
out.print("Goodbye, world!").flush()
 
// Also we can an implement a user-defined method
print("Hello, world! I'm back!");
 
}
// User-defined 'print' method
private Void print(Str s) {
Env.cur.out.print(s)
}
 
}
</syntaxhighlight>
Line 542 ⟶ 573:
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasicbasic">' FB 1.0510.01 Win64
 
Print "Goodbye, World!"; '' the trailing semi-colon suppresses the new line
Sleep</syntaxhighlight>
 
Line 589 ⟶ 620:
=={{header|Gambas}}==
'''[https://gambas-playground.proko.eu/?gist=09c8c3464c556325f089f9e4c326eaca Click this link to run this code]'''
<syntaxhighlight lang="gambasbasic">Public Sub Main()
 
Print "Goodbye, "; 'The semicolon stops the newline being added
Line 721 ⟶ 752:
 
=={{header|J}}==
With ''jconsole'', <code>stdout</code> can be used.
On a linux system, you can use 1!:3 because stdout is a file:
<syntaxhighlight lang="j"> 'Goodbye, World!' 1!:3 <'/proc/self/fd/1'stdout
Goodbye, World1! :2&4</syntaxhighlight>
<code>1!:2&4</code> returns its input unmodified. To avoid implicit output (which would repeat the output), when used interactively:
However, J works in environments other than Linux, so...
<syntaxhighlight lang="j"> put=: 0 0 $ 1!:2&4
 
put 'Goodbye, World!'
Goodbye, World!</syntaxhighlight>
However, J also works in graphical environments, which might not be connected to standard output.
'''Solution''':<code>prompt</code> from the misc package.
'''Example''':<syntaxhighlight lang="j"> load 'general/misc/prompt'
prompt 'Goodbye, World!'
Goodbye, World!</syntaxhighlight>
'''Notes''': J programs are normally run from a REPL, or session manager, which comes in several flavors. The traditional commandline-based terminal (jconsole), one of several desktop applications (jqt for the current version of J, jgtk and jwd for older but still supported versions), a web-based frontend (jhs), and various mobile apps (J for iOS, Android).
 
The specific session manager being used changes the context and therefore answer to this task. For example, when using J from a browser (including mobile browsers) newlines are omitted by default. Further, J provides strong tools for coalescing results and manipulating them prior to output, so newline elimination would typically happen before output rather than after.
 
With that said, <code>prompt</code> handles the most common cases (using binary output for jconsole, so no newline is appended; adjusting the REPL prompt in the desktop apps to to elide the newline which is normally included by default, etc).
 
For truly automated processes, you'd almost always want this kind of functionality (omitting the newline when printing) in a file- or stream-oriented application. For those cases, the simple <code>text 1!:3 file</code> will append the text to the referenced file verbatim, without inserting any extra newlines.
 
So, if a J programmer were asked to solve this task, the right approach would be to ask why that is needed, and then craft a solution appropriate to that situation.
Line 1,347 ⟶ 1,383:
Ursa doesn't output a newline to an I/O device by default, so simply omitting an endl object at the end of the output stream is all that's needed.
<syntaxhighlight lang="ursa">out "goodbye world!" console</syntaxhighlight>
 
=={{header|Uxntal}}==
<syntaxhighlight lang="Uxntal">|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
 
|0100
;message
&loop
LDAk .Console/write DEO
INC2 LDAk ?&loop
POP2
#80 .System/state DEO
BRK
 
@message "Goodbye, 20 "World! 00</syntaxhighlight>
 
=={{header|Vale}}==
Line 1,393 ⟶ 1,444:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">System.write("Goodbye, World!")</syntaxhighlight>
 
=={{header|XLISP}}==
56

edits