Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Ensure the translated Java code behaves exactly like the original OCaml snippet. | # let li = ["big"; "fjords"; "vex"; "quick"; "waltz"; "nymph"] in
List.iter print_endline li ;;
big
fjords
vex
quick
waltz
nymph
- : unit = ()
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Convert this OCaml snippet to Python and keep its semantics consistent. | # let li = ["big"; "fjords"; "vex"; "quick"; "waltz"; "nymph"] in
List.iter print_endline li ;;
big
fjords
vex
quick
waltz
nymph
- : unit = ()
| for node in lst:
print node.value
|
Transform the following OCaml implementation into Go, maintaining the same output and logic. | # let li = ["big"; "fjords"; "vex"; "quick"; "waltz"; "nymph"] in
List.iter print_endline li ;;
big
fjords
vex
quick
waltz
nymph
- : unit = ()
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Preserve the algorithm and functionality while converting the code from Perl to C. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Port the following code from Perl to C# with equivalent syntax and logic. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Convert this Perl block to C++, preserving its control flow and logic. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Preserve the algorithm and functionality while converting the code from Perl to Java. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Change the programming language of this snippet from Perl to Python without modifying what it does. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | for node in lst:
print node.value
|
Rewrite this program in VB while keeping its functionality equivalent to the Perl version. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Change the following Perl code into Go without altering its purpose. | package SSL_Node;
use strict;
use Class::Tiny qw( val next );
sub BUILD {
my $self = shift;
exists($self->{val}) or die "Must supply 'val'";
if (exists $self->{next}) {
ref($self->{next}) eq 'SSL_Node'
or die "If supplied, 'next' must be an SSL_Node";
}
return;
}
package main;
... | start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Write a version of this Racket function in C with identical behavior. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Produce a functionally identical C# code for the snippet given in Racket. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Preserve the algorithm and functionality while converting the code from Racket to C++. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Produce a functionally identical Java code for the snippet given in Racket. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Rewrite this program in Python while keeping its functionality equivalent to the Racket version. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | for node in lst:
print node.value
|
Port the provided Racket code into VB while preserving the original functionality. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Maintain the same structure and functionality when rewriting this code in Go. | #lang racket
(define l (list 1 2 3))
(map add1 l)
(for-each displayln l)
(foldl + 0 l)
(for/list ([x (in-list l)]) (add1 x))
(for ([x (in-list l)]) (displayln x))
(for/fold ([sum 0]) ([x (in-list l)]) (+ x sum))
(for/vector ([x (in-list l)]) (add1 x))
(require racket/mpair)
(define ml (mlist 1 2 3))
(mma... | start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Translate this program into C but keep the logic exactly as in REXX. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Produce a functionally identical C# code for the snippet given in REXX. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Change the following REXX code into C++ without altering its purpose. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Generate a Java translation of this REXX snippet without changing its computational steps. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Produce a language-to-language conversion: from REXX to Python, same semantics. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| for node in lst:
print node.value
|
Port the following code from REXX to VB with equivalent syntax and logic. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Produce a functionally identical Go code for the snippet given in REXX. | list=.list~of('A','B','X')
say "Manual list traversal"
index=list~first
loop while index \== .nil
say list~at(index)
index = list~next(index)
end
say
say "Do ... Over traversal"
do value over list
say value
end
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Produce a functionally identical C code for the snippet given in Ruby. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Port the provided Ruby code into C# while preserving the original functionality. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Convert this Ruby snippet to C++ and keep its semantics consistent. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Generate an equivalent Java version of this Ruby code. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Translate the given Ruby code snippet into Python without altering its behavior. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| for node in lst:
print node.value
|
Port the following code from Ruby to VB with equivalent syntax and logic. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Port the provided Ruby code into Go while preserving the original functionality. | head = ListNode.new("a", ListNode.new("b", ListNode.new("c")))
head.insertAfter("b", "b+")
head.each {|node| print node.value, ","}
puts
current = head
begin
print current.value, ","
end while current = current.succ
puts
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Translate this program into C but keep the logic exactly as in Scala. | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Can you help me rewrite this code in C# instead of Scala, keeping it the same logically? | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Convert this Scala snippet to C++ and keep its semantics consistent. | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Produce a functionally identical Java code for the snippet given in Scala. | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Please provide an equivalent version of this Scala code in Python. | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| for node in lst:
print node.value
|
Translate this program into VB but keep the logic exactly as in Scala. | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Please provide an equivalent version of this Scala code in Go. | fun main(args: Array<String>) {
val list = IntRange(1, 50).toList()
for (i in list) { print("%4d ".format(i)); if (i % 10 == 0) println() }
list.asReversed().forEach { print("%4d ".format(it)); if (it % 10 == 1) println() }
}
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Can you help me rewrite this code in C instead of Tcl, keeping it the same logically? | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
Change the following Tcl code into C# without altering its purpose. | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
Change the programming language of this snippet from Tcl to C++ without modifying what it does. | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
Can you help me rewrite this code in Java instead of Tcl, keeping it the same logically? | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
Translate this program into Python but keep the logic exactly as in Tcl. | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| for node in lst:
print node.value
|
Change the programming language of this snippet from Tcl to VB without modifying what it does. | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Write the same algorithm in Go as shown in this Tcl implementation. | oo::define List {
method for {varName script} {
upvar 1 $varName var
set elem [self]
while {$elem ne ""} {
set var [$elem value]
uplevel 1 $script
set elem [$elem next]
}
}
}
| start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
Write the same code in Rust as shown below in C. | struct link *first;
struct link *iter;
for(iter = first; iter != NULL; iter = iter->next) {
}
|
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... |
Convert the following code from C# to Rust, ensuring the logic remains intact. | var current = [head of list to traverse]
while(current != null)
{
current = current.Next;
}
|
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... |
Write the same code in Rust as shown below in Java. | LinkedList<Type> list = new LinkedList<Type>();
for(Type i: list){
System.out.println(i);
}
|
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... |
Produce a language-to-language conversion: from Rust to VB, same semantics. |
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... | Private Sub Iterate(ByVal list As LinkedList(Of Integer))
Dim node = list.First
Do Until node Is Nothing
node = node.Next
Loop
End Sub
|
Preserve the algorithm and functionality while converting the code from Go to Rust. | start := &Ele{"tacos", nil}
end := start.Append("burritos")
end = end.Append("fajitas")
end = end.Append("enchilatas")
for iter := start; iter != nil; iter = iter.Next {
fmt.Println(iter)
}
|
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... |
Change the following C++ code into Rust without altering its purpose. | #include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> list{1, 2, 3, 4, 5};
for (int e : list)
std::cout << e << std::endl;
}
|
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... |
Ensure the translated Python code behaves exactly like the original Rust snippet. |
pub struct IntoIter<T>(List<T>);
impl<T> Iterator for IntoIter<T> {
type Item = T;
fn next(&mut self) -> Option<Self::Item> {
self.0.head.take().map(|node| {
let node = *node;
self.0.head = node.next;
node.elem
})
}
}
pub struct Iter<'a, T: '... | for node in lst:
print node.value
|
Convert the following code from Ada to C#, ensuring the logic remains intact. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Ensure the translated C# code behaves exactly like the original Ada snippet. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Convert the following code from Ada to C, ensuring the logic remains intact. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Please provide an equivalent version of this Ada code in C. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Generate a C++ translation of this Ada snippet without changing its computational steps. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Convert this Ada block to C++, preserving its control flow and logic. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Can you help me rewrite this code in Go instead of Ada, keeping it the same logically? | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64
ψ float64
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const rEarth = 6372.8
func hsDist(p1, p2 pos) float... |
Can you help me rewrite this code in Go instead of Ada, keeping it the same logically? | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64
ψ float64
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const rEarth = 6372.8
func hsDist(p1, p2 pos) float... |
Produce a language-to-language conversion: from Ada to Java, same semantics. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | public class Haversine {
public static final double R = 6372.8;
public static double haversine(double lat1, double lon1, double lat2, double lon2) {
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double dLat = lat2 - lat1;
double dLon = Math.toRadians(lon2 - lon1);
... |
Can you help me rewrite this code in Java instead of Ada, keeping it the same logically? | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | public class Haversine {
public static final double R = 6372.8;
public static double haversine(double lat1, double lon1, double lat2, double lon2) {
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double dLat = lat2 - lat1;
double dLon = Math.toRadians(lon2 - lon1);
... |
Change the following Ada code into Python without altering its purpose. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | from math import radians, sin, cos, sqrt, asin
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2)**2
c = 2 * asin(sqrt(a))
... |
Write the same algorithm in Python as shown in this Ada implementation. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | from math import radians, sin, cos, sqrt, asin
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2)**2
c = 2 * asin(sqrt(a))
... |
Generate an equivalent VB version of this Ada code. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | Const MER = 6371
Public DEG_TO_RAD As Double
Function haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
lat1 = lat1 * DEG_TO_RAD
lat2 = lat2 * DEG_TO_RAD
long1 = long1 * DEG_TO_RAD
long2 = long2 * DEG_TO_RAD
haversine = MER * WorksheetFunction.Acos(Sin(... |
Convert this Ada block to VB, preserving its control flow and logic. | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Long_Float_Text_IO; use Ada.Long_Float_Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
procedure Haversine_Formula is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Long_Float); use Math;
function Great_Circle_Distance (lat1, long1, lat2,... | Const MER = 6371
Public DEG_TO_RAD As Double
Function haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
lat1 = lat1 * DEG_TO_RAD
lat2 = lat2 * DEG_TO_RAD
long1 = long1 * DEG_TO_RAD
long2 = long2 * DEG_TO_RAD
haversine = MER * WorksheetFunction.Acos(Sin(... |
Please provide an equivalent version of this Arturo code in C. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Port the following code from Arturo to C with equivalent syntax and logic. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Port the following code from Arturo to C# with equivalent syntax and logic. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Generate a C# translation of this Arturo snippet without changing its computational steps. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Port the provided Arturo code into C++ while preserving the original functionality. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Keep all operations the same but rewrite the snippet in C++. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Write the same code in Java as shown below in Arturo. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | public class Haversine {
public static final double R = 6372.8;
public static double haversine(double lat1, double lon1, double lat2, double lon2) {
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double dLat = lat2 - lat1;
double dLon = Math.toRadians(lon2 - lon1);
... |
Transform the following Arturo implementation into Java, maintaining the same output and logic. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | public class Haversine {
public static final double R = 6372.8;
public static double haversine(double lat1, double lon1, double lat2, double lon2) {
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double dLat = lat2 - lat1;
double dLon = Math.toRadians(lon2 - lon1);
... |
Produce a functionally identical Python code for the snippet given in Arturo. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | from math import radians, sin, cos, sqrt, asin
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2)**2
c = 2 * asin(sqrt(a))
... |
Keep all operations the same but rewrite the snippet in Python. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | from math import radians, sin, cos, sqrt, asin
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2)**2
c = 2 * asin(sqrt(a))
... |
Preserve the algorithm and functionality while converting the code from Arturo to VB. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | Const MER = 6371
Public DEG_TO_RAD As Double
Function haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
lat1 = lat1 * DEG_TO_RAD
lat2 = lat2 * DEG_TO_RAD
long1 = long1 * DEG_TO_RAD
long2 = long2 * DEG_TO_RAD
haversine = MER * WorksheetFunction.Acos(Sin(... |
Maintain the same structure and functionality when rewriting this code in VB. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | Const MER = 6371
Public DEG_TO_RAD As Double
Function haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
lat1 = lat1 * DEG_TO_RAD
lat2 = lat2 * DEG_TO_RAD
long1 = long1 * DEG_TO_RAD
long2 = long2 * DEG_TO_RAD
haversine = MER * WorksheetFunction.Acos(Sin(... |
Rewrite this program in Go while keeping its functionality equivalent to the Arturo version. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64
ψ float64
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const rEarth = 6372.8
func hsDist(p1, p2 pos) float... |
Convert the following code from Arturo to Go, ensuring the logic remains intact. | radians: function [x]-> x * pi // 180
haversine: function [src,tgt][
dLat: radians tgt\0 - src\0
dLon: radians tgt\1 - src\1
lat1: radians src\0
lat2: radians tgt\0
a: add product @[cos lat1, cos lat2, sin dLon/2, sin dLon/2] (sin dLat/2) ^ 2
c: 2 * asin sqrt a
return 6372.8 * c
]
print h... | package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64
ψ float64
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const rEarth = 6372.8
func hsDist(p1, p2 pos) float... |
Change the programming language of this snippet from AutoHotKey to C without modifying what it does. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Transform the following AutoHotKey implementation into C, maintaining the same output and logic. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Write a version of this AutoHotKey function in C# with identical behavior. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Convert this AutoHotKey snippet to C# and keep its semantics consistent. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Keep all operations the same but rewrite the snippet in C++. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Produce a language-to-language conversion: from AutoHotKey to C++, same semantics. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Translate the given AutoHotKey code snippet into Java without altering its behavior. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| public class Haversine {
public static final double R = 6372.8;
public static double haversine(double lat1, double lon1, double lat2, double lon2) {
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double dLat = lat2 - lat1;
double dLon = Math.toRadians(lon2 - lon1);
... |
Maintain the same structure and functionality when rewriting this code in Java. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| public class Haversine {
public static final double R = 6372.8;
public static double haversine(double lat1, double lon1, double lat2, double lon2) {
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
double dLat = lat2 - lat1;
double dLon = Math.toRadians(lon2 - lon1);
... |
Translate the given AutoHotKey code snippet into Python without altering its behavior. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| from math import radians, sin, cos, sqrt, asin
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2)**2
c = 2 * asin(sqrt(a))
... |
Ensure the translated Python code behaves exactly like the original AutoHotKey snippet. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| from math import radians, sin, cos, sqrt, asin
def haversine(lat1, lon1, lat2, lon2):
R = 6372.8
dLat = radians(lat2 - lat1)
dLon = radians(lon2 - lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = sin(dLat / 2)**2 + cos(lat1) * cos(lat2) * sin(dLon / 2)**2
c = 2 * asin(sqrt(a))
... |
Convert this AutoHotKey snippet to VB and keep its semantics consistent. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| Const MER = 6371
Public DEG_TO_RAD As Double
Function haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
lat1 = lat1 * DEG_TO_RAD
lat2 = lat2 * DEG_TO_RAD
long1 = long1 * DEG_TO_RAD
long2 = long2 * DEG_TO_RAD
haversine = MER * WorksheetFunction.Acos(Sin(... |
Transform the following AutoHotKey implementation into VB, maintaining the same output and logic. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| Const MER = 6371
Public DEG_TO_RAD As Double
Function haversine(lat1 As Double, long1 As Double, lat2 As Double, long2 As Double) As Double
lat1 = lat1 * DEG_TO_RAD
lat2 = lat2 * DEG_TO_RAD
long1 = long1 * DEG_TO_RAD
long2 = long2 * DEG_TO_RAD
haversine = MER * WorksheetFunction.Acos(Sin(... |
Ensure the translated Go code behaves exactly like the original AutoHotKey snippet. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64
ψ float64
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const rEarth = 6372.8
func hsDist(p1, p2 pos) float... |
Maintain the same structure and functionality when rewriting this code in Go. | MsgBox, % GreatCircleDist(36.12, 33.94, -86.67, -118.40, 6372.8, "km")
GreatCircleDist(La1, La2, Lo1, Lo2, R, U) {
return, 2 * R * ASin(Sqrt(Hs(Rad(La2 - La1)) + Cos(Rad(La1)) * Cos(Rad(La2)) * Hs(Rad(Lo2 - Lo1)))) A_Space U
}
Hs(n) {
return, (1 - Cos(n)) / 2
}
Rad(Deg) {
return, Deg * 4 * ATan(1) / 180
}
| package main
import (
"fmt"
"math"
)
func haversine(θ float64) float64 {
return .5 * (1 - math.Cos(θ))
}
type pos struct {
φ float64
ψ float64
}
func degPos(lat, lon float64) pos {
return pos{lat * math.Pi / 180, lon * math.Pi / 180}
}
const rEarth = 6372.8
func hsDist(p1, p2 pos) float... |
Convert this AWK block to C, preserving its control flow and logic. |
BEGIN {
distance(36.12,-86.67,33.94,-118.40)
exit(0)
}
function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) {
dlat = radians(lat2-lat1)
dlon = radians(lon2-lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2(sqr... | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Translate this program into C but keep the logic exactly as in AWK. |
BEGIN {
distance(36.12,-86.67,33.94,-118.40)
exit(0)
}
function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) {
dlat = radians(lat2-lat1)
dlon = radians(lon2-lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2(sqr... | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define R 6371
#define TO_RAD (3.1415926536 / 180)
double dist(double th1, double ph1, double th2, double ph2)
{
double dx, dy, dz;
ph1 -= ph2;
ph1 *= TO_RAD, th1 *= TO_RAD, th2 *= TO_RAD;
dz = sin(th1) - sin(th2);
dx = cos(ph1) * cos(th1) - cos(th2);
dy ... |
Generate a C# translation of this AWK snippet without changing its computational steps. |
BEGIN {
distance(36.12,-86.67,33.94,-118.40)
exit(0)
}
function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) {
dlat = radians(lat2-lat1)
dlon = radians(lon2-lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2(sqr... | public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Convert this AWK block to C#, preserving its control flow and logic. |
BEGIN {
distance(36.12,-86.67,33.94,-118.40)
exit(0)
}
function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) {
dlat = radians(lat2-lat1)
dlon = radians(lon2-lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2(sqr... | public static class Haversine {
public static double calculate(double lat1, double lon1, double lat2, double lon2) {
var R = 6372.8;
var dLat = toRadians(lat2 - lat1);
var dLon = toRadians(lon2 - lon1);
lat1 = toRadians(lat1);
lat2 = toRadians(lat2);
var a = Math.Sin(dLat / 2) * Math.Sin(... |
Produce a language-to-language conversion: from AWK to C++, same semantics. |
BEGIN {
distance(36.12,-86.67,33.94,-118.40)
exit(0)
}
function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) {
dlat = radians(lat2-lat1)
dlon = radians(lon2-lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2(sqr... | #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Generate a C++ translation of this AWK snippet without changing its computational steps. |
BEGIN {
distance(36.12,-86.67,33.94,-118.40)
exit(0)
}
function distance(lat1,lon1,lat2,lon2, a,c,dlat,dlon) {
dlat = radians(lat2-lat1)
dlon = radians(lon2-lon1)
lat1 = radians(lat1)
lat2 = radians(lat2)
a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
c = 2 * atan2(sqr... | #define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
const static double EarthRadiusKm = 6372.8;
inline double DegreeToRadian(double angle)
{
return M_PI * angle / 180.0;
}
class Coordinate
{
public:
Coordinate(double latitude ,double longitude):myLatitude(latitude), myLongitude(longitude)
{}
double... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.