Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Generate a VB translation of this Rust snippet without changing its computational steps. | fn cocktail_sort<T: PartialOrd>(a: &mut [T]) {
let len = a.len();
loop {
let mut swapped = false;
let mut i = 0;
while i + 1 < len {
if a[i] > a[i + 1] {
a.swap(i, i + 1);
swapped = true;
}
i += 1;
}
if s... | Function cocktail_sort(ByVal s As Variant) As Variant
Dim swapped As Boolean
Dim f As Integer, t As Integer, d As Integer, tmp As Integer
swapped = True
f = 1
t = UBound(s) - 1
d = 1
Do While swapped
swapped = 0
For i = f To t Step d
If Val(s(i)) > Val(s(i + 1)) T... |
Maintain the same structure and functionality when rewriting this code in Rust. | #include <iostream>
#include <windows.h>
const int EL_COUNT = 77, LLEN = 11;
class cocktailSort
{
public:
void sort( int* arr, int len )
{
bool notSorted = true;
while( notSorted )
{
notSorted = false;
for( int a = 0; a < len - 1; a++ )
{
if( arr[a] > arr[a + 1] )
{
sSwap( arr[a], ... | fn cocktail_sort<T: PartialOrd>(a: &mut [T]) {
let len = a.len();
loop {
let mut swapped = false;
let mut i = 0;
while i + 1 < len {
if a[i] > a[i + 1] {
a.swap(i, i + 1);
swapped = true;
}
i += 1;
}
if s... |
Change the following Rust code into Python without altering its purpose. | fn cocktail_sort<T: PartialOrd>(a: &mut [T]) {
let len = a.len();
loop {
let mut swapped = false;
let mut i = 0;
while i + 1 < len {
if a[i] > a[i + 1] {
a.swap(i, i + 1);
swapped = true;
}
i += 1;
}
if s... | def cocktailSort(A):
up = range(len(A)-1)
while True:
for indices in (up, reversed(up)):
swapped = False
for i in indices:
if A[i] > A[i+1]:
A[i], A[i+1] = A[i+1], A[i]
swapped = True
if not swapped:
... |
Port the following code from Ada to C# with equivalent syntax and logic. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Generate an equivalent C version of this Ada code. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Maintain the same structure and functionality when rewriting this code in C++. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Keep all operations the same but rewrite the snippet in Go. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Maintain the same structure and functionality when rewriting this code in Java. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Convert the following code from Ada to Python, ensuring the logic remains intact. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Generate an equivalent VB version of this Ada code. | generic
type Float_Type is digits <>;
Gravitation : Float_Type;
package Pendulums is
type Pendulum is private;
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum;
function Get_X (From : Pendulum) return Float_Type;
function Get_Y (From : Pendulum... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Change the following AutoHotKey code into C without altering its purpose. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Preserve the algorithm and functionality while converting the code from AutoHotKey to C#. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Transform the following AutoHotKey implementation into C++, maintaining the same output and logic. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Maintain the same structure and functionality when rewriting this code in Java. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Keep all operations the same but rewrite the snippet in Python. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Convert this AutoHotKey snippet to VB and keep its semantics consistent. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Preserve the algorithm and functionality while converting the code from AutoHotKey to Go. | SetBatchlines,-1
SizeGUI:={w:650,h:400}
pendulum:={length:300,maxangle:90,speed:2,size:30,center:{x:Sizegui.w//2,y:10}}
pendulum.maxangle:=pendulum.maxangle*0.01745329252
p_Token:=Gdip_Startup()
Gui,+LastFound
Gui,show,% "w" SizeGUI.w " h" SizeGUI.h
hwnd:=WinActive()
hdc:=GetDC(hwnd)
start:=A_TickCount/1000
G:=Gdi... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Transform the following BBC_Basic implementation into C, maintaining the same output and logic. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Generate a C# translation of this BBC_Basic snippet without changing its computational steps. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Port the following code from BBC_Basic to C++ with equivalent syntax and logic. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Rewrite the snippet below in Java so it works the same as the original BBC_Basic code. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Convert the following code from BBC_Basic to Python, ensuring the logic remains intact. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Change the programming language of this snippet from BBC_Basic to VB without modifying what it does. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Change the following BBC_Basic code into Go without altering its purpose. | MODE 8
*FLOAT 64
VDU 23,23,4;0;0;0; :
theta = RAD(40) :
g = 9.81 :
l = 0.50 :
REPEAT
PROCpendulum(theta, l)
WAIT 1
PROCpendulum(theta, l)
accel = - g * SIN(theta) / l / 100
speed += accel / 100
theta += speed
... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Please provide an equivalent version of this Clojure code in C. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Convert this Clojure block to C#, preserving its control flow and logic. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Port the following code from Clojure to C++ with equivalent syntax and logic. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Keep all operations the same but rewrite the snippet in Java. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Write the same code in Python as shown below in Clojure. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Generate a VB translation of this Clojure snippet without changing its computational steps. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Convert the following code from Clojure to Go, ensuring the logic remains intact. | (ns pendulum
(:import
(javax.swing JFrame)
(java.awt Canvas Graphics Color)))
(def length 200)
(def width (* 2 (+ 50 length)))
(def height (* 3 (/ length 2)))
(def dt 0.1)
(def g 9.812)
(def k (- (/ g length)))
(def anchor-x (/ width 2))
(def anchor-y (/ height 8))
(def angle (atom (/ (Math/PI) 2)))
(defn... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Can you help me rewrite this code in C instead of Common_Lisp, keeping it the same logically? | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Convert this Common_Lisp block to C#, preserving its control flow and logic. | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Generate an equivalent C++ version of this Common_Lisp code. | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Can you help me rewrite this code in Java instead of Common_Lisp, keeping it the same logically? | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Write a version of this Common_Lisp function in Python with identical behavior. | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Write a version of this Common_Lisp function in VB with identical behavior. | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Port the provided Common_Lisp code into Go while preserving the original functionality. | (defvar *frame-rate* 30)
(defvar *damping* 0.99 "Deceleration factor.")
(defun make-pendulum (length theta0 x)
"Returns an anonymous function with enclosed state representing a pendulum."
(let* ((theta (* (/ theta0 180) pi))
(acceleration 0))
(if (< length 40) (setf length 40))
(lambda ()
... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Port the following code from Delphi to C with equivalent syntax and logic. | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Can you help me rewrite this code in C# instead of Delphi, keeping it the same logically? | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Translate this program into C++ but keep the logic exactly as in Delphi. | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Generate a Java translation of this Delphi snippet without changing its computational steps. | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Translate the given Delphi code snippet into Python without altering its behavior. | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Write the same code in VB as shown below in Delphi. | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Change the following Delphi code into Go without altering its purpose. | unit main;
interface
uses
Vcl.Forms, Vcl.Graphics, Vcl.ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
Timer: TTimer;
angle, angleAccel, angleVelocity, dt: double;
len: Integer;
procedure Tick(Sender: TObject);
... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Convert this F# block to C, preserving its control flow and logic. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Transform the following F# implementation into C#, maintaining the same output and logic. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Please provide an equivalent version of this F# code in C++. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Generate an equivalent Java version of this F# code. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Convert this F# snippet to Python and keep its semantics consistent. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Port the provided F# code into VB while preserving the original functionality. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Write the same code in Go as shown below in F#. | open System
open System.Drawing
open System.Windows.Forms
[<Measure>] type m;
[<Measure>] type s;
type Pendulum =
{ length : float<m>
gravity : float<m/s^2>
velocity : float<m/s>
angle : float
}
let next pendulum deltaT : Pendulum =
let k = -pendulum.gravity / pendulum.length
let accelera... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Rewrite this program in C while keeping its functionality equivalent to the Factor version. | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Translate this program into C# but keep the logic exactly as in Factor. | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Port the provided Factor code into C++ while preserving the original functionality. | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Generate an equivalent Java version of this Factor code. | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Convert the following code from Factor to Python, ensuring the logic remains intact. | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Port the following code from Factor to VB with equivalent syntax and logic. | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Can you help me rewrite this code in Go instead of Factor, keeping it the same logically? | USING: accessors alarms arrays calendar colors.constants kernel
locals math math.constants math.functions math.rectangles
math.vectors opengl sequences system ui ui.gadgets ui.render ;
IN: pendulum
CONSTANT: g 9.81
CONSTANT: l 20
CONSTANT: theta0 0.5
: current-time ( -- time ) nano-count -9 10^ * ;
: T0 ( -- T0 ) 2 ... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Maintain the same structure and functionality when rewriting this code in C#. |
program animated_pendulum
implicit none
double precision, parameter :: pi = 4.0D0*atan(1.0D0), l = 1.0D-1, dt = 1.0D-2, g = 9.8D0
integer :: io
double precision :: s_ang, c_ang, p_ang, n_ang
write(*,*) 'Enter starting angle (in degrees):'
do
read(*,*,iostat=io) s_ang
if(io.ne.0 .or. s_ang.lt.-90.0D0 .or. s_ang.gt... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Write a version of this Fortran function in C++ with identical behavior. |
program animated_pendulum
implicit none
double precision, parameter :: pi = 4.0D0*atan(1.0D0), l = 1.0D-1, dt = 1.0D-2, g = 9.8D0
integer :: io
double precision :: s_ang, c_ang, p_ang, n_ang
write(*,*) 'Enter starting angle (in degrees):'
do
read(*,*,iostat=io) s_ang
if(io.ne.0 .or. s_ang.lt.-90.0D0 .or. s_ang.gt... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Convert this Fortran snippet to C and keep its semantics consistent. |
program animated_pendulum
implicit none
double precision, parameter :: pi = 4.0D0*atan(1.0D0), l = 1.0D-1, dt = 1.0D-2, g = 9.8D0
integer :: io
double precision :: s_ang, c_ang, p_ang, n_ang
write(*,*) 'Enter starting angle (in degrees):'
do
read(*,*,iostat=io) s_ang
if(io.ne.0 .or. s_ang.lt.-90.0D0 .or. s_ang.gt... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Produce a functionally identical Java code for the snippet given in Fortran. |
program animated_pendulum
implicit none
double precision, parameter :: pi = 4.0D0*atan(1.0D0), l = 1.0D-1, dt = 1.0D-2, g = 9.8D0
integer :: io
double precision :: s_ang, c_ang, p_ang, n_ang
write(*,*) 'Enter starting angle (in degrees):'
do
read(*,*,iostat=io) s_ang
if(io.ne.0 .or. s_ang.lt.-90.0D0 .or. s_ang.gt... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Write a version of this Fortran function in Python with identical behavior. |
program animated_pendulum
implicit none
double precision, parameter :: pi = 4.0D0*atan(1.0D0), l = 1.0D-1, dt = 1.0D-2, g = 9.8D0
integer :: io
double precision :: s_ang, c_ang, p_ang, n_ang
write(*,*) 'Enter starting angle (in degrees):'
do
read(*,*,iostat=io) s_ang
if(io.ne.0 .or. s_ang.lt.-90.0D0 .or. s_ang.gt... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Generate an equivalent VB version of this Fortran code. |
program animated_pendulum
implicit none
double precision, parameter :: pi = 4.0D0*atan(1.0D0), l = 1.0D-1, dt = 1.0D-2, g = 9.8D0
integer :: io
double precision :: s_ang, c_ang, p_ang, n_ang
write(*,*) 'Enter starting angle (in degrees):'
do
read(*,*,iostat=io) s_ang
if(io.ne.0 .or. s_ang.lt.-90.0D0 .or. s_ang.gt... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Write the same code in C as shown below in Groovy. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Change the programming language of this snippet from Groovy to C# without modifying what it does. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Change the programming language of this snippet from Groovy to C++ without modifying what it does. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Translate this program into Java but keep the logic exactly as in Groovy. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Change the programming language of this snippet from Groovy to Python without modifying what it does. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Keep all operations the same but rewrite the snippet in VB. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Translate this program into Go but keep the logic exactly as in Groovy. | import java.awt.*;
import javax.swing.*;
class Pendulum extends JPanel implements Runnable {
private angle = Math.PI / 2;
private length;
Pendulum(length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
void paint(Graphics g) {
g.setColor(Color.WHITE);
... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Change the programming language of this snippet from Haskell to C without modifying what it does. | import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Picture
import Graphics.HGL.Utils
import Graphics.HGL.Window
import Graphics.HGL.Run
import Control.Exception (bracket, )
import Control.Arrow
toInt = fromIntegral.round
pendulum = runGraphics $
bracket
(openWindowEx "Pendulum animation tas... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Port the provided Haskell code into C# while preserving the original functionality. | import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Picture
import Graphics.HGL.Utils
import Graphics.HGL.Window
import Graphics.HGL.Run
import Control.Exception (bracket, )
import Control.Arrow
toInt = fromIntegral.round
pendulum = runGraphics $
bracket
(openWindowEx "Pendulum animation tas... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Translate this program into Java but keep the logic exactly as in Haskell. | import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Picture
import Graphics.HGL.Utils
import Graphics.HGL.Window
import Graphics.HGL.Run
import Control.Exception (bracket, )
import Control.Arrow
toInt = fromIntegral.round
pendulum = runGraphics $
bracket
(openWindowEx "Pendulum animation tas... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Keep all operations the same but rewrite the snippet in Python. | import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Picture
import Graphics.HGL.Utils
import Graphics.HGL.Window
import Graphics.HGL.Run
import Control.Exception (bracket, )
import Control.Arrow
toInt = fromIntegral.round
pendulum = runGraphics $
bracket
(openWindowEx "Pendulum animation tas... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Translate this program into VB but keep the logic exactly as in Haskell. | import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Picture
import Graphics.HGL.Utils
import Graphics.HGL.Window
import Graphics.HGL.Run
import Control.Exception (bracket, )
import Control.Arrow
toInt = fromIntegral.round
pendulum = runGraphics $
bracket
(openWindowEx "Pendulum animation tas... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Rewrite the snippet below in Go so it works the same as the original Haskell code. | import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Picture
import Graphics.HGL.Utils
import Graphics.HGL.Window
import Graphics.HGL.Run
import Control.Exception (bracket, )
import Control.Arrow
toInt = fromIntegral.round
pendulum = runGraphics $
bracket
(openWindowEx "Pendulum animation tas... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Port the provided J code into C while preserving the original functionality. | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Produce a language-to-language conversion: from J to C#, same semantics. | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Convert this J snippet to C++ and keep its semantics consistent. | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Write the same algorithm in Java as shown in this J implementation. | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Convert this J snippet to Python and keep its semantics consistent. | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Can you help me rewrite this code in VB instead of J, keeping it the same logically? | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Change the programming language of this snippet from J to Go without modifying what it does. | require 'gl2 trig'
coinsert 'jgl2'
DT =: %30
ANGLE=: 0.45p1
L =: 1
G =: 9.80665
VEL =: 0
PEND=: noun define
pc pend;pn "Pendulum";
xywh 0 0 320 200;cc isi isigraph rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)
pend_run =: verb def ' wd PEND,'';pshow;timer '',":DT * 1... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Convert the following code from Julia to C, ensuring the logic remains intact. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Ensure the translated C# code behaves exactly like the original Julia snippet. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Write a version of this Julia function in C++ with identical behavior. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Write a version of this Julia function in Java with identical behavior. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Port the provided Julia code into Python while preserving the original functionality. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Transform the following Julia implementation into VB, maintaining the same output and logic. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Ensure the translated Go code behaves exactly like the original Julia snippet. | using Luxor
using Colors
using BoundaryValueDiffEq
const g = 9.81
const L = 1.0
const bobd = 0.10
const framerate = 50.0
const t0 = 0.0
const tf = 2.3
const dtframe = 1.0/framerate
const tspan = Lin... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Convert this Lua block to C, preserving its control flow and logic. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Write the same code in C# as shown below in Lua. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | using System;
using System.Drawing;
using System.Windows.Forms;
class CSharpPendulum
{
Form _form;
Timer _timer;
double _angle = Math.PI / 2,
_angleAccel,
_angleVelocity = 0,
_dt = 0.1;
int _length = 50;
[STAThread]
static void Main()
{
... |
Produce a functionally identical C++ code for the snippet given in Lua. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | #ifndef __wxPendulumDlg_h__
#define __wxPendulumDlg_h__
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include <wx/dialog.h>
#else
#include <wx/wxprec.h>
#endif
#include <wx/timer.h>
#include <wx/dcbuffer.h>
#include <cmath>
class wxPendulumDlgApp : public wxApp
{
public:
... |
Write a version of this Lua function in Java with identical behavior. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | import java.awt.*;
import javax.swing.*;
public class Pendulum extends JPanel implements Runnable {
private double angle = Math.PI / 2;
private int length;
public Pendulum(int length) {
this.length = length;
setDoubleBuffered(true);
}
@Override
public void paint(Graphics g) {... |
Produce a language-to-language conversion: from Lua to Python, same semantics. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | import pygame, sys
from pygame.locals import *
from math import sin, cos, radians
pygame.init()
WINDOWSIZE = 250
TIMETICK = 100
BOBSIZE = 15
window = pygame.display.set_mode((WINDOWSIZE, WINDOWSIZE))
pygame.display.set_caption("Pendulum")
screen = pygame.display.get_surface()
screen.fill((255,255,255))
PIVOT = (WI... |
Convert this Lua block to VB, preserving its control flow and logic. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | option explicit
const dt = 0.15
const length=23
dim ans0:ans0=chr(27)&"["
dim Veloc,Accel,angle,olr,olc,r,c
const r0=1
const c0=40
cls
angle=0.7
while 1
wscript.sleep(50)
Accel = -.9 * sin(Angle)
Veloc = Veloc + Accel * dt
Angle = Angle + Veloc * dt
r = r0 + int(cos(Angle) * Length)
... |
Translate this program into Go but keep the logic exactly as in Lua. | function degToRad( d )
return d * 0.01745329251
end
function love.load()
g = love.graphics
rodLen, gravity, velocity, acceleration = 260, 3, 0, 0
halfWid, damp = g.getWidth() / 2, .989
posX, posY, angle = halfWid
TWO_PI, angle = math.pi * 2, degToRad( 90 )
end
function love.update( dt )
ac... | package main
import (
"github.com/google/gxui"
"github.com/google/gxui/drivers/gl"
"github.com/google/gxui/math"
"github.com/google/gxui/themes/dark"
omath "math"
"time"
)
const (
ANIMATION_WIDTH int = 480
ANIMATION_HEIGHT int = 320
BALL_RADIUS float32 = 25.0
METER_PER_PIXEL float64 = 1.0... |
Translate this program into C but keep the logic exactly as in Mathematica. | freq = 8; length = freq^(-1/2);
Animate[Graphics[
List[{Line[{{0, 0}, length {Sin[T], -Cos[T]}} /. {T -> (Pi/6) Cos[2 Pi freq t]}], PointSize[Large],
Point[{length {Sin[T], -Cos[T]}} /. {T -> (Pi/6) Cos[2 Pi freq t]}]}],
PlotRange -> {{-0.3, 0.3}, {-0.5, 0}}], {t, 0, 1}, AnimationRate -> 0.07]
| #include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <sys/time.h>
#define length 5
#define g 9.8
double alpha, accl, omega = 0, E;
struct timeval tv;
double elappsed() {
struct timeval now;
gettimeofday(&now, 0);
int ret = (now.tv_sec - tv.tv_sec) * 1000000
+ now.tv_usec - tv.tv... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.