Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Write the same code in C as shown below in Factor. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Port the provided Factor code into C# while preserving the original functionality. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Convert this Factor block to C++, preserving its control flow and logic. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Ensure the translated Java code behaves exactly like the original Factor snippet. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Port the following code from Factor to Python with equivalent syntax and logic. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Ensure the translated VB code behaves exactly like the original Factor snippet. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Write the same code in Go as shown below in Factor. | "alphaBETA" >lower
"alphaBETA" >upper
"alphaBETA" >title
"ß" >case-fold
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Generate a C# translation of this Fortran snippet without changing its computational steps. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Transform the following Fortran implementation into C++, maintaining the same output and logic. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Convert this Fortran snippet to C and keep its semantics consistent. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Generate a Java translation of this Fortran snippet without changing its computational steps. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Please provide an equivalent version of this Fortran code in Python. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Change the programming language of this snippet from Fortran to VB without modifying what it does. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Write the same algorithm in PHP as shown in this Fortran implementation. | program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example
| $str = "alphaBETA";
echo strtoupper($str), "\n"; // ALPHABETA
echo strtolower($str), "\n"; // alphabeta
echo ucfirst($str), "\n"; // AlphaBETA
echo lcfirst("FOObar"), "\n"; // fOObar
echo ucwords("foO baR baZ"), "\n"; // FoO BaR BaZ
echo lcwords("FOo BAr BAz"), "\n"; // fOo bAr bAz
|
Can you help me rewrite this code in C instead of Groovy, keeping it the same logically? | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Preserve the algorithm and functionality while converting the code from Groovy to C#. | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Port the following code from Groovy to C++ with equivalent syntax and logic. | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Write a version of this Groovy function in Java with identical behavior. | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Convert this Groovy block to Python, preserving its control flow and logic. | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Rewrite this program in VB while keeping its functionality equivalent to the Groovy version. | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Write the same algorithm in Go as shown in this Groovy implementation. | def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Port the provided Haskell code into C while preserving the original functionality. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Ensure the translated C# code behaves exactly like the original Haskell snippet. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Convert this Haskell block to C++, preserving its control flow and logic. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Rewrite the snippet below in Java so it works the same as the original Haskell code. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Please provide an equivalent version of this Haskell code in Python. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Produce a functionally identical VB code for the snippet given in Haskell. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Rewrite this program in Go while keeping its functionality equivalent to the Haskell version. | import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Change the programming language of this snippet from Icon to C without modifying what it does. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Convert this Icon block to C#, preserving its control flow and logic. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Preserve the algorithm and functionality while converting the code from Icon to C++. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Change the programming language of this snippet from Icon to Java without modifying what it does. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Generate a Python translation of this Icon snippet without changing its computational steps. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Maintain the same structure and functionality when rewriting this code in VB. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Change the following Icon code into Go without altering its purpose. | procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Change the following J code into C without altering its purpose. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Keep all operations the same but rewrite the snippet in C#. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Write the same algorithm in C++ as shown in this J implementation. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Please provide an equivalent version of this J code in Java. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Generate a Python translation of this J snippet without changing its computational steps. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Please provide an equivalent version of this J code in VB. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Change the programming language of this snippet from J to Go without modifying what it does. | toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Please provide an equivalent version of this Julia code in C. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Write the same algorithm in C# as shown in this Julia implementation. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Change the programming language of this snippet from Julia to C++ without modifying what it does. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Change the following Julia code into Java without altering its purpose. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Write a version of this Julia function in Python with identical behavior. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Translate this program into VB but keep the logic exactly as in Julia. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Translate this program into Go but keep the logic exactly as in Julia. | julia> uppercase("alphaBETA")
"ALPHABETA"
julia> lowercase("alphaBETA")
"alphabeta"
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Ensure the translated C code behaves exactly like the original Lua snippet. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Convert the following code from Lua to C#, ensuring the logic remains intact. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Maintain the same structure and functionality when rewriting this code in C++. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Produce a language-to-language conversion: from Lua to Java, same semantics. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Port the following code from Lua to Python with equivalent syntax and logic. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Write the same code in VB as shown below in Lua. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Preserve the algorithm and functionality while converting the code from Lua to Go. | str = "alphaBETA"
print( string.upper(str) )
print( string.lower(str) )
print ( str:upper() )
print ( str:lower() )
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Preserve the algorithm and functionality while converting the code from Mathematica to C. | str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Generate an equivalent C++ version of this Mathematica code. | str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Generate an equivalent Java version of this Mathematica code. | str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Transform the following Mathematica implementation into Python, maintaining the same output and logic. | str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Produce a language-to-language conversion: from Mathematica to VB, same semantics. | str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Write a version of this Mathematica function in Go with identical behavior. | str="alphaBETA";
ToUpperCase[str]
ToLowerCase[str]
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Transform the following MATLAB implementation into C, maintaining the same output and logic. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Translate this program into C# but keep the logic exactly as in MATLAB. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Translate this program into C++ but keep the logic exactly as in MATLAB. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Generate an equivalent Java version of this MATLAB code. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Generate an equivalent Python version of this MATLAB code. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Translate this program into VB but keep the logic exactly as in MATLAB. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Preserve the algorithm and functionality while converting the code from MATLAB to Go. | >> upper('alphaBETA')
ans =
ALPHABETA
>> lower('alphaBETA')
ans =
alphabeta
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Transform the following Nim implementation into C, maintaining the same output and logic. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Change the following Nim code into C# without altering its purpose. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Transform the following Nim implementation into C++, maintaining the same output and logic. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Change the programming language of this snippet from Nim to Java without modifying what it does. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Keep all operations the same but rewrite the snippet in Python. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Change the programming language of this snippet from Nim to VB without modifying what it does. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Port the provided Nim code into Go while preserving the original functionality. | import strutils
var s: string = "alphaBETA_123"
echo s, " as upper case: ", toUpperAscii(s)
echo s, " as lower case: ", toLowerAscii(s)
echo s, " as capitalized: ", capitalizeAscii(s)
echo s, " as normal case: ", normalize(s)
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Translate the given OCaml code snippet into C without altering its behavior. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Rewrite the snippet below in C# so it works the same as the original OCaml code. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Write the same algorithm in C++ as shown in this OCaml implementation. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Change the following OCaml code into Java without altering its purpose. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Preserve the algorithm and functionality while converting the code from OCaml to Python. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Convert this OCaml block to VB, preserving its control flow and logic. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Change the following OCaml code into Go without altering its purpose. | let () =
let str = "alphaBETA" in
print_endline (String.uppercase_ascii str);
print_endline (String.lowercase_ascii str);
print_endline (String.capitalize_ascii str);
;;
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Write the same algorithm in C as shown in this Pascal implementation. | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Translate the given Pascal code snippet into C# without altering its behavior. | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Convert this Pascal block to C++, preserving its control flow and logic. | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Translate this program into Java but keep the logic exactly as in Pascal. | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Can you help me rewrite this code in Python instead of Pascal, keeping it the same logically? | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Change the following Pascal code into VB without altering its purpose. | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Write a version of this Pascal function in Go with identical behavior. | writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Transform the following Perl implementation into C, maintaining the same output and logic. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Translate the given Perl code snippet into C# without altering its behavior. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Keep all operations the same but rewrite the snippet in C++. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Convert this Perl snippet to Java and keep its semantics consistent. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
| String str = "alphaBETA";
System.out.println(str.toUpperCase());
System.out.println(str.toLowerCase());
System.out.println("äàâáçñßæεбế".toUpperCase());
System.out.println("ÄÀÂÁÇÑSSÆΕБẾ".toLowerCase());
|
Rewrite the snippet below in Python so it works the same as the original Perl code. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
| s = "alphaBETA"
print s.upper()
print s.lower()
print s.swapcase()
print "fOo bAR".capitalize()
print "fOo bAR".title()
import string
print string.capwords("fOo bAR")
|
Port the following code from Perl to VB with equivalent syntax and logic. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
| Sub Main()
Const TESTSTRING As String = "alphaBETA"
Debug.Print "initial = " _
& TESTSTRING
Debug.Print "uppercase = " _
& UCase(TESTSTRING)
Debug.Print "lowercase = " _
& LCase(TESTSTRING)
Debug.Print "first letter capitalized = " _
& StrConv(TESTSTRING, vbProperCase)
Debug.Print "length (in characters) = " _
& CStr(Len(TESTSTRING))
Debug.Print "length (in bytes) = " _
& CStr(LenB(TESTSTRING))
Debug.Print "reversed = " _
& StrReverse(TESTSTRING)
Debug.Print "first position of letter A (case-sensitive) = " _
& InStr(1, TESTSTRING, "A", vbBinaryCompare)
Debug.Print "first position of letter A (case-insensitive) = " _
& InStr(1, TESTSTRING, "A", vbTextCompare)
Debug.Print "concatenated with
& TESTSTRING & "123"
End Sub
|
Generate an equivalent Go version of this Perl code. | my $string = "alphaBETA";
print uc($string), "\n";
print lc($string), "\n";
$string =~ tr/[a-z][A-Z]/[A-Z][a-z]/; print "$string\n";
print ucfirst($string), "\n";
print lcfirst("FOObar"), "\n";
| package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
show("DŽLjnj")
show("o'hare O'HARE o’hare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes")
fmt.Println("All upper case: ", strings.ToUpper(s))
fmt.Println("All lower case: ", strings.ToLower(s))
fmt.Println("All title case: ", strings.ToTitle(s))
fmt.Println("Title words: ", strings.Title(s))
fmt.Println("Swapping case: ",
strings.Map(unicode.SimpleFold, s))
}
|
Write a version of this PowerShell function in C with identical behavior. | $string = 'alphaBETA'
$lower = $string.ToLower()
$upper = $string.ToUpper()
$title = (Get-Culture).TextInfo.ToTitleCase($string)
$lower, $upper, $title
|
#include <ctype.h>
#include <stdio.h>
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}
|
Write the same code in C# as shown below in PowerShell. | $string = 'alphaBETA'
$lower = $string.ToLower()
$upper = $string.ToUpper()
$title = (Get-Culture).TextInfo.ToTitleCase($string)
$lower, $upper, $title
| using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}
|
Convert this PowerShell block to C++, preserving its control flow and logic. | $string = 'alphaBETA'
$lower = $string.ToLower()
$upper = $string.ToUpper()
$title = (Get-Culture).TextInfo.ToTitleCase($string)
$lower, $upper, $title
| #include <algorithm>
#include <string>
#include <cctype>
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.