Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Preserve the algorithm and functionality while converting the code from Ada to PHP. | package Logic is
type Ternary is (True, Unknown, False);
function "and"(Left, Right: Ternary) return Ternary;
function "or"(Left, Right: Ternary) return Ternary;
function "not"(T: Ternary) return Ternary;
function Equivalent(Left, Right: Ternary) return Ternary;
function Implies(Condition, Concl... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Write the same algorithm in PHP as shown in this Arturo implementation. | vals: @[true maybe false]
loop vals 'v -> print ["NOT" v "=>" not? v]
print ""
loop vals 'v1 [
loop vals 'v2
-> print [v1 "AND" v2 "=>" and? v1 v2]
]
print ""
loop vals 'v1 [
loop vals 'v2
-> print [v1 "OR" v2 "=>" or? v1 v2]
]
print ""
loop vals 'v1 [
loop vals 'v2
-> print [v1 ... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Write the same code in PHP as shown below in AutoHotKey. | Ternary_Not(a){
SetFormat, Float, 2.1
return Abs(a-1)
}
Ternary_And(a,b){
return a<b?a:b
}
Ternary_Or(a,b){
return a>b?a:b
}
Ternary_IfThen(a,b){
return a=1?b:a=0?1:a+b>1?1:0.5
}
Ternary_Equiv(a,b){
return a=b?1:a=1?b:b=1?a:0.5
}
| #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Rewrite this program in PHP while keeping its functionality equivalent to the BBC_Basic version. | INSTALL @lib$ + "CLASSLIB"
DIM trit{tor, tand, teqv, tnot, tnor, s, v}
DEF PRIVATE trit.s (t&) LOCAL t$():DIM t$(2):t$()="FALSE","MAYBE","TRUE":=t$(t&)
DEF PRIVATE trit.v (t$) = INSTR("FALSE MAYBE TRUE", t$) DIV 6
DEF trit.tnot (t$) = FN(trit.s)(2 - FN(trit.v)(t$))
DEF ... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Transform the following Common_Lisp implementation into PHP, maintaining the same output and logic. | (defun tri-not (x) (- 1 x))
(defun tri-and (&rest x) (apply #'* x))
(defun tri-or (&rest x) (tri-not (apply #'* (mapcar #'tri-not x))))
(defun tri-eq (x y) (+ (tri-and x y) (tri-and (- 1 x) (- 1 y))))
(defun tri-imply (x y) (tri-or (tri-not x) y))
(defun tri-test (x) (< (random 1e0) x))
(defun tri-string (x) (if (= x ... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Write the same algorithm in PHP as shown in this D implementation. | import std.stdio;
struct Trit {
private enum Val : byte { F = -1, M, T }
private Val t;
alias t this;
static immutable Trit[3] vals = [{Val.F}, {Val.M}, {Val.T}];
static immutable F = Trit(Val.F);
static immutable M = Trit(Val.M);
static immutable T = Trit(Val.T);
string toString() co... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Maintain the same structure and functionality when rewriting this code in PHP. | unit TrinaryLogic;
interface
type
TriBool = type Boolean;
const
TTrue:TriBool = True;
TFalse:TriBool = False;
TMaybe:TriBool = TriBool(2);
function TVL_not(Value: TriBool): TriBool;
function TVL_and(A, B: TriBool): TriBool;
function TVL_or(A, B: TriBool): TriBool;
function TVL_xor(A, B: TriBool): ... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Rewrite this program in PHP while keeping its functionality equivalent to the Erlang version. |
-module(ternary).
-export([main/0, nott/1, andd/2,orr/2, then/2, equiv/2]).
main() ->
{ok, [A]} = io:fread("Enter A: ","~s"),
{ok, [B]} = io:fread("Enter B: ","~s"),
andd(A,B).
nott(S) ->
if
S=="T" ->
io : format("F\n");
S=="F" ->
io : format("T\n");
true ->
io: format("?\n")
end.
andd(A,... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Write the same algorithm in PHP as shown in this Factor implementation. |
USING: combinators kernel ;
IN: rosettacode.ternary
SINGLETON: m
UNION: trit t m POSTPONE: f ;
GENERIC: >trit ( object -- trit )
M: trit >trit ;
: tnot ( trit1 -- trit )
>trit { { t [ f ] } { m [ m ] } { f [ t ] } } case ;
: tand ( trit1 trit2 -- trit )
>trit {
{ t [ >trit ] }
{ m [ >trit ... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Port the provided Forth code into PHP while preserving the original functionality. | 1 constant maybe
: tnot dup maybe <> if invert then ;
: tand and ;
: tor or ;
: tequiv 2dup and rot tnot rot tnot and or ;
: timply tnot tor ;
: txor tequiv tnot ;
: t. C" TF?" 2 + + c@ emit ;
: table2.
cr ." T F ?"
cr ." --------"
2 true DO
cr I t. ." | "
2 true DO
dup I J rot execute t... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Convert this Fortran snippet to PHP and keep its semantics consistent. |
module trit
real, parameter :: true = 1, false = 0, maybe = 0.5
contains
real function tnot(y)
real, intent(in) :: y
tnot = 1 - y
end function tnot
real function tand(x, y)
real, intent(in) :: x, y
tand = min(x, y)
end function tand
real func... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Convert this Groovy snippet to PHP and keep its semantics consistent. | enum Trit {
TRUE, MAYBE, FALSE
private Trit nand(Trit that) {
switch ([this,that]) {
case { FALSE in it }: return TRUE
case { MAYBE in it }: return MAYBE
default : return FALSE
}
}
private Trit nor(Trit that) { this.or(that).not() }
... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Change the programming language of this snippet from Haskell to PHP without modifying what it does. | import Prelude hiding (Bool(..), not, (&&), (||), (==))
main = mapM_ (putStrLn . unlines . map unwords)
[ table "not" $ unary not
, table "and" $ binary (&&)
, table "or" $ binary (||)
, table "implies" $ binary (=->)
, table "equals" $ binary (==)
]
data Trit = False | Maybe | T... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Transform the following Icon implementation into PHP, maintaining the same output and logic. | $define TRUE 1
$define FALSE -1
$define UNKNOWN 0
invocable all
link printf
procedure main()
ufunc := ["not3"]
bfunc := ["and3", "or3", "xor3", "eq3", "ifthen3"]
every f := !ufunc do {
printf("\nunary function=%s:\n",f)
every t1 := (TRUE | FALSE | UNKNOWN) do
printf(" %s : %s\n",showtrit(t1),... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Translate the given J code snippet into PHP without altering its behavior. | not=: -.
and=: <.
or =: >.
if =: (>. -.)"0~
eq =: (<.&-. >. <.)"0
| #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Write the same code in PHP as shown below in Julia. | @enum Trit False Maybe True
const trits = (False, Maybe, True)
Base.:!(a::Trit) = a == False ? True : a == Maybe ? Maybe : False
∧(a::Trit, b::Trit) = a == b == True ? True : (a, b) ∋ False ? False : Maybe
∨(a::Trit, b::Trit) = a == b == False ? False : (a, b) ∋ True ? True : Maybe
⊃(a::Trit, b::Trit) = a == False || ... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Maintain the same structure and functionality when rewriting this code in PHP. | Maybe /: ! Maybe = Maybe;
Maybe /: (And | Or | Nand | Nor | Xor | Xnor | Implies | Equivalent)[Maybe, Maybe] = Maybe;
| #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Please provide an equivalent version of this Nim code in PHP. | type Trit* = enum ttrue, tmaybe, tfalse
proc `$`*(a: Trit): string =
case a
of ttrue: "T"
of tmaybe: "?"
of tfalse: "F"
proc `not`*(a: Trit): Trit =
case a
of ttrue: tfalse
of tmaybe: tmaybe
of tfalse: ttrue
proc `and`*(a, b: Trit): Trit =
const t: array[Trit, array[Trit, Trit]] =
[ [ttrue, tm... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Maintain the same structure and functionality when rewriting this code in PHP. | type trit = True | False | Maybe
let t_not = function
| True -> False
| False -> True
| Maybe -> Maybe
let t_and a b = match (a,b) with
| (True,True) -> True
| (False,_) | (_,False) -> False
| _ -> Maybe
let t_or a b = t_not (t_and (t_not a) (t_not b))
let t_eq a b = match (a,b) with
| (True,True... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Please provide an equivalent version of this Pascal code in PHP. |
unit ternarylogic;
interface
type
trit = (tFalse=-1, tMaybe=0, tTrue=1);
operator * (const a,b:trit):trit;
operator and (const a,b:trit):trit;inline;
operator or (const a,b:trit):trit;inline;
operator not (const a:trit):trit;inline;
operator xor (const a,b:trit):trit;
operator >< (const a... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Port the provided Perl code into PHP while preserving the original functionality. | use v5.36;
package Trit;
use List::Util qw(min max);
our @ISA = qw(Exporter);
our @EXPORT = qw(%E);
my %E = (true => 1, false => -1, maybe => 0);
use overload
'<=>' => sub ($a,$b) { $a->cmp($b) },
'cmp' => sub ($a,$b) { $a->cmp($b) },
'==' => sub ($a,$b,$) { $$a == $$b },
'eq' => sub ($a,$b... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Generate an equivalent PHP version of this Racket code. | #lang typed/racket
(define-type trit (U 'true 'false 'maybe))
(: not (trit -> trit))
(define (not a)
(case a
[(true) 'false]
[(maybe) 'maybe]
[(false) 'true]))
(: and (trit trit -> trit))
(define (and a b)
(case a
[(false) 'false]
[(maybe) (case b
[(false) 'false]
... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Generate a PHP translation of this REXX snippet without changing its computational steps. | tritValues = .array~of(.trit~true, .trit~false, .trit~maybe)
tab = '09'x
say "not operation (\)"
loop a over tritValues
say "\"a":" (\a)
end
say
say "and operation (&)"
loop aa over tritValues
loop bb over tritValues
say (aa" & "bb":" (aa&bb))
end
end
say
say "or operation (|)"
loop aa over tritV... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Write a version of this Ruby function in PHP with identical behavior. |
require 'singleton'
class MaybeClass
include Singleton
def to_s; "maybe"; end
end
MAYBE = MaybeClass.instance
class TrueClass
TritMagic = Object.new
class << TritMagic
def index; 0; end
def !; false; end
def & other; other; end
def | other; true; end
def ^ other; [false... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Produce a functionally identical PHP code for the snippet given in Scala. |
enum class Trit {
TRUE, MAYBE, FALSE;
operator fun not() = when (this) {
TRUE -> FALSE
MAYBE -> MAYBE
FALSE -> TRUE
}
infix fun and(other: Trit) = when (this) {
TRUE -> other
MAYBE -> if (other == FALSE) FALSE else MAYBE
FALSE -> FALSE
}
in... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Generate a PHP translation of this Tcl snippet without changing its computational steps. | package require Tcl 8.5
namespace eval ternary {
proc maketable {name count values} {
set sep ""
for {set i 0; set c 97} {$i<$count} {incr i;incr c} {
set v [format "%c" $c]
lappend args $v; append key $sep "$" $v
set sep ","
}
foreach row [split $values \n] {
if {[llength $row]>1} {
... | #!/usr/bin/php
<?php
# defined as numbers, so I can use max() and min() on it
if (! define('triFalse',0)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triMaybe',1)) trigger_error('Unknown error defining!', E_USER_ERROR);
if (! define('triTrue', 2)) trigger_error('Unknown error defining!', E... |
Port the provided C code into Rust while preserving the original functionality. | #include <stdio.h>
typedef enum {
TRITTRUE,
TRITMAYBE,
TRITFALSE
} trit;
trit tritNot[3] = {TRITFALSE , TRITMAYBE, TRITTRUE};
trit tritAnd[3][3] = { {TRITTRUE, TRITMAYBE, TRITFALSE},
{TRITMAYBE, TRITMAYBE, TRITFALSE},
{TRITFALSE, TRITFALSE, TRITFALSE} };
t... | use std::{ops, fmt};
#[derive(Copy, Clone, Debug)]
enum Trit {
True,
Maybe,
False,
}
impl ops::Not for Trit {
type Output = Self;
fn not(self) -> Self {
match self {
Trit::True => Trit::False,
Trit::Maybe => Trit::Maybe,
Trit::False => Trit::True,
... |
Preserve the algorithm and functionality while converting the code from C++ to Rust. | #include <iostream>
#include <stdlib.h>
class trit {
public:
static const trit False, Maybe, True;
trit operator !() const {
return static_cast<Value>(-value);
}
trit operator &&(const trit &b) const {
return (value < b.value) ? value : b.value;
}
trit operator ||(const trit ... | use std::{ops, fmt};
#[derive(Copy, Clone, Debug)]
enum Trit {
True,
Maybe,
False,
}
impl ops::Not for Trit {
type Output = Self;
fn not(self) -> Self {
match self {
Trit::True => Trit::False,
Trit::Maybe => Trit::Maybe,
Trit::False => Trit::True,
... |
Translate the given C# code snippet into Rust without altering its behavior. | using System;
public static class NullableBoolExtension
{
public static bool? Implies(this bool? left, bool? right)
{
return !left | right;
}
public static bool? IsEquivalentTo(this bool? left, bool? right)
{
return left.HasValue && right.HasValue ? left == right : default(bo... | use std::{ops, fmt};
#[derive(Copy, Clone, Debug)]
enum Trit {
True,
Maybe,
False,
}
impl ops::Not for Trit {
type Output = Self;
fn not(self) -> Self {
match self {
Trit::True => Trit::False,
Trit::Maybe => Trit::Maybe,
Trit::False => Trit::True,
... |
Translate this program into Rust but keep the logic exactly as in Java. | public class Logic{
public static enum Trit{
TRUE, MAYBE, FALSE;
public Trit and(Trit other){
if(this == TRUE){
return other;
}else if(this == MAYBE){
return (other == FALSE) ? FALSE : MAYBE;
}else{
return FALSE;
}
}
public Trit or(Trit other){
if(this == TRUE){
return TRUE... | use std::{ops, fmt};
#[derive(Copy, Clone, Debug)]
enum Trit {
True,
Maybe,
False,
}
impl ops::Not for Trit {
type Output = Self;
fn not(self) -> Self {
match self {
Trit::True => Trit::False,
Trit::Maybe => Trit::Maybe,
Trit::False => Trit::True,
... |
Write a version of this Go function in Rust with identical behavior. | package main
import "fmt"
type trit int8
const (
trFalse trit = iota - 1
trMaybe
trTrue
)
func (t trit) String() string {
switch t {
case trFalse:
return "False"
case trMaybe:
return "Maybe"
case trTrue:
return "True "
}
panic("Invalid trit")
}
func trNot... | use std::{ops, fmt};
#[derive(Copy, Clone, Debug)]
enum Trit {
True,
Maybe,
False,
}
impl ops::Not for Trit {
type Output = Self;
fn not(self) -> Self {
match self {
Trit::True => Trit::False,
Trit::Maybe => Trit::Maybe,
Trit::False => Trit::True,
... |
Can you help me rewrite this code in Python instead of Rust, keeping it the same logically? | use std::{ops, fmt};
#[derive(Copy, Clone, Debug)]
enum Trit {
True,
Maybe,
False,
}
impl ops::Not for Trit {
type Output = Self;
fn not(self) -> Self {
match self {
Trit::True => Trit::False,
Trit::Maybe => Trit::Maybe,
Trit::False => Trit::True,
... | class Trit(int):
def __new__(cls, value):
if value == 'TRUE':
value = 1
elif value == 'FALSE':
value = 0
elif value == 'MAYBE':
value = -1
return super(Trit, cls).__new__(cls, value // (abs(value) or 1))
def __repr__(self):
if self > ... |
Generate a C# translation of this Ada snippet without changing its computational steps. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Rewrite this program in C# while keeping its functionality equivalent to the Ada version. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Write a version of this Ada function in C with identical behavior. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Translate this program into C but keep the logic exactly as in Ada. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Ensure the translated C++ code behaves exactly like the original Ada snippet. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Convert this Ada snippet to C++ and keep its semantics consistent. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Convert the following code from Ada to Go, ensuring the logic remains intact. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Port the provided Ada code into Go while preserving the original functionality. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Write the same code in Java as shown below in Ada. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Translate the given Ada code snippet into Java without altering its behavior. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Translate this program into Python but keep the logic exactly as in Ada. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | import sys
print(sys.getrecursionlimit())
|
Please provide an equivalent version of this Ada code in Python. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | import sys
print(sys.getrecursionlimit())
|
Translate this program into VB but keep the logic exactly as in Ada. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Transform the following Ada implementation into VB, maintaining the same output and logic. | with Ada.Text_IO; use Ada.Text_IO;
procedure Test_Recursion_Depth is
function Recursion (Depth : Positive) return Positive is
begin
return Recursion (Depth + 1);
exception
when Storage_Error =>
return Depth;
end Recursion;
begin
Put_Line ("Recursion depth on this system is" & Integ... | Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Translate this program into C but keep the logic exactly as in Arturo. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Ensure the translated C code behaves exactly like the original Arturo snippet. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Can you help me rewrite this code in C# instead of Arturo, keeping it the same logically? | recurse: function [x][
print x
recurse x+1
]
recurse 0
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Transform the following Arturo implementation into C#, maintaining the same output and logic. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Convert this Arturo block to C++, preserving its control flow and logic. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Translate this program into C++ but keep the logic exactly as in Arturo. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Generate an equivalent Java version of this Arturo code. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Change the programming language of this snippet from Arturo to Java without modifying what it does. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Produce a language-to-language conversion: from Arturo to VB, same semantics. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Translate this program into VB but keep the logic exactly as in Arturo. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Translate the given Arturo code snippet into Go without altering its behavior. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Change the following Arturo code into Go without altering its purpose. | recurse: function [x][
print x
recurse x+1
]
recurse 0
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Change the following AutoHotKey code into C without altering its purpose. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Write the same algorithm in C as shown in this AutoHotKey implementation. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Translate this program into C# but keep the logic exactly as in AutoHotKey. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Ensure the translated C# code behaves exactly like the original AutoHotKey snippet. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Produce a language-to-language conversion: from AutoHotKey to C++, same semantics. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Please provide an equivalent version of this AutoHotKey code in C++. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Write a version of this AutoHotKey function in Java with identical behavior. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Translate this program into Java but keep the logic exactly as in AutoHotKey. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Produce a language-to-language conversion: from AutoHotKey to Python, same semantics. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| import sys
print(sys.getrecursionlimit())
|
Rewrite this program in Python while keeping its functionality equivalent to the AutoHotKey version. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| import sys
print(sys.getrecursionlimit())
|
Port the provided AutoHotKey code into VB while preserving the original functionality. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Write a version of this AutoHotKey function in VB with identical behavior. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Rewrite the snippet below in Go so it works the same as the original AutoHotKey code. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Produce a language-to-language conversion: from AutoHotKey to Go, same semantics. | Recurse(0)
Recurse(x)
{
TrayTip, Number, %x%
Recurse(x+1)
}
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Port the following code from AWK to C with equivalent syntax and logic. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Translate this program into C but keep the logic exactly as in AWK. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Port the following code from AWK to C# with equivalent syntax and logic. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Maintain the same structure and functionality when rewriting this code in C#. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Ensure the translated C++ code behaves exactly like the original AWK snippet. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Rewrite the snippet below in C++ so it works the same as the original AWK code. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Ensure the translated Java code behaves exactly like the original AWK snippet. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Convert the following code from AWK to Java, ensuring the logic remains intact. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Rewrite the snippet below in Python so it works the same as the original AWK code. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| import sys
print(sys.getrecursionlimit())
|
Write a version of this AWK function in Python with identical behavior. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| import sys
print(sys.getrecursionlimit())
|
Generate an equivalent VB version of this AWK code. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Write the same code in VB as shown below in AWK. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Rewrite this program in Go while keeping its functionality equivalent to the AWK version. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Convert this AWK block to Go, preserving its control flow and logic. |
BEGIN {
x()
print("done")
}
function x() {
print(++n)
if (n > 999999) { return }
x()
}
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Write the same code in C as shown below in BBC_Basic. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Rewrite this program in C while keeping its functionality equivalent to the BBC_Basic version. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| #include <stdio.h>
void recurse(unsigned int i)
{
printf("%d\n", i);
recurse(i+1);
}
int main()
{
recurse(0);
return 0;
}
|
Convert this BBC_Basic snippet to C# and keep its semantics consistent. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Write a version of this BBC_Basic function in C# with identical behavior. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| using System;
class RecursionLimit
{
static void Main(string[] args)
{
Recur(0);
}
private static void Recur(int i)
{
Console.WriteLine(i);
Recur(i + 1);
}
}
|
Rewrite the snippet below in C++ so it works the same as the original BBC_Basic code. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Ensure the translated C++ code behaves exactly like the original BBC_Basic snippet. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| #include <iostream>
void recurse(unsigned int i)
{
std::cout<<i<<"\n";
recurse(i+1);
}
int main()
{
recurse(0);
}
|
Rewrite this program in Java while keeping its functionality equivalent to the BBC_Basic version. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Generate a Java translation of this BBC_Basic snippet without changing its computational steps. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| public class RecursionTest {
private static void recurse(int i) {
try {
recurse(i+1);
} catch (StackOverflowError e) {
System.out.print("Recursion depth on this system is " + i + ".");
}
}
public static void main(String[] args) {
recurse(0);
}
}
|
Translate the given BBC_Basic code snippet into Python without altering its behavior. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| import sys
print(sys.getrecursionlimit())
|
Write the same code in Python as shown below in BBC_Basic. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| import sys
print(sys.getrecursionlimit())
|
Write the same algorithm in VB as shown in this BBC_Basic implementation. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Translate this program into VB but keep the logic exactly as in BBC_Basic. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| Option Explicit
Sub Main()
Debug.Print "The limit is : " & Limite_Recursivite(0)
End Sub
Function Limite_Recursivite(Cpt As Long) As Long
Cpt = Cpt + 1
On Error Resume Next
Limite_Recursivite Cpt
On Error GoTo 0
Limite_Recursivite = Cpt
End Function
|
Convert this BBC_Basic snippet to Go and keep its semantics consistent. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Port the following code from BBC_Basic to Go with equivalent syntax and logic. | PROCrecurse(1)
END
DEF PROCrecurse(depth%)
IF depth% MOD 100 = 0 PRINT TAB(0,0) depth%;
PROCrecurse(depth% + 1)
ENDPROC
| package main
import (
"flag"
"fmt"
"runtime/debug"
)
func main() {
stack := flag.Int("stack", 0, "maximum per goroutine stack size or 0 for the default")
flag.Parse()
if *stack > 0 {
debug.SetMaxStack(*stack)
}
r(1)
}
func r(l int) {
if l%1000 == 0 {
fmt.Println(l)
}
r(l + 1)
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.