Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Write the same code in VB as shown below in OCaml. | let () =
let top = Tk.openTk() in
Wm.title_set top "An Empty Window";
Wm.geometry_set top "240x180";
Tk.mainLoop ();
;;
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Rewrite this program in Go while keeping its functionality equivalent to the OCaml version. | let () =
let top = Tk.openTk() in
Wm.title_set top "An Empty Window";
Wm.geometry_set top "240x180";
Tk.mainLoop ();
;;
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Produce a language-to-language conversion: from Pascal to C, same semantics. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Translate the given Pascal code snippet into C# without altering its behavior. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Translate the given Pascal code snippet into C++ without altering its behavior. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Translate the given Pascal code snippet into Java without altering its behavior. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Port the following code from Pascal to Python with equivalent syntax and logic. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Write a version of this Pascal function in VB with identical behavior. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Translate the given Pascal code snippet into Go without altering its behavior. | Program WindowCreation_SDL;
uses
SDL,
SysUtils;
var
screen: PSDL_Surface;
begin
SDL_Init(SDL_INIT_VIDEO);
screen := SDL_SetVideoMode( 800, 600, 16, (SDL_SWSURFACE or SDL_HWPALETTE) );
sleep(2000);
SDL_Quit;
end.
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Convert this Perl snippet to C and keep its semantics consistent. | use Tk;
MainWindow->new();
MainLoop;
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Write a version of this Perl function in C# with identical behavior. | use Tk;
MainWindow->new();
MainLoop;
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Transform the following Perl implementation into C++, maintaining the same output and logic. | use Tk;
MainWindow->new();
MainLoop;
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Change the programming language of this snippet from Perl to Java without modifying what it does. | use Tk;
MainWindow->new();
MainLoop;
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Write the same code in Python as shown below in Perl. | use Tk;
MainWindow->new();
MainLoop;
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Can you help me rewrite this code in VB instead of Perl, keeping it the same logically? | use Tk;
MainWindow->new();
MainLoop;
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Port the provided Perl code into Go while preserving the original functionality. | use Tk;
MainWindow->new();
MainLoop;
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Convert the following code from PowerShell to C, ensuring the logic remains intact. | New-Window -Show
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Rewrite this program in C# while keeping its functionality equivalent to the PowerShell version. | New-Window -Show
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Produce a language-to-language conversion: from PowerShell to C++, same semantics. | New-Window -Show
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Translate this program into Java but keep the logic exactly as in PowerShell. | New-Window -Show
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Please provide an equivalent version of this PowerShell code in VB. | New-Window -Show
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Ensure the translated Go code behaves exactly like the original PowerShell snippet. | New-Window -Show
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Translate the given R code snippet into C without altering its behavior. | win <- tktoplevel()
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Convert this R snippet to C# and keep its semantics consistent. | win <- tktoplevel()
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Keep all operations the same but rewrite the snippet in C++. | win <- tktoplevel()
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Can you help me rewrite this code in Java instead of R, keeping it the same logically? | win <- tktoplevel()
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Write the same code in VB as shown below in R. | win <- tktoplevel()
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Port the provided R code into Go while preserving the original functionality. | win <- tktoplevel()
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Change the programming language of this snippet from Racket to C without modifying what it does. | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Generate an equivalent C# version of this Racket code. | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Translate the given Racket code snippet into C++ without altering its behavior. | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Please provide an equivalent version of this Racket code in Java. | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Generate a Python translation of this Racket snippet without changing its computational steps. | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Change the programming language of this snippet from Racket to VB without modifying what it does. | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Can you help me rewrite this code in Go instead of Racket, keeping it the same logically? | #lang racket/gui
(send (new frame%
[label "New Window"]
[width 100] [height 100])
show #t)
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Write the same code in C as shown below in REXX. |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Preserve the algorithm and functionality while converting the code from REXX to C#. |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Generate a C++ translation of this REXX snippet without changing its computational steps. |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Convert the following code from REXX to Java, ensuring the logic remains intact. |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Can you help me rewrite this code in Python instead of REXX, keeping it the same logically? |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Convert the following code from REXX to VB, ensuring the logic remains intact. |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Can you help me rewrite this code in Go instead of REXX, keeping it the same logically? |
options replace format comments java crossref symbols binary
import javax.swing.JFrame
import javax.swing.JLabel
import java.awt.BorderLayout
import java.awt.Font
import java.awt.Color
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parse arg showText .
select
when showText.length = 0 then addText = isTrue
when 'YES'.abbrev(showText.upper) then addText = isTrue
when showText = '.' then addText = isTrue
otherwise addText = isFalse
end
title = 'Rosetta Code - Window Creation'
createFrame(title, addText)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method createFrame(title, addText = boolean 0) public static
do
fenester = JFrame(title)
fenester.setSize(600, 200)
fenester.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
if addText then decorate(fenester)
fenester.setVisible(isTrue)
catch ex = Exception
ex.printStackTrace()
end
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method decorate(fenester = JFrame, textStr = 'This page intentionally left blank.') private static returns JFrame
textlbl = JLabel(textStr)
textfont = Font(Font.SERIF, Font.BOLD, 20)
textlbl.setHorizontalAlignment(JLabel.CENTER)
textlbl.setFont(textfont)
textlbl.setForeground(Color.ORANGE)
fenester.add(textlbl, BorderLayout.CENTER)
return fenester
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isTrue() public static returns boolean
return (1 == 1)
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method isFalse() public static returns boolean
return \(1 == 1)
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Can you help me rewrite this code in C instead of Ruby, keeping it the same logically? | require 'tk'
window = TkRoot::new()
window::mainloop()
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Generate an equivalent C# version of this Ruby code. | require 'tk'
window = TkRoot::new()
window::mainloop()
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Generate an equivalent C++ version of this Ruby code. | require 'tk'
window = TkRoot::new()
window::mainloop()
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Convert the following code from Ruby to Java, ensuring the logic remains intact. | require 'tk'
window = TkRoot::new()
window::mainloop()
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Generate an equivalent Python version of this Ruby code. | require 'tk'
window = TkRoot::new()
window::mainloop()
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Write the same algorithm in VB as shown in this Ruby implementation. | require 'tk'
window = TkRoot::new()
window::mainloop()
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Change the programming language of this snippet from Ruby to Go without modifying what it does. | require 'tk'
window = TkRoot::new()
window::mainloop()
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Convert this Scala snippet to C and keep its semantics consistent. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Port the provided Scala code into C# while preserving the original functionality. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Transform the following Scala implementation into C++, maintaining the same output and logic. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Port the provided Scala code into Java while preserving the original functionality. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Translate this program into Python but keep the logic exactly as in Scala. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Convert the following code from Scala to VB, ensuring the logic remains intact. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Rewrite this program in Go while keeping its functionality equivalent to the Scala version. | import javax.swing.JFrame
object ShowWindow{
def main(args: Array[String]){
var jf = new JFrame("Hello!")
jf.setSize(800, 600)
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE)
jf.setVisible(true)
}
}
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Convert this Tcl snippet to C and keep its semantics consistent. | package require Tk
|
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
|
Please provide an equivalent version of this Tcl code in C#. | package require Tk
| using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
|
Can you help me rewrite this code in C++ instead of Tcl, keeping it the same logically? | package require Tk
| #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
|
Convert this Tcl snippet to Java and keep its semantics consistent. | package require Tk
| import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
|
Transform the following Tcl implementation into VB, maintaining the same output and logic. | package require Tk
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Convert this Tcl block to Go, preserving its control flow and logic. | package require Tk
| package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
|
Write a version of this C function in Rust with identical behavior. |
#include <stdio.h>
#include <stdlib.h>
#include "SDL.h"
int main()
{
SDL_Surface *screen;
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
fprintf(stderr, "Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
atexit(SDL_Quit);
screen = SDL_SetVideoMode( 800, 600, 16, SDL_SWSURFACE | SDL_HWPALETTE );
return 0;
}
| use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
|
Rewrite the snippet below in Rust so it works the same as the original C++ code. | #include <QApplication>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QMainWindow window;
window.show();
return app.exec();
}
| use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
|
Translate this program into Rust but keep the logic exactly as in C#. | using System;
using System.Windows.Forms;
public class Window {
[STAThread]
static void Main() {
Form form = new Form();
form.Text = "Window";
form.Disposed += delegate { Application.Exit(); };
form.Show();
Application.Run();
}
}
| use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
|
Maintain the same structure and functionality when rewriting this code in Rust. | import javax.swing.JFrame;
public class Main {
public static void main(String[] args) throws Exception {
JFrame w = new JFrame("Title");
w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
w.setSize(800,600);
w.setVisible(true);
}
}
| use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
|
Rewrite the snippet below in Rust so it works the same as the original Go code. | package main
import (
"github.com/mattn/go-gtk/glib"
"github.com/mattn/go-gtk/gtk"
)
func main() {
gtk.Init(nil)
window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
window.Connect("destroy",
func(*glib.CallbackContext) { gtk.MainQuit() }, "")
window.Show()
gtk.Main()
}
| use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
|
Produce a language-to-language conversion: from Rust to Python, same semantics. | use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
| import Tkinter
w = Tkinter.Tk()
w.mainloop()
|
Please provide an equivalent version of this Rust code in VB. | use winit::event::{Event, WindowEvent};
use winit::event_loop::{ControlFlow, EventLoop};
use winit::window::WindowBuilder;
fn main() {
let event_loop = EventLoop::new();
let _win = WindowBuilder::new()
.with_title("Window")
.build(&event_loop).unwrap();
event_loop.run(move |ev, _, flow| {
match ev {
Event::WindowEvent {
event: WindowEvent::CloseRequested, ..
} => {
*flow = ControlFlow::Exit;
}
_ => {}
}
});
}
| Option Explicit
Sub InsertForm()
Dim myForm As Object, strname As String
Set myForm = ThisWorkbook.VBProject.VBComponents.Add(3)
strname = myForm.Name
VBA.UserForms.Add(strname).Show
End Sub
|
Produce a functionally identical C# code for the snippet given in Ada. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| using System.IO;
class Program
{
static void Main(string[] args)
{
var fileContents = File.ReadAllText("c:\\autoexec.bat");
}
}
|
Convert this Ada snippet to C and keep its semantics consistent. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| #include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
fclose(fh); fh = NULL;
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}
|
Write a version of this Ada function in C++ with identical behavior. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| #include <iostream>
#include <fstream>
#include <string>
#include <iterator>
int main( )
{
if (std::ifstream infile("sample.txt"))
{
std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>());
cout << "File has " << fileData.size() << "chars\n";
return 0;
}
else
{
std::cout << "file not found!\n";
return 1;
}
}
|
Generate a Go translation of this Ada snippet without changing its computational steps. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| import "io/ioutil"
data, err := ioutil.ReadFile(filename)
sv := string(data)
|
Translate this program into Java but keep the logic exactly as in Ada. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| static Byte[] contentsOf(File file)
{
return file.contents;
}
|
Please provide an equivalent version of this Ada code in Python. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| open(filename).read()
|
Convert this Ada block to VB, preserving its control flow and logic. | with Ada.Directories,
Ada.Direct_IO,
Ada.Text_IO;
procedure Whole_File is
File_Name : String := "whole_file.adb";
File_Size : Natural := Natural (Ada.Directories.Size (File_Name));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => File_Name);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
Ada.Text_IO.Put (Contents);
end Whole_File;
| dim s
s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall
wscript.echo s
|
Produce a functionally identical C code for the snippet given in Arturo. | contents: read "input.txt"
| #include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
fclose(fh); fh = NULL;
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}
|
Rewrite the snippet below in C# so it works the same as the original Arturo code. | contents: read "input.txt"
| using System.IO;
class Program
{
static void Main(string[] args)
{
var fileContents = File.ReadAllText("c:\\autoexec.bat");
}
}
|
Rewrite the snippet below in C++ so it works the same as the original Arturo code. | contents: read "input.txt"
| #include <iostream>
#include <fstream>
#include <string>
#include <iterator>
int main( )
{
if (std::ifstream infile("sample.txt"))
{
std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>());
cout << "File has " << fileData.size() << "chars\n";
return 0;
}
else
{
std::cout << "file not found!\n";
return 1;
}
}
|
Please provide an equivalent version of this Arturo code in VB. | contents: read "input.txt"
| dim s
s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall
wscript.echo s
|
Convert this AutoHotKey block to C, preserving its control flow and logic. | fileread, varname, C:\filename.txt
| #include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
fclose(fh); fh = NULL;
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}
|
Translate the given AutoHotKey code snippet into C# without altering its behavior. | fileread, varname, C:\filename.txt
| using System.IO;
class Program
{
static void Main(string[] args)
{
var fileContents = File.ReadAllText("c:\\autoexec.bat");
}
}
|
Maintain the same structure and functionality when rewriting this code in C++. | fileread, varname, C:\filename.txt
| #include <iostream>
#include <fstream>
#include <string>
#include <iterator>
int main( )
{
if (std::ifstream infile("sample.txt"))
{
std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>());
cout << "File has " << fileData.size() << "chars\n";
return 0;
}
else
{
std::cout << "file not found!\n";
return 1;
}
}
|
Translate the given AutoHotKey code snippet into VB without altering its behavior. | fileread, varname, C:\filename.txt
| dim s
s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall
wscript.echo s
|
Produce a functionally identical Go code for the snippet given in AutoHotKey. | fileread, varname, C:\filename.txt
| import "io/ioutil"
data, err := ioutil.ReadFile(filename)
sv := string(data)
|
Maintain the same structure and functionality when rewriting this code in C. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| #include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
fclose(fh); fh = NULL;
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}
|
Write the same algorithm in C# as shown in this AWK implementation. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| using System.IO;
class Program
{
static void Main(string[] args)
{
var fileContents = File.ReadAllText("c:\\autoexec.bat");
}
}
|
Maintain the same structure and functionality when rewriting this code in C++. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| #include <iostream>
#include <fstream>
#include <string>
#include <iterator>
int main( )
{
if (std::ifstream infile("sample.txt"))
{
std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>());
cout << "File has " << fileData.size() << "chars\n";
return 0;
}
else
{
std::cout << "file not found!\n";
return 1;
}
}
|
Produce a functionally identical Java code for the snippet given in AWK. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| static Byte[] contentsOf(File file)
{
return file.contents;
}
|
Preserve the algorithm and functionality while converting the code from AWK to Python. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| open(filename).read()
|
Generate a VB translation of this AWK snippet without changing its computational steps. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| dim s
s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall
wscript.echo s
|
Convert the following code from AWK to Go, ensuring the logic remains intact. |
BEGIN {
RS="";
getline;
print "=== line "NR,":",$0;
}
{
print "=== line "NR,":",$0;
}
| import "io/ioutil"
data, err := ioutil.ReadFile(filename)
sv := string(data)
|
Convert this BBC_Basic block to C, preserving its control flow and logic. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| #include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
fclose(fh); fh = NULL;
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}
|
Write the same algorithm in C# as shown in this BBC_Basic implementation. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| using System.IO;
class Program
{
static void Main(string[] args)
{
var fileContents = File.ReadAllText("c:\\autoexec.bat");
}
}
|
Preserve the algorithm and functionality while converting the code from BBC_Basic to C++. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| #include <iostream>
#include <fstream>
#include <string>
#include <iterator>
int main( )
{
if (std::ifstream infile("sample.txt"))
{
std::string fileData(std::istreambuf_iterator<char>(infile), std::istreambuf_iterator<char>());
cout << "File has " << fileData.size() << "chars\n";
return 0;
}
else
{
std::cout << "file not found!\n";
return 1;
}
}
|
Generate a Java translation of this BBC_Basic snippet without changing its computational steps. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| static Byte[] contentsOf(File file)
{
return file.contents;
}
|
Generate a Python translation of this BBC_Basic snippet without changing its computational steps. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| open(filename).read()
|
Please provide an equivalent version of this BBC_Basic code in VB. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| dim s
s = createobject("scripting.filesystemobject").opentextfile("slurp.vbs",1).readall
wscript.echo s
|
Convert the following code from BBC_Basic to Go, ensuring the logic remains intact. | file% = OPENIN("input.txt")
strvar$ = ""
WHILE NOT EOF#file%
strvar$ += CHR$(BGET#file%)
ENDWHILE
CLOSE #file%
| import "io/ioutil"
data, err := ioutil.ReadFile(filename)
sv := string(data)
|
Ensure the translated C code behaves exactly like the original Clojure snippet. | (slurp "myfile.txt")
(slurp "my-utf8-file.txt" "UTF-8")
| #include <stdio.h>
#include <stdlib.h>
int main()
{
char *buffer;
FILE *fh = fopen("readentirefile.c", "rb");
if ( fh != NULL )
{
fseek(fh, 0L, SEEK_END);
long s = ftell(fh);
rewind(fh);
buffer = malloc(s);
if ( buffer != NULL )
{
fread(buffer, s, 1, fh);
fclose(fh); fh = NULL;
fwrite(buffer, s, 1, stdout);
free(buffer);
}
if (fh != NULL) fclose(fh);
}
return EXIT_SUCCESS;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.