Hello world/Newline omission: Difference between revisions

From Rosetta Code
Content added Content deleted
(Emacs Lisp: Make code actually print)
m (Emacs Lisp: Fix formatting)
Line 419: Line 419:


=={{header|Emacs Lisp}}==
=={{header|Emacs Lisp}}==
<lang Emacs Lisp>(princ "Goodbye, World!")</lang>


<lang Lisp>(princ "Goodbye, World!")</lang>
{{out}}

Goodbye, World!


=={{header|Erlang}}==
=={{header|Erlang}}==

Revision as of 21:26, 7 February 2022

Task
Hello world/Newline omission
You are encouraged to solve this task according to the task description, using any language you may know.

Some languages automatically insert a newline after outputting a string, unless measures are taken to prevent its output.


Task

Display the string   Goodbye, World!   without a trailing newline.


Related tasks



11l

<lang 11l>print(‘Goodbye, World!’, end' ‘’)</lang>

68000 Assembly

Because assembly lets (or rather forces) the programmer to create their own print routines, new lines are not done by default.

Code is called as a subroutine, taking A0 as its argument (e.g. LEA myString,A0 JSR PrintString). The hardware-specific PrintChar routine is left unimplemented. <lang 68000devpac>PrintString:

input
A0 = source address
outputs to screen.

MOVE.B (A0)+,D0 BEQ Terminated JSR PrintChar BRA PrintString Terminated:

If this routine did in fact put a new line by default, it would do so here with the following
MOVE.B #13,D0 ;13 is ascii for Carriage Return (moves cursor back to beginning of row).
JSR PrintChar
MOVE.B #10,D0 ;10 is ascii for Line Feed (moves cursor down one line).
JSR PrintChar

RTS

myString: DC.B "Goodbye, World!",0 EVEN</lang>

ACL2

<lang lisp>(cw "Goodbye, World!")</lang>

Action!

<lang Action!>PROC Main()

 Print("Goodbye, World!")

RETURN</lang>

Output:

Screenshot from Atari 8-bit computer

Goodbye, World!

Ada

This example will implicitly include a final, implementation defined, terminator (usually a linefeed) if the output is a file (RM A.10.7-8) such as stdout on UNIX systems. <lang ada> with Ada.Text_IO;

procedure Goodbye_World is begin

  Ada.Text_IO.Put("Goodbye, World!");

end Goodbye_World; </lang> Using Ada.Text_IO.Text_Streams instead allows us to control the termination. <lang ada> with Ada.Text_IO; with Ada.Text_IO.Text_Streams;

procedure Goodbye_World is

   stdout: Ada.Text_IO.File_Type := Ada.Text_IO.Standard_Output;

begin

   String'Write(Ada.Text_IO.Text_Streams.Stream(stdout), "Goodbye World");

end Goodbye_World; </lang>

Agena

<lang agena>io.write( "Goodbye, World!" )</lang>

ALGOL 68

This works with Algol68 Genie 2.8.2 and above. Earlier versions appended a gratuitous newline on unflushed output when the program terminated. <lang algol68>BEGIN

  print ("Goodbye, World!")

END</lang>

Arturo

<lang arturo>prints "Goodbye, World!"</lang>

Output:
Goodbye, World!

ATS

<lang ATS>implement main0 () = print "Goodbye, World!"</lang>

AutoHotkey

<lang AHK>DllCall("AllocConsole") FileAppend, Goodbye`, World!, CONOUT$ ; No newline outputted MsgBox</lang>

AutoIt

<lang AutoIt> ConsoleWrite("Goodbye, World!") </lang>

AWK

<lang AWK> BEGIN { printf("Goodbye, World!") } </lang>

Axe

<lang axe>Disp "Goodbye, World!"</lang>

B

Works with: The Amsterdam Compiler Kit - B version V6.1pre1

<lang B>main() {

   putstr("Goodbye, World!");
   return(0);

}</lang>

BASIC

<lang basic>10 REM The trailing semicolon prevents a newline 20 PRINT "Goodbye, World!";</lang>

BaCon

BaCon supports BASIC PRINT ending with trailing semicolon to prevent a newline and also supports a FORMAT clause that uses printf specifications and special character escapes (with no \n, there is no newline). <lang freebasic>PRINT "Goodbye, World!"; PRINT "Goodbye, World!" FORMAT "%s"</lang>

Applesoft BASIC

<lang ApplesoftBasic>PRINT "GOODBYE, WORLD!";</lang>

Commodore BASIC

<lang basic>10 print chr$(14) : rem Switch to lower+uppercase character set 20 print "Goodbye, World!"; 30 rem * If we end this program here, we will not see the effect because 40 rem BASIC will print 'READY' at a new line anyway. 50 rem * So, we just print additional message... 60 print "(End of the world)" 70 end</lang> Output:

Goodbye, World!(End of the world)

ready.

BASIC256

Output all on a single line. <lang BASIC256>print "Goodbye,"; print " "; print "World!";</lang>

IS-BASIC

<lang IS-BASIC>10 PRINT "Goodbye, World! ";</lang>

QBasic

Works with: FreeBASIC
Works with: True BASIC
Works with: Yabasic

A trailing semicolon prevents a newline <lang qbasic>PRINT "Goodbye, World!"; END</lang>

True BASIC

Works with: FreeBASIC
Works with: QBasic
Works with: Yabasic

A trailing semicolon prevents a newline <lang qbasic>PRINT "Goodbye, World!"; END</lang>

Yabasic

Works with: FreeBASIC
Works with: QBasic
Works with: True BASIC

A trailing semicolon prevents a newline <lang yabasic>print "Goodbye, World!"; end</lang>

Batch File

Under normal circumstances, when delayed expansion is disabled
The quoted form guarantees there are no hidden trailing spaces after World! <lang dos><nul set/p"=Goodbye, World!" <nul set/p=Goodbye, World!</lang>

If delayed expansion is enabled, then the ! must be escaped
Escape once if quoted form, twice if unquoted. <lang dos>setlocal enableDelayedExpansion <nul set/p"=Goodbye, World^!" <nul set/p=Goodbye, World^^^!</lang>

BBC BASIC

<lang bbcbasic> REM BBC BASIC accepts the standard trailing semicolon:

     PRINT "Goodbye World!";
     
     REM One could also output the characters individually:
     GW$ = "Goodbye World!"
     FOR i% = 1 TO LEN(GW$)
       VDU ASCMID$(GW$, i%)
     NEXT</lang>

Bc

<lang Bc>print "Goodbye, World!"</lang>

beeswax

<lang beeswax>_`Goodbye, World!</lang>

beeswax prints everything without appending a newline character. beeswax has an instruction to explicitely print a newline character: N.

Befunge

In Befunge, a newline has to be explicitly output when required, so you can just not include one if it's not wanted.

<lang befunge>"!dlroW ,eybdooG">:#,_@</lang>

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. <lang bootBASIC>10 print "Goodbye, w"; 20 print "orld!";</lang>

Bracmat

<lang bracmat>put$"Goodbye, World!"</lang>

Brainf***

One option was to copy the code from the regular Hello World version and omit the last period, but one of the nicer things about the language is that no matter how simple your program is, if it's more than a few characters long, it's probably unique. So here's yet another version of Goodbye, World in Brainf***. <lang bf>>+++++[>++++>+>+>++++>>+++<<<+<+<++[>++>+++>+++>++++>+>+[<]>>-]<-]>> +.>>+..<.--.++>>+.<<+.>>>-.>++.[<]++++[>++++<-]>.>>.+++.------.<-.[>]<+.[-] [G oo d b y e , W o r l d  !]</lang>

C

In C, we do not get a newline unless we embed one: <lang c>#include <stdio.h>

  1. include <stdlib.h>

int main(int argc, char *argv[]) {

 (void) printf("Goodbye, World!");    /* No automatic newline */
 return EXIT_SUCCESS;

}</lang>

However ISO C leaves it up to implementations to define whether or not the last line of a text stream requires a new-line. This means that the C can be targetted to environments where this task is impossible to implement, at least with a direct text stream manipulation like this.

C#

<lang csharp>using System;

class Program {

   static void Main(string[] args)
   {
       //Using Console.WriteLine() will append a newline
       Console.WriteLine("Goodbye, World!");
       //Using Console.Write() will not append a newline
       Console.Write("Goodbye, World!");
   }

}</lang>

C++

<lang cpp>#include <iostream>

int main() {

 std::cout << "Goodbye, World!";
 return 0;

}</lang>

Clipper

<lang Clipper>?? "Goodbye, World!"</lang>

Clojure

<lang clojure>(print "Goodbye, World!")</lang>

COBOL

<lang cobol>IDENTIFICATION DIVISION. PROGRAM-ID. GOODBYE-WORLD.

PROCEDURE DIVISION. DISPLAY 'Goodbye, World!'

   WITH NO ADVANCING

END-DISPLAY . STOP RUN.</lang>

CoffeeScript

Node JS: <lang coffeescript>process.stdout.write "Goodbye, World!"</lang>

Common Lisp

<lang lisp>(princ "Goodbye, World!")</lang>

Creative Basic

<lang Creative Basic> 'In a window

DEF Win:WINDOW DEF Close:CHAR DEF ScreenSizeX,ScreenSizeY:INT

GETSCREENSIZE(ScreenSizeX,ScreenSizeY)

WINDOW Win,0,0,ScreenSizeX,ScreenSizeY,0,0,"Goodbye program",MainHandler

PRINT Win,"Goodbye, World!" 'Prints in the upper left corner of the window (position 0,0). PRINT"Win," I ride off into the sunset."

'There does not appear to be a means of starting a new line when printing in a window, other than by using the MOVE command. 'Therefore, both sentences here will print on the same line, i.e., in the same vertical position.

WAITUNTIL Close=1

CLOSEWINDOW Win

END

SUB MainHandler

   IF @CLASS=@IDCLOSEWINDOW THEN Close=1   

RETURN

'In the console

OPENCONSOLE

'Insert a trailing comma. PRINT"Goodbye, World!", PRINT" I ride off into the sunset."

PRINT:PRINT"Press any key to end."

DO:UNTIL INKEY$<>""

CLOSECONSOLE

'Since this a Cbasic console program. END </lang>

D

Works with: D version 2.0

<lang D>import std.stdio;

void main() {

   write("Goodbye, World!");

}</lang>

Dc

<lang Dc>[Goodbye, World!]P</lang> <lang Dc>370913249815566165486152944077005857 P</lang>

Delphi

<lang Delphi>program Project1;

{$APPTYPE CONSOLE}

begin

 Write('Goodbye, World!');

end.</lang>

DWScript

<lang Delphi>Print('Goodbye, World!');</lang>

Dyalect

<lang Dyalect>print("Goodbye, World!", terminator: "")</lang>

Dylan.NET

Works with: Mono version 2.6.7
Works with: Mono version 2.10.x
Works with: Mono version 3.x.y
Works with: .NET version 3.5
Works with: .NET version 4.0
Works with: .NET version 4.5

One Line version: <lang Dylan.NET>Console::Write("Goodbye, World!")</lang> Goodbye World Program: <lang Dylan.NET> //compile using the new dylan.NET v, 11.5.1.2 or later //use mono to run the compiler

  1. refstdasm mscorlib.dll

import System

assembly gdbyeex exe ver 1.2.0.0

class public Program

  method public static void main()
     Console::Write("Goodbye, World!")
  end method

end class </lang>

Déjà Vu

<lang dejavu>!print\ "Goodbye, World!"</lang>

EchoLisp

<lang lisp> (begin

   (write "GoodBye, World")
   (write "Next on same line"))

</lang>

Elena

ELENA 4.x: <lang elena>public program() {

   //print will not append a newline
   console.write("Goodbye, World!")

}</lang>

Elixir

<lang elixir> IO.write "Goodbye, World!" </lang>

Emacs Lisp

<lang Lisp>(princ "Goodbye, World!")</lang>

Erlang

In erlang a newline must be specified in the format string. <lang erlang>io:format("Goodbye, world!").</lang>

ERRE

<lang ERRE> ....... PRINT("Goodbye, World!";) ....... </lang>

Euphoria

<lang euphoria>-- In Euphoria puts() does not insert a newline character after outputting a string puts(1,"Goodbye, world!")</lang>

F#

<lang fsharp> // A program that will run in the interpreter (fsi.exe) printf "Goodbye, World!";;

// A compiled program [<EntryPoint>] let main args =

   printf "Goodbye, World!"
   0 

</lang>

Factor

<lang factor>USE: io "Goodbye, World!" write</lang>

Falcon

With the print() function: <lang falcon>print("Goodbye, World!")</lang> Or via "fast print": <lang falcon>>> "Goodbye, World!"</lang>

Fantom

<lang fantom> class Main {

 Void main() {
   echo("Goodbye, World!")
 }

} </lang>

FOCAL

FOCAL does not insert a newline unless we specifically request one. <lang focal>TYPE "Goodbye, World!"</lang>

Forth

<lang Forth>\ The Forth word ." does not insert a newline character after outputting a string ." Goodbye, World!"</lang>

Fortran

<lang Fortran>program bye

 write (*,'(a)',advance='no') 'Goodbye, World!'

end program bye</lang>

The "advance" facility was introduced with F90, as was the ability to specify format instructions (the '(A)' part) without a separate FORMAT statement. Earlier, there was a common extension: <lang Fortran> WRITE (6,1) "Goodbye, World!"

   1 FORMAT (A,$)
     END</lang>

In this, the FORMAT instruction is to accept alphabetic text (the A) from the WRITE statement, followed by the special $ item (of no mnemonic form) which signified that there was not to be any new line action at the end of the output. This sort of thing is useful when writing a prompt to the screen so that the input of the response appears on the same screen line. The text could also have been incorporated into the FORMAT statement, which would be useful if there were many WRITE statements scattered about that were to send forth the same text.

These facilities only became of interest when, instead of card decks and lineprinters, I/O involved a keyboard and screen with both input and output appearing on the same screen. Thus, in earlier Fortran usage, the issue would not arise for output to a lineprinter, because it was already the case: a line written to the lineprinter was not followed by a end-of-line/start-new-line sort of action by the lineprinter. It stayed put on the line just written. It was the following output to the lineprinter that would state "advance one" (or two, or, no) lines at the start of its output. This was the "carriage control character", and a 1 signified "skip to top-of-form" which is to say, start a new page.

In other words, the Fortran approach for output was <carriage control><output text> rather than the <output text><carriage control> sequence, that now has to be suppressed by the "advance = 'no'" facility.

FreeBASIC

<lang freebasic>' FB 1.05.0 Win64

Print "Goodbye, World!"; the trailing semi-colon suppresses the new line Sleep</lang>

Frink

<lang Frink>print["Goodbye, World!"]</lang>

Gambas

Click this link to run this code <lang gambas>Public Sub Main()

Print "Goodbye, "; 'The semicolon stops the newline being added Print "World!"

End</lang> Output:

Goodbye, World!

gecho

This example is incorrect. Please fix the code and remove this message.

Details: output isn't consistent with the task's requirements: wording, capitalization of the 2nd word.

<lang gecho>'Hello, <> 'world! print</lang>

Genie

<lang genie>[indent=4] /*

 Hello, with no newline, in Genie
 valac helloNoNewline.gs
  • /

init

   stdout.printf("%s", "Goodbye, World!")</lang>
Output:
prompt$ valac helloNoNewline.gs
prompt$ ./helloNoNewline
Goodbye, World!prompt$

GML

<lang lisp>show_message("Goodbye, World!")</lang>

Go

<lang go>package main

import "fmt"

func main() { fmt.Print("Goodbye, World!") }</lang>

Groovy

<lang groovy>print "Goodbye, world"</lang>

GUISS

In Graphical User Interface Support Script, we specify a newline, if we want one. The following will not produce a newline: <lang GUISS>Start,Programs,Accessories,Notepad,Type:Goodbye World[pling]</lang>

Harbour

<lang visualfoxpro>?? "Goodbye, world" or QQout( "Goodbye, world" ) </lang>

Haskell

<lang haskell>main = putStr "Goodbye, world"</lang>

HolyC

<lang holyc>"Goodbye, World!";</lang>

Io

<lang io> write("Goodbye, World!") </lang>

Huginn

<lang huginn>#! /bin/sh exec huginn --no-argv -E "${0}" "${@}"

  1. ! huginn

main() { print( "Goodbye, World!" ); return ( 0 ); }</lang>

Icon and Unicon

Native output in Icon and Unicon is performed via the write and writes procedures. The write procedure terminates each line with both a return and newline (for consistency across platforms). The writes procedure omits this. Additionally, the programming library has a series of printf procedures as well. <lang Icon>procedure main()

  writes("Goodbye, World!")    

end</lang>

IWBASIC

<lang IWBASIC> 'In a window

DEF Win:WINDOW DEF Close:CHAR DEF ScreenSizeX,ScreenSizeY:UINT

GETSCREENSIZE(ScreenSizeX,ScreenSizeY)

OPENWINDOW Win,0,0,ScreenSizeX,ScreenSizeY,NULL,NULL,"Goodbye program",&MainHandler

PRINT Win,"Goodbye, World!" 'Prints in upper left corner of the window (position 0,0). PRINT Win," You won't have this program to kick around anymore."

'There does not appear to be a means of starting a new line when printing in a window, other than by using the MOVE command. 'Therefore, both sentences here will print on the same line, i.e., in the same vertical position.

WAITUNTIL Close=1

CLOSEWINDOW Win

END

SUB MainHandler

   IF @MESSAGE=@IDCLOSEWINDOW THEN Close=1

RETURN ENDSUB

'In the console

OPENCONSOLE

'by inserting a trailing comma. PRINT"Goodbye, World!", PRINT" You won't have this program to kick around anymore."

PRINT:PRINT

'A press any key to continue message is automatic in a program compiled as console only. 'I presume the compiler adds the code. CLOSECONSOLE

'Since this an IWBASIC console program. END </lang>

J

On a linux system, you can use 1!:3 because stdout is a file: <lang j> 'Goodbye, World!' 1!:3 <'/proc/self/fd/1' Goodbye, World! </lang> However, J works in environments other than Linux, so... Solution:prompt from the misc package. Example:<lang j> load 'general/misc/prompt'

  prompt 'Goodbye, World!'

Goodbye, World!</lang> 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, prompt 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 text 1!:3 file 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.

Jack

<lang jack>class Main {

 function void main () {
   do Output.printString("Goodbye, World!");und
   return;
 }

}</lang>

Janet

<lang janet>(prin "Goodbye, World!")</lang>

Java

<lang java>public class HelloWorld {

public static void main(String[] args)
{
 System.out.print("Goodbye, World!");
}

}</lang>

JavaScript

Node JS: <lang javascript>process.stdout.write("Goodbye, World!");</lang>

jq

The "-j" command-line option suppresses the newline that would otherwise be printed, e.g. if "$" is the command-line prompt: <lang sh>$ jq -n -j '"Goodbye, World!"' Goodbye, World!$ </lang> The trailing "$" is the command-line prompt.

Similarly: <lang sh>$ echo '"Goodbye, World!"' | jq -j Goodbye, World!$ </lang>

Jsish

<lang javascript>printf("Goodbye, World!")</lang>

Evaluated from the command line as:

Output:
prompt$ jsish -e 'printf("Goodbye, World!")'
Goodbye, World!prompt$

Julia

Julia provides a println function which appends a newline, and a print function which doesn't: <lang julia>print("Goodbye, World!")</lang>

Kotlin

Translation of: Java

<lang scala>fun main(args: Array<String>) = print("Goodbye, World!")</lang>

Lasso

Lasso provides a stdoutnl method that prints a trailing newline, and a stdout method that does not: <lang lasso>stdout("Goodbye, World!")</lang>

LFE

<lang lisp> (io:format "Goodbye, World") </lang>

Liberty BASIC

A trailing semicolon prevents a newline <lang lb>print "Goodbye, World!"; </lang>

LIL

<lang tcl>write Goodbye, World!</lang>

Limbo

<lang limbo>implement HelloWorld;

include "sys.m"; sys: Sys; include "draw.m";

HelloWorld: module { init: fn(nil: ref Draw->Context, nil: list of string); };

init(nil: ref Draw->Context, nil: list of string) { sys = load Sys Sys->PATH; sys->print("Goodbye, World!"); # No automatic newline. }</lang>

LLVM

<lang llvm>; This is not strictly LLVM, as it uses the C library function "printf".

LLVM does not provide a way to print values, so the alternative would be
to just load the string into memory, and that would be boring.

$"OUTPUT_STR" = comdat any @"OUTPUT_STR" = linkonce_odr unnamed_addr constant [16 x i8] c"Goodbye, World!\00", comdat, align 1

--- The declaration for the external C printf function.

declare i32 @printf(i8*, ...)

define i32 @main() {

   %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @"OUTPUT_STR", i32 0, i32 0))
   ret i32 0

}</lang>

Logtalk

No action is necessary to avoid an unwanted newline. <lang logtalk>

- object(error_message).
   % the initialization/1 directive argument is automatically executed
   % when the object is compiled loaded into memory:
   :- initialization(write('Goodbye, World!')).
- end_object.

</lang>

Lua

<lang lua>io.write("Goodbye, World!")</lang>

m4

(Quoted) text is issued verbatim, "dnl" suppresses all input until and including the next newline. Simply creating an input without a trailing newline would of course accomplish the same task.

<lang m4>`Goodbye, World!'dnl</lang>

MANOOL

<lang MANOOL>{{extern "manool.org.18/std/0.3/all"} in Out.Write["Goodbye, World!"]}</lang>

Maple

<lang Maple> printf( "Goodbye, World!" ); </lang>

Mathematica / Wolfram Language

<lang Mathematica>NotebookWrite[EvaluationNotebook[], "Goodbye, World!"]</lang> Another one that works in scripts: <lang Mathematica>WriteString[$Output, "Goodbye, World!"]</lang>

MATLAB / Octave

<lang Matlab> fprintf('Goodbye, World!');</lang>

min

<lang min>"Goodbye, World!" print</lang>

mIRC Scripting Language

<lang mirc>echo -ag Goodbye, World!</lang>

ML/I

Simple solution

In ML/I, if there isn't a newline in the input, there won't be one in the output; so a simple solution is this (although it's hard to see that there isn't a newline). <lang ML/I>Goodbye, World!</lang>

More sophisticated solution

To make it clearer, we can define an ML/I skip to delete itself and an immediately following newline. <lang ML/I>MCSKIP " WITH " NL Goodbye, World!""</lang>

Modula-2

<lang modula2>MODULE HelloWorld; FROM Terminal IMPORT WriteString,ReadChar;

BEGIN

   WriteString("Goodbye, World!");
   ReadChar

END HelloWorld.</lang>

N/t/roff

By default, /.ROFF/ replaces single non-consecutive newline characters with spaces, but considers two consecutive newline characters as a paragraph separator and omits 2-newline's worth of spaces. The former behaviour is the same as in HTML and Rosettacode's Wiki syntax: text on non-consecutive single newlines get wrapped on the same line above it. In /.ROFF/, this is the default behaviour if and only if the typesetter is processing the input in fill mode (.fi); though, by default, the typesetter processes in this mode anyway!

Because /.ROFF/ is a document formatting language, most text input is expected to be text input which will get output on paper, so there is usually no need to run a special procedure or routine to output text.

<lang N/t/roff> Goodbye, World! </lang>

Nanoquery

<lang nanoquery>print "Goodbye, world!"</lang>

Neko

The Neko builtin $print does not add a newline.

<lang ActionScript>/**

hellonnl.neko
Tectonics:
  nekoc hellonnl.neko
  neko hellonnl
  -or-
  nekoc hellonnl.neko
  nekotools boot hellonnl.n
  ./hellonnl
  • /

$print("Goodbye, World!");</lang>

Output:
prompt$ nekoc hellonnl.neko
prompt$ neko hellonnl
Goodbye, World!prompt$

Nemerle

<lang Nemerle>using System.Console;

module Hello {

   // as with C#, Write() does not append a newline
   Write("Goodbye, world!");
   // equivalently
   Write("Goodbye, ");
   Write("world!");

}</lang>

NetRexx

<lang NetRexx>/* NetRexx */ options replace format comments java crossref symbols binary

say 'Goodbye, World!\-' </lang>

NewLISP

<lang NewLISP>(print "Goodbye, World!")</lang>

Nim

<lang nim>stdout.write "Goodbye, World!"</lang>

NS-HUBASIC

<lang NS-HUBASIC>10 PRINT "GOODBYE, WORLD!";</lang>

Oberon-2

<lang oberon2> MODULE HelloWorld; IMPORT Out; BEGIN

 Out.String("Goodbye, world!")

END HelloWorld. </lang>

Objeck

<lang objeck> bundle Default {

 class SayGoodbye {
   function : Main(args : String[]) ~ Nil {
     "Goodbye, World!"->Print();
   }
 }

} </lang>

OCaml

In OCaml, the function print_endline prints a string followed by a newline character on the standard output and flush the standard output. And the function print_string just prints a string with nothing additional.

<lang ocaml>print_string "Goodbye, World!"</lang>

Oforth

<lang Oforth>"Goodbye, World!" print</lang>

Ol

To omit the trailing newline use `display` instead of `print`. <lang scheme> (display "Goodbye, World!") </lang>

OOC

To omit the trailing newline use print instead of println: <lang ooc>main: func {

 "Goodbye, World!" print()

}</lang>

Oxygene

This example is incorrect. Please fix the code and remove this message.

Details: output isn't consistent with the task's requirements: wording, capitalization.

<lang oxygene> namespace HelloWorld;

interface

type

 HelloWorld = class
 public
   class method Main; 
 end;

implementation

class method HelloWorld.Main; begin

 Console.Write('Farewell, ');
 Console.Write('cruel ');
 Console.WriteLine('world!');

end;

end. </lang>

>HelloWorld.exe
Farewell, cruel world!

Panoramic

<lang Panoramic> rem insert a trailing semicolon. print "Goodbye, World!"; print " Nice having known you."</lang>

PARI/GP

<lang parigp>print1("Goodbye, World!")</lang>

Pascal

<lang pascal>program NewLineOmission(output);

begin

 write('Goodbye, World!');

end.</lang> Output:

% ./NewLineOmission 
Goodbye, World!% 

PASM

<lang pasm>print "Goodbye World!" # Newlines do not occur unless we embed them end</lang>

Perl

<lang perl>print "Goodbye, World!"; # A newline does not occur automatically</lang>

Phix

Phix does not add '\n' automatically, except for the '?' (debugging) shorthand; if you want one you must remember to add it explicitly.

puts(1,"Goodbye, World!")

PHL

Printf doesn't add newline automatically.

<lang phl>module helloworld_noln; extern printf;

@Integer main [

   printf("Goodbye, World!");
   return 0;

]</lang>

PHP

<lang PHP>echo "Goodbye, World !";</lang>

PicoLisp

<lang PicoLisp>(prin "Goodbye, World!")</lang>

Pict

<lang pict>(pr "Hello World!");</lang>

Pike

<lang Pike>write("Goodbye, World!");</lang>

Pixilang

<lang Pixilang>fputs("Goodbye, World!")</lang>

PL/I

<lang PL/I> put ('Goodbye, World!'); </lang>

Plain English

<lang plainenglish>To run: Start up. Write "Goodbye, world!" on the console without advancing. Wait for the escape key. Shut down.</lang>

PowerShell

<lang PowerShell>Write-Host -NoNewLine "Goodbye, " Write-Host -NoNewLine "World!"</lang>

Output:
Goodbye, World!PS C:\>

Processing

<lang processing> print("Goodbye, World!"); /* No automatic newline */ </lang>

PureBasic

<lang PureBasic>OpenConsole() Print("Goodbye, World!") Input() ;wait for enter key to be pressed</lang>

Python

<lang python>import sys sys.stdout.write("Goodbye, World!")</lang>

Works with: Python version 3.x

<lang python>print("Goodbye, World!", end="")</lang>

Quackery

Quackery does not automatically insert a new line.

<lang Quackery>say "Goodbye, world!"</lang>

R

<lang R>cat("Goodbye, world!")</lang>

Ra

<lang Ra> class HelloWorld **Prints "Goodbye, World!" without a new line**

on start

print "Goodbye, World!" without new line </lang>

Racket

<lang Racket>#lang racket (display "Goodbye, World!")</lang>

Raku

(formerly Perl 6) A newline is not added automatically to print or printf <lang perl6>print "Goodbye, World!"; printf "%s", "Goodbye, World!";</lang>

RASEL

<lang>"!dlroW ,olleH">:?@,Gj</lang>

REBOL

<lang REBOL>prin "Goodbye, World!"</lang>

Red

<lang Red>prin "Goodbye, World!"</lang>

Retro

<lang Retro>'Goodbye,_World! s:put</lang>

REXX

It should be noted that upon a REXX program completion, any text left pending without a C/R (or newline) is followed by a
blank line so as to not leave the state of the terminal with malformed "text lines" (which can be followed by other text
(lines) from a calling program(s), or the operating system (shell) which is usually some sort of a "prompt" text string. <lang rexx>/*REXX pgm displays a "Goodbye, World!" without a trailing newline. */

call charout ,'Goodbye, World!'</lang>

Ring

<lang ring>see "Goodbye, World!"</lang>

Ruby

<lang ruby>print "Goodbye, World!"</lang>

Run BASIC

<lang RunBasic>print "Goodbye, World!";</lang>

Rust

<lang rust>fn main () {

   print!("Goodbye, World!");

}</lang>

Salmon

<lang Salmon>print("Goodbye, World!");</lang>

Scala

Library: scala

Ad hoc REPL solution

Ad hoc solution as REPL script. Type this in a REPL session: <lang Scala>print("Goodbye, World!")</lang>

Scheme

<lang scheme>(display "Goodbye, World!")</lang>

Scilab

Scilab can emulate C printf which, by default, does not return the carriage. <lang scilab>print("Goodbye, World!")</lang>

Seed7

<lang seed7>$ include "seed7_05.s7i";

const proc: main is func

 begin
   write("Goodbye, World!");
 end func;</lang>

SETL

<lang setl>nprint( 'Goodbye, World!' );</lang>

Sidef

<lang ruby>print "Goodbye, World!";</lang> or: <lang ruby>"%s".printf("Goodbye, World!");</lang>

Smalltalk

<lang smalltalk> Transcript show: 'Goodbye, World!'. </lang>

Standard ML

<lang sml>print "Goodbye, World!"</lang>

Swift

Works with: Swift version 2.x+

<lang swift>print("Goodbye, World!", terminator: "")</lang>

Works with: Swift version 1.x

<lang swift>print("Goodbye, World!")</lang>

Tcl

<lang tcl>puts -nonewline "Goodbye, World!"</lang>

Transact-SQL

This example is incorrect. Please fix the code and remove this message.

Details: output isn't consistent with the task's requirements: wrong word.

As an output statement, PRINT always adds a new line <lang Transact-SQL> PRINT 'Goodbye, World!'</lang> or: As a result set <lang Transact-SQL> select 'Goodbye, World!'</lang>

TUSCRIPT

<lang tuscript> $$ MODE TUSCRIPT PRINT "Goodbye, World!" </lang> Output:

Goodbye, World!

TXR

Possible using access to standard output stream via TXR Lisp: <lang bash>$ txr -e '(put-string "Goodbye, world!")' Goodbye, world!$</lang>

UNIX Shell

The echo command is not portable, and echo -n is not guaranteed to prevent a newline from occuring. With the original Bourne Shell, echo -n "Goodbye, World!" prints -n Goodbye, World! with a newline. So use a printf instead.

Works with: Bourne Shell

<lang bash>printf "Goodbye, World!" # This works. There is no newline. printf %s "-hyphens and % signs" # Use %s with arbitrary strings.</lang>

Unfortunately, older systems where you have to rely on vanilla Bourne shell may not have a printf command, either. It's possible that there is no command available to complete the task, but only on very old systems. For the rest, one of these two should work:

<lang bash>echo -n 'Goodbye, World!'</lang> or <lang bash>echo 'Goodbye, World!\c'</lang>

The print command, from the Korn Shell, would work well, but most shells have no print command. (With pdksh, print is slightly faster than printf because print runs a built-in command, but printf forks an external command. With ksh93 and zsh, print and printf are both built-in commands.)

Works with: ksh93
Works with: pdksh
Works with: zsh

<lang bash>print -n "Goodbye, World!" print -nr -- "-hyphens and \backslashes"</lang>

C Shell

C Shell does support echo -n and omits the newline.

<lang csh>echo -n "Goodbye, World!" echo -n "-hyphens and \backslashes"</lang>

Ursa

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. <lang ursa>out "goodbye world!" console</lang>

Verbexx

<lang verbexx>@STDOUT "Goodbye, World!";</lang>


Verilog

<lang Verilog>module main;

 initial 
   begin
     $write("Goodbye, World!");
     $finish ;
   end

endmodule</lang>


Vim Script

<lang vim>echon "Goodbye, World!"</lang>

Visual Basic .NET

<lang vbnet>Module Module1

   Sub Main()
       Console.Write("Goodbye, World!")
   End Sub

End Module</lang>

Web 68

This example is incorrect. Please fix the code and remove this message.

Details: output isn't consistent with the task's requirements: wording, punctuation.

Use the command 'tang -V hello.w68', then 'chmod +x hello.a68', then './hello.a68'

<lang web68>@ @a@=#!/usr/bin/a68g -nowarn@>@\BEGIN print("Hello World") END</lang>

Wren

<lang ecmascript>System.write("Goodbye, World!")</lang>

XLISP

Either <lang scheme>(display "Goodbye, World!")</lang> or <lang lisp>(princ "Goodbye, World!")</lang>

XPL0

<lang XPL0>code Text=12; Text(0, "Goodbye, World!")</lang>

zkl

<lang zkl>print("Goodbye, World!"); Console.write("Goodbye, World!");</lang>

ZX Spectrum Basic

<lang basic>10 REM The trailing semicolon prevents a newline 20 PRINT "Goodbye, World!";</lang>