Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Translate the given Tcl code snippet into PHP without altering its behavior.
package require Tcl 8.5 proc binom {n k} { set pTop 1 for {set i $n} {$i > $n - $k} {incr i -1} { set pTop [expr {$pTop * $i}] } set pBottom 1 for {set i $k} {$i > 1} {incr i -1} { set pBottom [expr {$pBottom * $i}] } return [expr {$pTop / $pBottom}] }
<?php $n=5; $k=3; function factorial($val){ for($f=2;$val-1>1;$f*=$val--); return $f; } $binomial_coefficient=factorial($n)/(factorial($k)*factorial($n-$k)); echo $binomial_coefficient; ?>
Rewrite this program in Rust while keeping its functionality equivalent to the C version.
#include <stdio.h> #include <limits.h> static unsigned long gcd_ui(unsigned long x, unsigned long y) { unsigned long t; if (y < x) { t = x; x = y; y = t; } while (y > 0) { t = y; y = x % y; x = t; } return x; } unsigned long binomial(unsigned long n, unsigned long k) { unsigned long d, g, r = 1;...
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
Convert this C# snippet to Rust and keep its semantics consistent.
using System; namespace BinomialCoefficients { class Program { static void Main(string[] args) { ulong n = 1000000, k = 3; ulong result = biCoefficient(n, k); Console.WriteLine("The Binomial Coefficient of {0}, and {1}, is equal to: {2}", n, k, result); ...
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
Convert this Java snippet to Rust and keep its semantics consistent.
public class Binomial { private static long binomialInt(int n, int k) { if (k > n - k) k = n - k; long binom = 1; for (int i = 1; i <= k; i++) binom = binom * (n + 1 - i) / i; return binom; } private static Object binomialIntReliable(int n...
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
Ensure the translated Rust code behaves exactly like the original Go snippet.
package main import "fmt" import "math/big" func main() { fmt.Println(new(big.Int).Binomial(5, 3)) fmt.Println(new(big.Int).Binomial(60, 30)) }
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
Port the provided Rust code into Python while preserving the original functionality.
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
def binomialCoeff(n, k): result = 1 for i in range(1, k+1): result = result * (n-i+1) / i return result if __name__ == "__main__": print(binomialCoeff(5, 3))
Rewrite this program in Rust while keeping its functionality equivalent to the C++ version.
double Factorial(double nValue) { double result = nValue; double result_next; double pc = nValue; do { result_next = result*(pc-1); result = result_next; pc--; }while(pc>2); nValue = result; return nValue; } double binomialC...
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
Can you help me rewrite this code in VB instead of Rust, keeping it the same logically?
fn fact(n:u32) -> u64 { let mut f:u64 = n as u64; for i in 2..n { f *= i as u64; } return f; } fn choose(n: u32, k: u32) -> u64 { let mut num:u64 = n as u64; for i in 1..k { num *= (n-i) as u64; } return num / fact(k); } fn main() { println!("{}", choose(5,3)); }
Function binomial(n,k) binomial = factorial(n)/(factorial(n-k)*factorial(k)) End Function Function factorial(n) If n = 0 Then factorial = 1 Else For i = n To 1 Step -1 If i = n Then factorial = n Else factorial = factorial * i End If Next End If End Function WScript.StdOut.Write "the binom...
Rewrite the snippet below in C# so it works the same as the original Ada code.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Generate a C translation of this Ada snippet without changing its computational steps.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Change the programming language of this snippet from Ada to C++ without modifying what it does.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Maintain the same structure and functionality when rewriting this code in Go.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Write the same code in Java as shown below in Ada.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Translate this program into Python but keep the logic exactly as in Ada.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Transform the following Ada implementation into VB, maintaining the same output and logic.
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Strings.Bounded; procedure Main is package data_string is new Ada.Strings.Bounded.Generic_Bounded_Length(80); use data_string; type GCOSE_Rec is record Full_Name : Bounded_String; Office : Bounded...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Convert this AWK block to C, preserving its control flow and logic.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Ensure the translated C# code behaves exactly like the original AWK snippet.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Rewrite this program in C++ while keeping its functionality equivalent to the AWK version.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Convert this AWK block to Java, preserving its control flow and logic.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Change the following AWK code into Python without altering its purpose.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Rewrite the snippet below in VB so it works the same as the original AWK code.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Convert this AWK snippet to Go and keep its semantics consistent.
BEGIN { fn = "\\etc\\passwd" print("account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell") >fn print("jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash") >fn print("jdoe:x:1002:1000:Jane Doe,Room 1004,(234)555...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Convert the following code from Common_Lisp to C, ensuring the logic remains intact.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Transform the following Common_Lisp implementation into C#, maintaining the same output and logic.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Translate this program into C++ but keep the logic exactly as in Common_Lisp.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Convert this Common_Lisp block to Java, preserving its control flow and logic.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Keep all operations the same but rewrite the snippet in Python.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Port the following code from Common_Lisp to VB with equivalent syntax and logic.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Port the provided Common_Lisp code into Go while preserving the original functionality.
(defvar *initial_data* (list (list "jsmith" "x" 1001 1000 (list "Joe Smith" "Room 1007" "(234)555-8917" "(234)555-0077" "jsmith@rosettacode.org") "/home/jsmith" "/bin/bash") (list "jdoe" "x" 1002 1000 (list "Jane Doe" "Room 1004" "(234)555-8914" "(234)555-0044" "jdoe@rosettacode.org") ...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Produce a language-to-language conversion: from D to C, same semantics.
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Can you help me rewrite this code in C# instead of D, keeping it the same logically?
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Transform the following D implementation into C++, maintaining the same output and logic.
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Change the following D code into Java without altering its purpose.
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Change the programming language of this snippet from D to Python without modifying what it does.
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Convert this D snippet to VB and keep its semantics consistent.
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Port the following code from D to Go with equivalent syntax and logic.
class Record { private const string account; private const string password; private const int uid; private const int gid; private const string[] gecos; private const string directory; private const string shell; public this(string account, string password, int uid, int gid, string[] gec...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Rewrite the snippet below in C so it works the same as the original Delphi code.
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Produce a language-to-language conversion: from Delphi to C#, same semantics.
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Can you help me rewrite this code in C++ instead of Delphi, keeping it the same logically?
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Convert this Delphi snippet to Java and keep its semantics consistent.
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Convert this Delphi block to Python, preserving its control flow and logic.
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Generate a VB translation of this Delphi snippet without changing its computational steps.
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Generate an equivalent Go version of this Delphi code.
uses cTypes, unix; const passwdPath = '/tmp/passwd'; resourceString advisoryLockFailed = 'Error: could not obtain advisory lock'; type GECOS = object fullname: string; office: string; extension: string; homephone: string; email: string; function asString: string; end; entry = object...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Ensure the translated C code behaves exactly like the original Elixir snippet.
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Write the same code in C# as shown below in Elixir.
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Please provide an equivalent version of this Elixir code in C++.
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Maintain the same structure and functionality when rewriting this code in Java.
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Produce a functionally identical Python code for the snippet given in Elixir.
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Transform the following Elixir implementation into VB, maintaining the same output and logic.
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Can you help me rewrite this code in Go instead of Elixir, keeping it the same logically?
defmodule Gecos do defstruct [:fullname, :office, :extension, :homephone, :email] defimpl String.Chars do def to_string(gecos) do [:fullname, :office, :extension, :homephone, :email] |> Enum.map_join(",", &Map.get(gecos, &1)) end end end defmodule Passwd do defstruct [:account, :passwor...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Ensure the translated C# code behaves exactly like the original Fortran snippet.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Produce a language-to-language conversion: from Fortran to C++, same semantics.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Rewrite this program in C while keeping its functionality equivalent to the Fortran version.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Maintain the same structure and functionality when rewriting this code in Java.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Preserve the algorithm and functionality while converting the code from Fortran to Python.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Produce a language-to-language conversion: from Fortran to VB, same semantics.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Port the following code from Fortran to PHP with equivalent syntax and logic.
PROGRAM DEMO TYPE DETAILS CHARACTER*28 FULLNAME CHARACTER*12 OFFICE CHARACTER*16 EXTENSION CHARACTER*16 HOMEPHONE CHARACTER*88 EMAIL END TYPE DETAILS TYPE USERSTUFF CHARACTER*8 ACCOUNT CHARACTER*8 PASSWORD INTEGER*2 UID INTEGER...
<?php $filename = '/tmp/passwd'; $data = array( 'account:password:UID:GID:fullname,office,extension,homephone,email:directory:shell' . PHP_EOL, 'jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash' . PHP_EOL, 'jdoe:x:1002:1000:Jane Doe,Room 1004...
Convert this Groovy block to C, preserving its control flow and logic.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Produce a functionally identical C# code for the snippet given in Groovy.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Write the same code in C++ as shown below in Groovy.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Transform the following Groovy implementation into Java, maintaining the same output and logic.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Translate this program into Python but keep the logic exactly as in Groovy.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Rewrite this program in VB while keeping its functionality equivalent to the Groovy version.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Change the programming language of this snippet from Groovy to Go without modifying what it does.
class PasswdRecord { String account, password, directory, shell int uid, gid SourceRecord source private static final fs = ':' private static final fieldNames = ['account', 'password', 'uid', 'gid', 'source', 'directory', 'shell'] private static final stringFields = ['account', 'password', 'dir...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Produce a language-to-language conversion: from Haskell to C, same semantics.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Produce a functionally identical C# code for the snippet given in Haskell.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Convert the following code from Haskell to C++, ensuring the logic remains intact.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Port the provided Haskell code into Java while preserving the original functionality.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Change the programming language of this snippet from Haskell to Python without modifying what it does.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Translate the given Haskell code snippet into VB without altering its behavior.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Write a version of this Haskell function in Go with identical behavior.
import System.IO import Data.List (intercalate) data Gecos = Gecos { fullname :: String , office :: String , extension :: String , homephone :: String , email :: String } data Record = Record { account :: Stri...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Keep all operations the same but rewrite the snippet in C.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Convert this J block to C#, preserving its control flow and logic.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Write the same code in C++ as shown below in J.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Write the same code in Java as shown below in J.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Produce a language-to-language conversion: from J to Python, same semantics.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Write the same code in VB as shown below in J.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Please provide an equivalent version of this J code in Go.
require'strings ~system/packages/misc/xenos.ijs' record=: [:|: <@deb;._1@(':',]);._2@do bind '0 :0' passfields=: <;._1':username:password:gid:uid:gecos:home:shell' passrec=: LF,~ [: }.@;@ , ':';"0 (passfields i. {. ) { a:,~ {: R1=: passrec record'' username: jsmith password: x gid: 1001 uid: 1000 geco...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Convert the following code from Julia to C, ensuring the logic remains intact.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Port the following code from Julia to C# with equivalent syntax and logic.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Port the provided Julia code into C++ while preserving the original functionality.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Change the following Julia code into Java without altering its purpose.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Write the same code in Python as shown below in Julia.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Convert this Julia block to VB, preserving its control flow and logic.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Rewrite this program in Go while keeping its functionality equivalent to the Julia version.
using SHA mutable struct Personnel fullname::String office::String extension::String homephone::String email::String Personnel(ful,off,ext,hom,ema) = new(ful,off,ext,hom,ema) end mutable struct Passwd account::String password::String uid::Int32 gid::Int32 personal::P...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Port the following code from Lua to C with equivalent syntax and logic.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Write a version of this Lua function in C# with identical behavior.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Ensure the translated C++ code behaves exactly like the original Lua snippet.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Generate an equivalent Java version of this Lua code.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Please provide an equivalent version of this Lua code in Python.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Change the following Lua code into VB without altering its purpose.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Rewrite this program in Go while keeping its functionality equivalent to the Lua version.
function append(tbl,filename) local file,err = io.open(filename, "a") if err then return err end file:write(tbl.account..":") file:write(tbl.password..":") file:write(tbl.uid..":") file:write(tbl.gid..":") for i,v in ipairs(tbl.gecos) do if i>1 then file:write(",") ...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Maintain the same structure and functionality when rewriting this code in C.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
#include <stdio.h> #include <string.h> typedef const char *STRING; typedef struct{STRING fullname, office, extension, homephone, email; } gecos_t; typedef struct{STRING account, password; int uid, gid; gecos_t gecos; STRING directory, shell; } passwd_t; #define GECOS_FMT "%s,%s,%s,%s,%s" #define PASSWD_FMT "%s:%s:%d:...
Translate this program into C# but keep the logic exactly as in Mathematica.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...
Preserve the algorithm and functionality while converting the code from Mathematica to C++.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
#include <iostream> #include <fstream> #include <string> #include <vector> std::ostream& operator<<(std::ostream& out, const std::string s) { return out << s.c_str(); } struct gecos_t { std::string fullname, office, extension, homephone, email; friend std::ostream& operator<<(std::ostream&, const gecos_t...
Generate a Java translation of this Mathematica snippet without changing its computational steps.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
import static java.util.Objects.requireNonNull; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; impor...
Convert the following code from Mathematica to Python, ensuring the logic remains intact.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
passwd_list=[ dict(account='jsmith', password='x', UID=1001, GID=1000, GECOS=dict(fullname='Joe Smith', office='Room 1007', extension='(234)555-8917', homephone='(234)555-0077', email='jsmith@rosettacode.org'), directory='/home/jsmith', shell='/bin/bash'), dict(accoun...
Translate the given Mathematica code snippet into VB without altering its behavior.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
$Include "Rapidq.inc" dim file as qfilestream dim filename as string dim LogRec as string filename = "C:\Logfile2.txt" file.open(filename, fmCreate) file.writeline "jsmith:x:1001:1000:Joe Smith,Room 1007,(234)555-8917,(234)555-0077,jsmith@rosettacode.org:/home/jsmith:/bin/bash" file.writeline "jdoe:x:1002:1000:Jane...
Convert the following code from Mathematica to Go, ensuring the logic remains intact.
data = <|"account" -> "xyz", "password" -> "x", "UID" -> 1003, "GID" -> 1000, "fullname" -> "X Yz", "office" -> "Room 1003", "extension" -> "(234)555-8913", "homephone" -> "(234)555-0033", "email" -> "xyz@rosettacode.org", "directory" -> "/home/xyz", "shell" -> "/bin/bash"|>; asString[data_] := Strin...
package main import ( "bytes" "fmt" "io" "io/ioutil" "os" ) type pw struct { account, password string uid, gid uint gecos directory, shell string } type gecos struct { fullname, office, extension, homephone, email string } func (p *pw) encode(w io.Writer) (int, error...
Convert this MATLAB block to C#, preserving its control flow and logic.
DS{1}.account='jsmith'; DS{1}.password='x'; DS{1}.UID=1001; DS{1}.GID=1000; DS{1}.fullname='Joe Smith'; DS{1}.office='Room 1007'; DS{1}.extension='(234)555-8917'; DS{1}.homephone='(234)555-0077'; DS{1}.email='jsmith@rosettacode.org'; DS{1}.directory='/home/jsmith'; DS{1}.shell='/bin/bash'; DS{2...
using System; using System.IO; namespace AppendPwdRosetta { class PasswordRecord { public string account, password, fullname, office, extension, homephone, email, directory, shell; public int UID, GID; public PasswordRecord(string account, string password, int UID, int GID, string fulln...