Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Convert this Delphi snippet to C# and keep its semantics consistent.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Change the following Delphi code into C++ without altering its purpose.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Produce a language-to-language conversion: from Delphi to C++, same semantics.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Please provide an equivalent version of this Delphi code in Java.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Please provide an equivalent version of this Delphi code in Java.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Convert this Delphi snippet to Python and keep its semantics consistent.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Generate a Python translation of this Delphi snippet without changing its computational steps.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Port the following code from Delphi to VB with equivalent syntax and logic.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Keep all operations the same but rewrite the snippet in VB.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Can you help me rewrite this code in Go instead of Delphi, keeping it the same logically?
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Convert the following code from Delphi to Go, ensuring the logic remains intact.
program Cantor_set; const WIDTH: Integer = 81; HEIGHT: Integer = 5; var Lines: TArray<TArray<Char>>; procedure Init; var i, j: Integer; begin SetLength(lines, HEIGHT, WIDTH); for i := 0 to HEIGHT - 1 do for j := 0 to WIDTH - 1 do lines[i, j] := '*'; end; procedure Cantor(start, len, index: I...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Rewrite the snippet below in C so it works the same as the original Elixir code.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Transform the following Elixir implementation into C, maintaining the same output and logic.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Change the following Elixir code into C# without altering its purpose.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Please provide an equivalent version of this Elixir code in C++.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Translate the given Elixir code snippet into C++ without altering its behavior.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Rewrite this program in Java while keeping its functionality equivalent to the Elixir version.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Generate a Java translation of this Elixir snippet without changing its computational steps.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Change the programming language of this snippet from Elixir to Python without modifying what it does.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Preserve the algorithm and functionality while converting the code from Elixir to VB.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Ensure the translated VB code behaves exactly like the original Elixir snippet.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Change the programming language of this snippet from Elixir to Go without modifying what it does.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Transform the following Elixir implementation into Go, maintaining the same output and logic.
defmodule Cantor do @pos "β–ˆ" @neg " " def run(lines) do Enum.map(0..lines, fn line -> segment_size = 3 ** (lines - line - 1) chars = (3 ** line) Enum.map(0..chars, fn char -> char |> Integer.digits(3) |> Enum.any?(fn x -> x === 1 end) |> case do tr...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Change the programming language of this snippet from Factor to C without modifying what it does.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Change the following Factor code into C without altering its purpose.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Write the same algorithm in C# as shown in this Factor implementation.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Convert the following code from Factor to C#, ensuring the logic remains intact.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Translate the given Factor code snippet into C++ without altering its behavior.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Ensure the translated C++ code behaves exactly like the original Factor snippet.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Generate a Java translation of this Factor snippet without changing its computational steps.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Ensure the translated Java code behaves exactly like the original Factor snippet.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Generate a Python translation of this Factor snippet without changing its computational steps.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Write the same code in Python as shown below in Factor.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Convert this Factor block to VB, preserving its control flow and logic.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Convert the following code from Factor to VB, ensuring the logic remains intact.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Transform the following Factor implementation into Go, maintaining the same output and logic.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Write a version of this Factor function in Go with identical behavior.
USING: grouping.extras io kernel math sequences sequences.repeating ; IN: rosetta-code.cantor-set CONSTANT: width 81 CONSTANT: depth 5 : cantor ( n -- seq ) dup 0 = [ drop { 0 1 } ] [ 1 - cantor [ 3 / ] map dup [ 2/3 + ] map append ] if ; : gaps ( seq -- seq ) [ width * ] map [ - abs ] 2clump-map ; ...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Convert the following code from Forth to C, ensuring the logic remains intact.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Generate a C translation of this Forth snippet without changing its computational steps.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Write a version of this Forth function in C# with identical behavior.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Generate an equivalent C# version of this Forth code.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Please provide an equivalent version of this Forth code in C++.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Translate the given Forth code snippet into C++ without altering its behavior.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Convert this Forth snippet to Java and keep its semantics consistent.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Translate this program into Java but keep the logic exactly as in Forth.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Convert this Forth snippet to Python and keep its semantics consistent.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Write the same code in Python as shown below in Forth.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Can you help me rewrite this code in VB instead of Forth, keeping it the same logically?
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Keep all operations the same but rewrite the snippet in VB.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Convert this Forth snippet to Go and keep its semantics consistent.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Convert this Forth block to Go, preserving its control flow and logic.
warnings off 4 : ** 1 swap 0 ?DO over * LOOP nip ; 3 swap ** constant width create string here width char # fill width allot : print string width type cr ; create length width , : reduce length dup @ 3 / swap ! ; : done? dup string - width >= ; : hole? dup c@ bl = ; : skip leng...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Produce a language-to-language conversion: from Groovy to C, same semantics.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Convert this Groovy block to C, preserving its control flow and logic.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Please provide an equivalent version of this Groovy code in C#.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Change the programming language of this snippet from Groovy to C# without modifying what it does.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Produce a functionally identical C++ code for the snippet given in Groovy.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Keep all operations the same but rewrite the snippet in C++.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Keep all operations the same but rewrite the snippet in Java.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Write the same algorithm in Java as shown in this Groovy implementation.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Generate a Python translation of this Groovy snippet without changing its computational steps.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Change the following Groovy code into Python without altering its purpose.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Keep all operations the same but rewrite the snippet in VB.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Change the following Groovy code into VB without altering its purpose.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Write the same code in Go as shown below in Groovy.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Produce a language-to-language conversion: from Groovy to Go, same semantics.
class App { private static final int WIDTH = 81 private static final int HEIGHT = 5 private static char[][] lines static { lines = new char[HEIGHT][WIDTH] for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*' } ...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Produce a language-to-language conversion: from Haskell to C, same semantics.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Maintain the same structure and functionality when rewriting this code in C.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Convert this Haskell block to C#, preserving its control flow and logic.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Rewrite the snippet below in C# so it works the same as the original Haskell code.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Port the following code from Haskell to C++ with equivalent syntax and logic.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Convert this Haskell block to C++, preserving its control flow and logic.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Rewrite this program in Java while keeping its functionality equivalent to the Haskell version.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Convert this Haskell snippet to Java and keep its semantics consistent.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Convert this Haskell block to Python, preserving its control flow and logic.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Generate a Python translation of this Haskell snippet without changing its computational steps.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Translate this program into VB but keep the logic exactly as in Haskell.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Port the following code from Haskell to VB with equivalent syntax and logic.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Transform the following Haskell implementation into Go, maintaining the same output and logic.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Preserve the algorithm and functionality while converting the code from Haskell to Go.
cantor :: [(Bool, Int)] -> [(Bool, Int)] cantor = concatMap go where go (bln, n) | bln && 1 < n = let m = quot n 3 in [(True, m), (False, m), (True, m)] | otherwise = [(bln, n)] main :: IO () main = putStrLn $ cantorLines 5 cantorLines :: Int -> String cantorLines n = unli...
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Change the following J code into C without altering its purpose.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Generate a C translation of this J snippet without changing its computational steps.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Generate an equivalent C# version of this J code.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Transform the following J implementation into C#, maintaining the same output and logic.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Write a version of this J function in C++ with identical behavior.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Convert this J snippet to C++ and keep its semantics consistent.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Change the programming language of this snippet from J to Java without modifying what it does.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Port the following code from J to Java with equivalent syntax and logic.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...
Change the following J code into Python without altering its purpose.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Translate this program into Python but keep the logic exactly as in J.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
WIDTH = 81 HEIGHT = 5 lines=[] def cantor(start, len, index): seg = len / 3 if seg == 0: return None for it in xrange(HEIGHT-index): i = index + it for jt in xrange(seg): j = start + seg + jt pos = i * WIDTH + j lines[pos] = ' ' cantor(start, ...
Produce a language-to-language conversion: from J to VB, same semantics.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Port the provided J code into VB while preserving the original functionality.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
Module Module1 Const WIDTH = 81 Const HEIGHT = 5 Dim lines(HEIGHT, WIDTH) As Char Sub Init() For i = 0 To HEIGHT - 1 For j = 0 To WIDTH - 1 lines(i, j) = "*" Next Next End Sub Sub Cantor(start As Integer, len As Integer, index As Integer...
Preserve the algorithm and functionality while converting the code from J to Go.
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Can you help me rewrite this code in Go instead of J, keeping it the same logically?
odometer =: [: (4 $. $.) $&1 cantor_dust =: monad define shape =. ,~ 3 ^ y a =. shape $ ' ' i =. odometer shape < (}:"1) 1j1 #"1 '#' (([: <"1 [: ;/"1 (#~ 1 e."1 [: (,/"2) 3 3&#:)) i)}a )
package main import "fmt" const ( width = 81 height = 5 ) var lines [height][width]byte func init() { for i := 0; i < height; i++ { for j := 0; j < width; j++ { lines[i][j] = '*' } } } func cantor(start, len, index int) { seg := len / 3 if seg == 0 { retu...
Can you help me rewrite this code in C instead of Julia, keeping it the same logically?
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Translate this program into C but keep the logic exactly as in Julia.
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
#include <stdio.h> #define WIDTH 81 #define HEIGHT 5 char lines[HEIGHT][WIDTH]; void init() { int i, j; for (i = 0; i < HEIGHT; ++i) { for (j = 0; j < WIDTH; ++j) lines[i][j] = '*'; } } void cantor(int start, int len, int index) { int i, j, seg = len / 3; if (seg == 0) return; for (i...
Ensure the translated C# code behaves exactly like the original Julia snippet.
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Convert this Julia block to C#, preserving its control flow and logic.
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
using System; namespace CantorSet { class Program { const int WIDTH = 81; const int HEIGHT = 5; private static char[,] lines = new char[HEIGHT, WIDTH]; static Program() { for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { ...
Produce a language-to-language conversion: from Julia to C++, same semantics.
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Rewrite this program in C++ while keeping its functionality equivalent to the Julia version.
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
#include <iostream> const int WIDTH = 81; const int HEIGHT = 5; char lines[WIDTH*HEIGHT]; void cantor(int start, int len, int index) { int seg = len / 3; if (seg == 0) return; for (int i = index; i < HEIGHT; i++) { for (int j = start + seg; j < start + seg * 2; j++) { int pos = i * WIDTH + j; lines[pos] =...
Keep all operations the same but rewrite the snippet in Java.
const width = 81 const height = 5 function cantor!(lines, start, len, idx) seg = div(len, 3) if seg > 0 for i in idx+1:height, j in start + seg + 1: start + seg * 2 lines[i, j] = ' ' end cantor!(lines, start, seg, idx + 1) cantor!(lines, start + 2 * seg, seg, idx + 1...
public class App { private static final int WIDTH = 81; private static final int HEIGHT = 5; private static char[][] lines; static { lines = new char[HEIGHT][WIDTH]; for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { lines[i][j] = '*'; ...