Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Rewrite this program in PHP while keeping its functionality equivalent to the Fortran version.
program palindro implicit none character(len=*), parameter :: p = "ingirumimusnocteetconsumimurigni" print *, is_palindro_r(p) print *, is_palindro_r("anothertest") print *, is_palindro2(p) print *, is_palindro2("test") print *, is_palindro(p) print *, is_palindro("last test") contains
<?php function is_palindrome($string) { return $string == strrev($string); } ?>
Write the same code in C as shown below in Groovy.
def isPalindrome = { String s -> s == s?.reverse() }
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Port the following code from Groovy to C# with equivalent syntax and logic.
def isPalindrome = { String s -> s == s?.reverse() }
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Preserve the algorithm and functionality while converting the code from Groovy to C++.
def isPalindrome = { String s -> s == s?.reverse() }
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Please provide an equivalent version of this Groovy code in Java.
def isPalindrome = { String s -> s == s?.reverse() }
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Maintain the same structure and functionality when rewriting this code in Python.
def isPalindrome = { String s -> s == s?.reverse() }
def is_palindrome(s): return s == s[::-1]
Transform the following Groovy implementation into VB, maintaining the same output and logic.
def isPalindrome = { String s -> s == s?.reverse() }
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Rewrite the snippet below in Go so it works the same as the original Groovy code.
def isPalindrome = { String s -> s == s?.reverse() }
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Produce a functionally identical C code for the snippet given in Haskell.
is_palindrome x = x == reverse x
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Ensure the translated C# code behaves exactly like the original Haskell snippet.
is_palindrome x = x == reverse x
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Preserve the algorithm and functionality while converting the code from Haskell to C++.
is_palindrome x = x == reverse x
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Translate this program into Java but keep the logic exactly as in Haskell.
is_palindrome x = x == reverse x
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Produce a functionally identical VB code for the snippet given in Haskell.
is_palindrome x = x == reverse x
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Transform the following Haskell implementation into Go, maintaining the same output and logic.
is_palindrome x = x == reverse x
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Port the following code from Icon to C with equivalent syntax and logic.
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Change the following Icon code into C# without altering its purpose.
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Can you help me rewrite this code in C++ instead of Icon, keeping it the same logically?
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Transform the following Icon implementation into Java, maintaining the same output and logic.
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Change the programming language of this snippet from Icon to Python without modifying what it does.
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
def is_palindrome(s): return s == s[::-1]
Generate a VB translation of this Icon snippet without changing its computational steps.
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Rewrite the snippet below in Go so it works the same as the original Icon code.
procedure main(arglist) every writes(s := !arglist) do write( if palindrome(s) then " is " else " is not", " a palindrome.") end
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Write the same code in C as shown below in J.
isPalin0=: -: |.
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Produce a functionally identical C# code for the snippet given in J.
isPalin0=: -: |.
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Write the same code in Java as shown below in J.
isPalin0=: -: |.
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Please provide an equivalent version of this J code in VB.
isPalin0=: -: |.
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Convert this J snippet to Go and keep its semantics consistent.
isPalin0=: -: |.
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Port the following code from Julia to C with equivalent syntax and logic.
palindrome(s) = s == reverse(s)
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Transform the following Julia implementation into C#, maintaining the same output and logic.
palindrome(s) = s == reverse(s)
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Ensure the translated C++ code behaves exactly like the original Julia snippet.
palindrome(s) = s == reverse(s)
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Convert this Julia block to Java, preserving its control flow and logic.
palindrome(s) = s == reverse(s)
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Ensure the translated VB code behaves exactly like the original Julia snippet.
palindrome(s) = s == reverse(s)
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Transform the following Julia implementation into Go, maintaining the same output and logic.
palindrome(s) = s == reverse(s)
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Translate this program into C but keep the logic exactly as in Lua.
function ispalindrome(s) return s == string.reverse(s) end
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Preserve the algorithm and functionality while converting the code from Lua to C#.
function ispalindrome(s) return s == string.reverse(s) end
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Maintain the same structure and functionality when rewriting this code in C++.
function ispalindrome(s) return s == string.reverse(s) end
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Produce a functionally identical Java code for the snippet given in Lua.
function ispalindrome(s) return s == string.reverse(s) end
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Keep all operations the same but rewrite the snippet in Python.
function ispalindrome(s) return s == string.reverse(s) end
def is_palindrome(s): return s == s[::-1]
Maintain the same structure and functionality when rewriting this code in VB.
function ispalindrome(s) return s == string.reverse(s) end
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Rewrite the snippet below in Go so it works the same as the original Lua code.
function ispalindrome(s) return s == string.reverse(s) end
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Convert this Mathematica block to C, preserving its control flow and logic.
PalindromeQ
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Keep all operations the same but rewrite the snippet in C#.
PalindromeQ
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Ensure the translated C++ code behaves exactly like the original Mathematica snippet.
PalindromeQ
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Ensure the translated Java code behaves exactly like the original Mathematica snippet.
PalindromeQ
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Change the programming language of this snippet from Mathematica to VB without modifying what it does.
PalindromeQ
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Translate the given Mathematica code snippet into Go without altering its behavior.
PalindromeQ
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Generate an equivalent C version of this MATLAB code.
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Write the same code in C# as shown below in MATLAB.
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Convert this MATLAB snippet to C++ and keep its semantics consistent.
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Rewrite the snippet below in Java so it works the same as the original MATLAB code.
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Write the same algorithm in Python as shown in this MATLAB implementation.
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
def is_palindrome(s): return s == s[::-1]
Can you help me rewrite this code in VB instead of MATLAB, keeping it the same logically?
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Port the provided MATLAB code into Go while preserving the original functionality.
function trueFalse = isPalindrome(string) trueFalse = all(string == fliplr(string)); if not(trueFalse) string = lower(string); trueFalse = all(string == fliplr(string)); end if not(trueFalse) string(isspace(string)) = []; trueFalse = all(string == fliplr(...
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Generate a C translation of this Nim snippet without changing its computational steps.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Generate a C# translation of this Nim snippet without changing its computational steps.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Maintain the same structure and functionality when rewriting this code in C++.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Write a version of this Nim function in Java with identical behavior.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Convert this Nim block to Python, preserving its control flow and logic.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
def is_palindrome(s): return s == s[::-1]
Produce a functionally identical VB code for the snippet given in Nim.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Rewrite this program in Go while keeping its functionality equivalent to the Nim version.
import unicode func isPalindrome(rseq: seq[Rune]): bool = for i in 1..(rseq.len shr 1): if rseq[i - 1] != rseq[^i]: return false result = true func isPalindrome(str: string; exact = true): bool {.inline.} = if exact: result = str.toRunes.isPalindrome() else: var rseq: seq[Rune] ...
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Produce a language-to-language conversion: from OCaml to C, same semantics.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Port the provided OCaml code into C# while preserving the original functionality.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Write the same code in C++ as shown below in OCaml.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Maintain the same structure and functionality when rewriting this code in Java.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Produce a functionally identical Python code for the snippet given in OCaml.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
def is_palindrome(s): return s == s[::-1]
Convert this OCaml snippet to VB and keep its semantics consistent.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Keep all operations the same but rewrite the snippet in Go.
fun to_locase s = implode ` map (c_downcase) ` explode s fun only_alpha s = implode ` filter (fn x = c_alphabetic x) ` explode s fun is_palin ( h1 :: t1, h2 :: t2, n = 0 ) = true | ( h1 :: t1, h2 :: t2, n ) where ( h1 eql h2 ) = is_palin( t1, t2, n - 1) | ( h1 :: t1, h2 :: t2, n ) = fa...
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Generate an equivalent C version of this Pascal code.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Port the following code from Pascal to C# with equivalent syntax and logic.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Transform the following Pascal implementation into C++, maintaining the same output and logic.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Please provide an equivalent version of this Pascal code in Java.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Please provide an equivalent version of this Pascal code in Python.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
def is_palindrome(s): return s == s[::-1]
Write the same algorithm in VB as shown in this Pascal implementation.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Produce a functionally identical Go code for the snippet given in Pascal.
program Palindro; function is_palindro_r(s : String) : Boolean; begin if length(s) <= 1 then is_palindro_r := true else begin if s[1] = s[length(s)] then is_palindro_r := is_palindro_r(copy(s, 2, length(s)-2)) else is_palindro_r := false end end; function is_palindro(s : String) : Bo...
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Produce a language-to-language conversion: from Perl to C, same semantics.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Please provide an equivalent version of this Perl code in C#.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Maintain the same structure and functionality when rewriting this code in C++.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Change the programming language of this snippet from Perl to Java without modifying what it does.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Produce a language-to-language conversion: from Perl to Python, same semantics.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
def is_palindrome(s): return s == s[::-1]
Produce a functionally identical VB code for the snippet given in Perl.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Port the following code from Perl to Go with equivalent syntax and logic.
package Palindrome; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw(palindrome palindrome_c palindrome_r palindrome_e); sub palindrome { my $s = (@_ ? shift : $_); return $s eq reverse $s; } sub palindrome_c { my $s = (@_ ? shift : $_); for my $i (0 .. length($s) >> 1) { ...
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Write a version of this PowerShell function in C with identical behavior.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Port the provided PowerShell code into C# while preserving the original functionality.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Rewrite this program in C++ while keeping its functionality equivalent to the PowerShell version.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Change the programming language of this snippet from PowerShell to Java without modifying what it does.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Port the following code from PowerShell to Python with equivalent syntax and logic.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
def is_palindrome(s): return s == s[::-1]
Produce a functionally identical VB code for the snippet given in PowerShell.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Write a version of this PowerShell function in Go with identical behavior.
Function Test-Palindrome( [String] $Text ){ $CharArray = $Text.ToCharArray() [Array]::Reverse($CharArray) $Text -eq [string]::join('', $CharArray) }
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Produce a functionally identical C code for the snippet given in Racket.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Convert this Racket block to C#, preserving its control flow and logic.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Produce a functionally identical C++ code for the snippet given in Racket.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Convert the following code from Racket to Java, ensuring the logic remains intact.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Produce a language-to-language conversion: from Racket to Python, same semantics.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
def is_palindrome(s): return s == s[::-1]
Transform the following Racket implementation into VB, maintaining the same output and logic.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...
Convert this Racket block to Go, preserving its control flow and logic.
(define (palindromb str) (let* ([lst (string->list (string-downcase str))] [slst (remove* '(#\space) lst)]) (string=? (list->string (reverse slst)) (list->string slst)))) > (palindromb "able was i ere i saw elba") #t > (palindromb "waht the hey") #f > (palindromb "In girum imus nocte et consumimur ign...
var str; str = argument0 str = string_lettersdigits(string_lower(string_replace(str,' ',''))); var inv; inv = ''; var i; for (i = 0; i < string_length(str); i += 1;) { inv += string_copy(str,string_length(str)-i,1); } return (str == inv);
Keep all operations the same but rewrite the snippet in C.
identification division. function-id. palindromic-test. data division. linkage section. 01 test-text pic x any length. 01 result pic x. 88 palindromic value high-value when set to false low-value. ...
#include <string.h> int palindrome(const char *s) { int i,l; l = strlen(s); for(i=0; i<l/2; i++) { if ( s[i] != s[l-i-1] ) return 0; } return 1; }
Write the same algorithm in C# as shown in this COBOL implementation.
identification division. function-id. palindromic-test. data division. linkage section. 01 test-text pic x any length. 01 result pic x. 88 palindromic value high-value when set to false low-value. ...
using System; class Program { static string Reverse(string value) { char[] chars = value.ToCharArray(); Array.Reverse(chars); return new string(chars); } static bool IsPalindrome(string value) { return value == Reverse(value); } static void Main(string[] ar...
Can you help me rewrite this code in C++ instead of COBOL, keeping it the same logically?
identification division. function-id. palindromic-test. data division. linkage section. 01 test-text pic x any length. 01 result pic x. 88 palindromic value high-value when set to false low-value. ...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Convert the following code from COBOL to Java, ensuring the logic remains intact.
identification division. function-id. palindromic-test. data division. linkage section. 01 test-text pic x any length. 01 result pic x. 88 palindromic value high-value when set to false low-value. ...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Convert this COBOL block to Python, preserving its control flow and logic.
identification division. function-id. palindromic-test. data division. linkage section. 01 test-text pic x any length. 01 result pic x. 88 palindromic value high-value when set to false low-value. ...
def is_palindrome(s): return s == s[::-1]
Change the following COBOL code into VB without altering its purpose.
identification division. function-id. palindromic-test. data division. linkage section. 01 test-text pic x any length. 01 result pic x. 88 palindromic value high-value when set to false low-value. ...
function Squish( s1 ) dim sRes sRes = vbNullString dim i, c for i = 1 to len( s1 ) c = lcase( mid( s1, i, 1 )) if instr( "abcdefghijklmnopqrstuvwxyz0123456789", c ) then sRes = sRes & c end if next Squish = sRes end function function isPalindrome( s1 ) dim squished squished = Squish( s1 ) isPalindr...