Hello world/Newline omission: Difference between revisions

m
 
(28 intermediate revisions by 14 users not shown)
Line 132:
==={{header|Applesoft BASIC}}===
<syntaxhighlight lang="applesoftbasic">PRINT "GOODBYE, WORLD!";</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">print "Goodbye, World!"; '' the trailing semi-colon suppresses the new line</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
Line 141 ⟶ 145:
60 print "(End of the world)"
70 end</syntaxhighlight>
{{out}}
'''Output:'''
<pre>Goodbye, World!(End of the world)
<pre>
Goodbye, World!(End of the world)
 
ready.</pre>
</pre>
 
==={{header|BASIC256}}===
Line 153 ⟶ 155:
print " ";
print "World!";</syntaxhighlight>
 
==={{header|GW-BASIC}}===
{{works with|BASICA}}
<syntaxhighlight lang="qbasic">10 PRINT "Goodbye, World!"; '' the trailing semi-colon suppresses the new line</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basicqbasic">10 PRINT "Goodbye, World! ";</syntaxhighlight>
 
==={{header|Minimal BASIC}}===
<syntaxhighlight lang="qbasic">10 PRINT "Goodbye, World!"; : REM the trailing semi-colon suppresses the new line
20 END</syntaxhighlight>
 
==={{header|MSX Basic}}===
<syntaxhighlight lang="qbasic">10 PRINT "Goodbye, World!"; : REM the trailing semi-colon suppresses the new line</syntaxhighlight>
 
==={{header|QBasic}}===
Line 164 ⟶ 177:
<syntaxhighlight lang="qbasic">PRINT "Goodbye, World!";
END</syntaxhighlight>
 
==={{header|Quite BASIC}}===
<syntaxhighlight lang="qbasic">10 PRINT "Goodbye, World!"; : REM the trailing semi-colon suppresses the new line</syntaxhighlight>
 
==={{header|True BASIC}}===
Line 172 ⟶ 188:
<syntaxhighlight lang="qbasic">PRINT "Goodbye, World!";
END</syntaxhighlight>
 
==={{header|XBasic}}===
<syntaxhighlight lang="qbasic">PROGRAM "helloworld"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
PRINT "Goodbye, World!";
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
Line 203 ⟶ 230:
NEXT</syntaxhighlight>
 
=={{header|Bcbc}}==
<syntaxhighlight lang="bc">print "Goodbye, World!"</syntaxhighlight>
 
=={{header|beeswax}}==
Line 215 ⟶ 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
 
<pre>*Goodbye, World!</pre>
 
=={{header|Blade}}==
Line 221 ⟶ 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 276 ⟶ 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 348 ⟶ 378:
void main() {
write("Goodbye, World!");
}</syntaxhighlight>
 
=={{header|Dart}}==
<syntaxhighlight lang="dart">import 'dart:io';
void main() {
stdout.write("Goodbye, World!");
}</syntaxhighlight>
 
Line 362 ⟶ 399:
Write('Goodbye, World!');
end.</syntaxhighlight>
 
=={{header|dt}}==
<syntaxhighlight lang="dt">"Goodbye, World!" p</syntaxhighlight>
 
=={{header|DWScript}}==
Line 400 ⟶ 440:
=={{header|Déjà Vu}}==
<syntaxhighlight lang="dejavu">!print\ "Goodbye, World!"</syntaxhighlight>
 
=={{header|EasyLang}}==
<syntaxhighlight>
# write omits newline
write "Goodbye, World!"
 
</syntaxhighlight>
 
=={{header|EchoLisp}}==
Line 427 ⟶ 474:
 
Goodbye, World!
 
=={{header|EMal}}==
<syntaxhighlight lang="emal">write("Goodbye, World!")</syntaxhighlight>
 
=={{header|Erlang}}==
Line 467 ⟶ 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 499 ⟶ 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 546 ⟶ 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 678 ⟶ 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 703 ⟶ 782:
}
}</syntaxhighlight>
 
=={{header|Jakt}}==
<syntaxhighlight lang="jakt">
fn main() {
print("Goodbye, World!")
}
</syntaxhighlight>
 
=={{header|Janet}}==
Line 719 ⟶ 805:
Node JS:
<syntaxhighlight lang="javascript">process.stdout.write("Goodbye, World!");</syntaxhighlight>
 
=={{header|Joy}}==
<syntaxhighlight lang="joy">"Goodbye, World!" putchars.</syntaxhighlight>
 
=={{header|jq}}==
Line 745 ⟶ 834:
{{trans|Java}}
<syntaxhighlight lang="scala">fun main(args: Array<String>) = print("Goodbye, World!")</syntaxhighlight>
 
=={{header|Lang}}==
<syntaxhighlight lang="lang">fn.print(Goodbye, World!)</syntaxhighlight>
 
=={{header|Lasso}}==
Line 809 ⟶ 901:
=={{header|Lua}}==
<syntaxhighlight lang="lua">io.write("Goodbye, World!")</syntaxhighlight>
 
=={{header|M2000 Interpreter}}==
 
<syntaxhighlight lang="m2000 interpreter">
Form 80, 45
// set no special format, 8 character column, at 0,0 position, row (top left)
Print $("", 8),@(0,0),
// semi colon
Module Test1 {
Print "Goodbye, "; 'The semicolon stops the newline being added
Print "World!"
}
// comma
Module Test2 {
Print 1,
Print 2,
Print 3,
Print // now we change line
For i=4 to 30 : Print i,: Next
// lines changed according the use of columns
}
Test1
Test2
// we can mix ; and ,
Print "aaa ";1, "bbb ";2, "ccc ";3
</syntaxhighlight>
 
 
=={{header|m4}}==
Line 831 ⟶ 950:
=={{header|MATLAB}} / {{header|Octave}}==
<syntaxhighlight lang="matlab"> fprintf('Goodbye, World!');</syntaxhighlight>
 
=={{header|Microsoft Small Basic}}==
<syntaxhighlight lang="smallbasic">TextWindow.Write("Goodbye, World!")</syntaxhighlight>
{{out}}
<pre>Goodbye, World!Press any key to continue...</pre>
 
=={{header|min}}==
Line 1,259 ⟶ 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}}==
{{works with|Vale|0.2.0}}
<syntaxhighlight lang="vale">
import stdlib.*;
 
exported func main() {
print("Goodbye, World!");
}
</syntaxhighlight>
 
=={{header|Verbexx}}==
<syntaxhighlight lang="verbexx">@STDOUT "Goodbye, World!";</syntaxhighlight>
 
 
=={{header|Verilog}}==
Line 1,296 ⟶ 1,444:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">System.write("Goodbye, World!")</syntaxhighlight>
 
=={{header|XLISP}}==
Line 1,330 ⟶ 1,478:
20 PRINT "Goodbye, World!";</syntaxhighlight>
 
{{omit from|Craft Basic|No keyword to output without newline}}
{{omit from|SQL PL|It does not provide a command to not add a new line. There is not CALL DBMS_OUTPUT.CURRENT_LINE, only CALL DBMS_OUTPUT.NEW_LINE}}
56

edits