Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Produce a language-to-language conversion: from Ada to Java, same semantics.
function Palindrome (Text : String) return Boolean is begin for Offset in 0..Text'Length / 2 - 1 loop if Text (Text'First + Offset) /= Text (Text'Last - Offset) then return False; end if; end loop; return True; end Palindrome;
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Write the same code in Python as shown below in Ada.
function Palindrome (Text : String) return Boolean is begin for Offset in 0..Text'Length / 2 - 1 loop if Text (Text'First + Offset) /= Text (Text'Last - Offset) then return False; end if; end loop; return True; end Palindrome;
def is_palindrome(s): return s == s[::-1]
Can you help me rewrite this code in VB instead of Ada, keeping it the same logically?
function Palindrome (Text : String) return Boolean is begin for Offset in 0..Text'Length / 2 - 1 loop if Text (Text'First + Offset) /= Text (Text'Last - Offset) then return False; end if; end loop; return True; end Palindrome;
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 C while keeping its functionality equivalent to the Arturo version.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
#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#.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
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 language-to-language conversion: from Arturo to C++, same semantics.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Generate an equivalent Java version of this Arturo code.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Generate a Python translation of this Arturo snippet without changing its computational steps.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
def is_palindrome(s): return s == s[::-1]
Generate a VB translation of this Arturo snippet without changing its computational steps.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
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 language-to-language conversion: from Arturo to Go, same semantics.
palindrome?: $[seq] -> seq = reverse seq loop ["abba" "boom" "radar" "civic" "great"] 'wrd [ print [wrd ": palindrome?" palindrome? wrd] ]
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);
Maintain the same structure and functionality when rewriting this code in C.
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
#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; }
Can you help me rewrite this code in C# instead of AutoHotKey, keeping it the same logically?
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
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 AutoHotKey implementation into C++, maintaining the same output and logic.
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Produce a language-to-language conversion: from AutoHotKey to Java, same semantics.
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Preserve the algorithm and functionality while converting the code from AutoHotKey to Python.
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
def is_palindrome(s): return s == s[::-1]
Transform the following AutoHotKey implementation into VB, maintaining the same output and logic.
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
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 AutoHotKey snippet to Go and keep its semantics consistent.
IsPalindrome(Str){ Loop, Parse, Str ReversedStr := A_LoopField . ReversedStr return, (ReversedStr == Str)?"Exact":(RegExReplace(ReversedStr,"\W")=RegExReplace(Str,"\W"))?"Inexact":"False" }
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);
Please provide an equivalent version of this AWK code in C.
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
#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 AWK snippet without changing its computational steps.
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
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 a version of this AWK function in C++ with identical behavior.
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Convert this AWK block to Java, preserving its control flow and logic.
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Preserve the algorithm and functionality while converting the code from AWK to Python.
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
def is_palindrome(s): return s == s[::-1]
Rewrite this program in VB while keeping its functionality equivalent to the AWK version.
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
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...
Can you help me rewrite this code in Go instead of AWK, keeping it the same logically?
function is_palindro(s) { if ( s == reverse(s) ) return 1 return 0 }
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);
Ensure the translated C code behaves exactly like the original BBC_Basic snippet.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
#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; }
Maintain the same structure and functionality when rewriting this code in C#.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
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 BBC_Basic to C++.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
#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 BBC_Basic code in Java.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
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 BBC_Basic.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
def is_palindrome(s): return s == s[::-1]
Translate this program into VB but keep the logic exactly as in BBC_Basic.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
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...
Preserve the algorithm and functionality while converting the code from BBC_Basic to Go.
test$ = "A man, a plan, a canal: Panama!" PRINT """" test$ """" ; IF FNpalindrome(FNletters(test$)) THEN PRINT " is a palindrome" ELSE PRINT " is not a palindrome" ENDIF END DEF FNpalindrome(A$) = (A$ = FNreverse(A$)) DEF FNreverse(A$) ...
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 provided Clojure code into C while preserving the original functionality.
(defn palindrome? [s] (= s (clojure.string/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; }
Rewrite this program in C# while keeping its functionality equivalent to the Clojure version.
(defn palindrome? [s] (= s (clojure.string/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...
Produce a functionally identical C++ code for the snippet given in Clojure.
(defn palindrome? [s] (= s (clojure.string/reverse s)))
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Can you help me rewrite this code in Java instead of Clojure, keeping it the same logically?
(defn palindrome? [s] (= s (clojure.string/reverse s)))
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 Clojure.
(defn palindrome? [s] (= s (clojure.string/reverse s)))
def is_palindrome(s): return s == s[::-1]
Convert this Clojure snippet to VB and keep its semantics consistent.
(defn palindrome? [s] (= s (clojure.string/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...
Please provide an equivalent version of this Clojure code in Go.
(defn palindrome? [s] (= s (clojure.string/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);
Write the same algorithm in C as shown in this Common_Lisp implementation.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
#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 Common_Lisp code into C# without altering its purpose.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
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++.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
#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 Common_Lisp.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
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.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
def is_palindrome(s): return s == s[::-1]
Rewrite the snippet below in VB so it works the same as the original Common_Lisp code.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
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 Common_Lisp version.
(defun reverse-split-at-r (xs i ys) (if (zp i) (mv xs ys) (reverse-split-at-r (rest xs) (1- i) (cons (first xs) ys)))) (defun reverse-split-at (xs i) (reverse-split-at-r xs i nil)) (defun is-palindrome (str) (let* ((lngth (length str)) (idx (floor lngth 2))) (m...
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);
Ensure the translated C code behaves exactly like the original D snippet.
import std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
#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; }
Translate this program into C# but keep the logic exactly as in D.
import std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
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 std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Translate the given D code snippet into Java without altering its behavior.
import std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Convert this D block to Python, preserving its control flow and logic.
import std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
def is_palindrome(s): return s == s[::-1]
Maintain the same structure and functionality when rewriting this code in VB.
import std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
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 D.
import std.traits, std.algorithm; bool isPalindrome1(C)(in C[] s) pure if (isSomeChar!C) { auto s2 = s.dup; s2.reverse(); return s == s2; } void main() { alias pali = isPalindrome1; assert(pali("")); assert(pali("z")); assert(pali("aha")); assert(pali("sees")); assert(!pali("oofo...
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);
Change the programming language of this snippet from Delphi to C without modifying what it does.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); 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; }
Port the following code from Delphi to C# with equivalent syntax and logic.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); 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...
Convert the following code from Delphi to C++, ensuring the logic remains intact.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); end;
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Port the following code from Delphi to Java with equivalent syntax and logic.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); end;
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Convert this Delphi snippet to Python and keep its semantics consistent.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); end;
def is_palindrome(s): return s == s[::-1]
Preserve the algorithm and functionality while converting the code from Delphi to VB.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); 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...
Convert this Delphi block to Go, preserving its control flow and logic.
uses SysUtils, StrUtils; function IsPalindrome(const aSrcString: string): Boolean; begin Result := SameText(aSrcString, ReverseString(aSrcString)); 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);
Translate the given Elixir code snippet into C without altering its behavior.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) 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; }
Please provide an equivalent version of this Elixir code in C#.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) 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...
Produce a functionally identical C++ code for the snippet given in Elixir.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) end
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Produce a language-to-language conversion: from Elixir to Java, same semantics.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) 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 Elixir to Python without modifying what it does.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) end
def is_palindrome(s): return s == s[::-1]
Write the same code in VB as shown below in Elixir.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) 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...
Translate this program into Go but keep the logic exactly as in Elixir.
defmodule PalindromeDetection do def is_palindrome(str), do: str == String.reverse(str) 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);
Transform the following Erlang implementation into C, maintaining the same output and logic.
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
#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 a version of this Erlang function in C# with identical behavior.
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
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 Erlang version.
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Can you help me rewrite this code in Java instead of Erlang, keeping it the same logically?
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Convert the following code from Erlang to Python, ensuring the logic remains intact.
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
def is_palindrome(s): return s == s[::-1]
Translate this program into VB but keep the logic exactly as in Erlang.
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
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 Erlang.
-module( palindrome ). -export( [is_palindrome/1, task/0] ). is_palindrome( String ) -> String =:= lists:reverse(String). task() -> display( "abcba" ), display( "abcdef" ), Latin = "In girum imus nocte et consumimur igni", No_spaces_same_case = lists:append( string:tokens(string:to_lower(Latin), " ") ), display...
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);
Can you help me rewrite this code in C instead of F#, keeping it the same logically?
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
#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 F# snippet.
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
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++.
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Convert this F# block to Java, preserving its control flow and logic.
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Convert this F# block to Python, preserving its control flow and logic.
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
def is_palindrome(s): return s == s[::-1]
Write a version of this F# function in VB with identical behavior.
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
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 this program into Go but keep the logic exactly as in F#.
let isPalindrome (s: string) = let arr = s.ToCharArray() arr = Array.rev arr
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 Factor to C with equivalent syntax and logic.
USING: kernel sequences ; : palindrome? ( str -- ? ) dup 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; }
Rewrite this program in C# while keeping its functionality equivalent to the Factor version.
USING: kernel sequences ; : palindrome? ( str -- ? ) dup 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...
Port the following code from Factor to C++ with equivalent syntax and logic.
USING: kernel sequences ; : palindrome? ( str -- ? ) dup reverse = ;
#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 Factor code.
USING: kernel sequences ; : palindrome? ( str -- ? ) dup reverse = ;
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Generate an equivalent Python version of this Factor code.
USING: kernel sequences ; : palindrome? ( str -- ? ) dup reverse = ;
def is_palindrome(s): return s == s[::-1]
Can you help me rewrite this code in VB instead of Factor, keeping it the same logically?
USING: kernel sequences ; : palindrome? ( str -- ? ) dup 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...
Ensure the translated Go code behaves exactly like the original Factor snippet.
USING: kernel sequences ; : palindrome? ( str -- ? ) dup 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);
Port the provided Forth code into C while preserving the original functionality.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
#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 Forth implementation.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
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...
Change the programming language of this snippet from Forth to C++ without modifying what it does.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Convert this Forth snippet to Java and keep its semantics consistent.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
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 Forth.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
def is_palindrome(s): return s == s[::-1]
Change the programming language of this snippet from Forth to VB without modifying what it does.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
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 the following code from Forth to Go, ensuring the logic remains intact.
: first over c@ ; : last >r 2dup + 1- c@ r> swap ; : palindrome? begin dup 1 <= if 2drop true exit then first last <> if 2drop false exit then 1 /string 1- again ;
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);
Change the following Fortran code into C# without altering its purpose.
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
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...
Change the following Fortran code into C++ without altering its purpose.
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
#include <string> #include <algorithm> bool is_palindrome(std::string const& s) { return std::equal(s.begin(), s.end(), s.rbegin()); }
Preserve the algorithm and functionality while converting the code from Fortran to C.
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
#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 Fortran snippet to Java and keep its semantics consistent.
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
public static boolean pali(String testMe){ StringBuilder sb = new StringBuilder(testMe); return testMe.equals(sb.reverse().toString()); }
Change the following Fortran code into Python without altering its purpose.
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
def is_palindrome(s): return s == s[::-1]
Transform the following Fortran implementation into VB, maintaining the same output and logic.
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
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...