Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Port the following code from Common_Lisp to PHP with equivalent syntax and logic.
(defun csvfile-to-nested-list (filename delim-char) "Reads the csv to a nested list, where each sublist represents a line." (with-open-file (input filename) (loop :for line := (read-line input nil) :while line :collect (read-from-string (substitute #\SPACE delim-char ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Ensure the translated PHP code behaves exactly like the original Common_Lisp snippet.
(defun csvfile-to-nested-list (filename delim-char) "Reads the csv to a nested list, where each sublist represents a line." (with-open-file (input filename) (loop :for line := (read-line input nil) :while line :collect (read-from-string (substitute #\SPACE delim-char ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Rewrite this program in PHP while keeping its functionality equivalent to the D version.
void main() { import std.stdio, std.csv, std.file, std.typecons, std.array, std.algorithm, std.conv, std.range; auto rows = "csv_data_in.csv".File.byLine; auto fout = "csv_data_out.csv".File("w"); fout.writeln(rows.front); fout.writef("%(%(%d,%)\n%)", rows.dropOne .map!(r...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert this D block to PHP, preserving its control flow and logic.
void main() { import std.stdio, std.csv, std.file, std.typecons, std.array, std.algorithm, std.conv, std.range; auto rows = "csv_data_in.csv".File.byLine; auto fout = "csv_data_out.csv".File("w"); fout.writeln(rows.front); fout.writef("%(%(%d,%)\n%)", rows.dropOne .map!(r...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert this Delphi block to PHP, preserving its control flow and logic.
program CSV_data_manipulation; uses System.SysUtils, System.IoUtils, System.Types; type TStringDynArrayHelper = record helper for TStringDynArray function Sum: Integer; end; function TStringDynArrayHelper.Sum: Integer; var value: string; begin Result := 0; for value in self do Result := R...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Produce a functionally identical PHP code for the snippet given in Delphi.
program CSV_data_manipulation; uses System.SysUtils, System.IoUtils, System.Types; type TStringDynArrayHelper = record helper for TStringDynArray function Sum: Integer; end; function TStringDynArrayHelper.Sum: Integer; var value: string; begin Result := 0; for value in self do Result := R...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Translate the given Elixir code snippet into PHP without altering its behavior.
defmodule Csv do defstruct header: "", data: "", separator: "," def from_file(path) do [header | data] = path |> File.stream! |> Enum.to_list |> Enum.map(&String.trim/1) %Csv{ header: header, data: data } end def sums_of_rows(csv) do Enum.map(csv.data, fn (row) -> sum_of_row(row, csv....
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Please provide an equivalent version of this Elixir code in PHP.
defmodule Csv do defstruct header: "", data: "", separator: "," def from_file(path) do [header | data] = path |> File.stream! |> Enum.to_list |> Enum.map(&String.trim/1) %Csv{ header: header, data: data } end def sums_of_rows(csv) do Enum.map(csv.data, fn (row) -> sum_of_row(row, csv....
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Ensure the translated PHP code behaves exactly like the original Erlang snippet.
-module( csv_data ). -export( [change/2, from_binary/1, from_file/1, into_file/2, task/0] ). change( CSV, Changes ) -> lists:foldl( fun change_foldl/2, CSV, Changes ). from_binary( Binary ) -> Lines = binary:split( Binary, <<"\n">>, [global] ), [binary:split(X, <<",">>, [global]) || X <- Lines]. fro...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Change the following Erlang code into PHP without altering its purpose.
-module( csv_data ). -export( [change/2, from_binary/1, from_file/1, into_file/2, task/0] ). change( CSV, Changes ) -> lists:foldl( fun change_foldl/2, CSV, Changes ). from_binary( Binary ) -> Lines = binary:split( Binary, <<"\n">>, [global] ), [binary:split(X, <<",">>, [global]) || X <- Lines]. fro...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Transform the following F# implementation into PHP, maintaining the same output and logic.
open System.IO [<EntryPoint>] let main _ = let input = File.ReadAllLines "test_in.csv" let output = input |> Array.mapi (fun i line -> if i = 0 then line + ",SUM" else let sum = Array.sumBy int (line.Split(',')) sprintf "%s,%i" line sum...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate an equivalent PHP version of this F# code.
open System.IO [<EntryPoint>] let main _ = let input = File.ReadAllLines "test_in.csv" let output = input |> Array.mapi (fun i line -> if i = 0 then line + ",SUM" else let sum = Array.sumBy int (line.Split(',')) sprintf "%s,%i" line sum...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert this Factor block to PHP, preserving its control flow and logic.
USING: csv io.encodings.utf8 kernel math.parser sequences ; IN: rosetta-code.csv-manipulation : append-sum ( seq -- seq' ) dup [ string>number ] map-sum number>string suffix ; : csv-sums ( seq -- seq' ) [ 0 = [ "SUM" suffix ] [ append-sum ] if ] map-index ; "example.csv" utf8 [ file>csv csv-sums ] [ csv>file...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Translate the given Factor code snippet into PHP without altering its behavior.
USING: csv io.encodings.utf8 kernel math.parser sequences ; IN: rosetta-code.csv-manipulation : append-sum ( seq -- seq' ) dup [ string>number ] map-sum number>string suffix ; : csv-sums ( seq -- seq' ) [ 0 = [ "SUM" suffix ] [ append-sum ] if ] map-index ; "example.csv" utf8 [ file>csv csv-sums ] [ csv>file...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Write the same algorithm in PHP as shown in this Forth implementation.
CHAR , CONSTANT SEPARATOR 3 CONSTANT DECIMALS 1E1 DECIMALS S>D D>F F** FCONSTANT FSCALE : colsum 0E0 OVER SWAP BOUNDS ?DO I C@ SEPARATOR = IF I TUCK OVER - >FLOAT IF F+ THEN ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Port the provided Forth code into PHP while preserving the original functionality.
CHAR , CONSTANT SEPARATOR 3 CONSTANT DECIMALS 1E1 DECIMALS S>D D>F F** FCONSTANT FSCALE : colsum 0E0 OVER SWAP BOUNDS ?DO I C@ SEPARATOR = IF I TUCK OVER - >FLOAT IF F+ THEN ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Change the following Fortran code into PHP without altering its purpose.
program rowsum implicit none character(:), allocatable :: line, name, a(:) character(20) :: fmt double precision, allocatable :: v(:) integer :: n, nrow, ncol, i call get_command_argument(1, length=n) allocate(character(n) :: name) call get_command_argument(1, name) open(unit=10...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate a PHP translation of this Fortran snippet without changing its computational steps.
program rowsum implicit none character(:), allocatable :: line, name, a(:) character(20) :: fmt double precision, allocatable :: v(:) integer :: n, nrow, ncol, i call get_command_argument(1, length=n) allocate(character(n) :: name) call get_command_argument(1, name) open(unit=10...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Rewrite the snippet below in PHP so it works the same as the original Groovy code.
def csv = [] def loadCsv = { source -> source.splitEachLine(/,/) { csv << it.collect { it } } } def saveCsv = { target -> target.withWriter { writer -> csv.each { writer.println it.join(',') } } } loadCsv new File('csv.txt') csv[0][0] = 'Column0' (1..4).each { i -> csv[i][i] = i * 100 } saveCsv new File('csv_out.txt')...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert this Groovy block to PHP, preserving its control flow and logic.
def csv = [] def loadCsv = { source -> source.splitEachLine(/,/) { csv << it.collect { it } } } def saveCsv = { target -> target.withWriter { writer -> csv.each { writer.println it.join(',') } } } loadCsv new File('csv.txt') csv[0][0] = 'Column0' (1..4).each { i -> csv[i][i] = i * 100 } saveCsv new File('csv_out.txt')...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Write the same code in PHP as shown below in Haskell.
import Data.Array (Array(..), (//), bounds, elems, listArray) import Data.List (intercalate) import Control.Monad (when) import Data.Maybe (isJust) delimiters :: String delimiters = ",;:" fields :: String -> [String] fields [] = [] fields xs = let (item, rest) = break (`elem` delimiters) xs (_, next) = break ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Port the provided Haskell code into PHP while preserving the original functionality.
import Data.Array (Array(..), (//), bounds, elems, listArray) import Data.List (intercalate) import Control.Monad (when) import Data.Maybe (isJust) delimiters :: String delimiters = ",;:" fields :: String -> [String] fields [] = [] fields xs = let (item, rest) = break (`elem` delimiters) xs (_, next) = break ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate an equivalent PHP version of this J code.
data=: (','&splitstring);.2 freads 'rc_csv.csv' data=: (<'"spam"') (<2 3)} data 'rc_outcsv.csv' fwrites~ ;<@(','&joinstring"1) data
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Maintain the same structure and functionality when rewriting this code in PHP.
data=: (','&splitstring);.2 freads 'rc_csv.csv' data=: (<'"spam"') (<2 3)} data 'rc_outcsv.csv' fwrites~ ;<@(','&joinstring"1) data
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Please provide an equivalent version of this Julia code in PHP.
using DataFrames, CSV ifn = "csv_data_manipulation_in.dat" ofn = "csv_data_manipulation_out.dat" df = CSV.read(ifn, DataFrame) df.SUM = sum.(eachrow(df)) CSV.write(ofn, df)
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert the following code from Julia to PHP, ensuring the logic remains intact.
using DataFrames, CSV ifn = "csv_data_manipulation_in.dat" ofn = "csv_data_manipulation_out.dat" df = CSV.read(ifn, DataFrame) df.SUM = sum.(eachrow(df)) CSV.write(ofn, df)
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Ensure the translated PHP code behaves exactly like the original Lua snippet.
local csv={} for line in io.lines('file.csv') do table.insert(csv, {}) local i=1 for j=1,#line do if line:sub(j,j) == ',' then table.insert(csv[#csv], line:sub(i,j-1)) i=j+1 end end table.insert(csv[#csv], line:sub(i,j)) end table.insert(csv[1], 'SUM') for i=...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert the following code from Lua to PHP, ensuring the logic remains intact.
local csv={} for line in io.lines('file.csv') do table.insert(csv, {}) local i=1 for j=1,#line do if line:sub(j,j) == ',' then table.insert(csv[#csv], line:sub(i,j-1)) i=j+1 end end table.insert(csv[#csv], line:sub(i,j)) end table.insert(csv[1], 'SUM') for i=...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Keep all operations the same but rewrite the snippet in PHP.
iCSV=Import["test.csv"] ->{{"C1","C2","C3","C4","C5"},{1,5,9,13,17},{2,6,10,14,18},{3,7,11,15,19},{4,8,12,16,20}} iCSV = Transpose@ Append[Transpose[iCSV], Join[{"Sum"}, Total /@ Drop[iCSV, 1]]]; iCSV // MatrixForm Export["test.csv",iCSV];
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Maintain the same structure and functionality when rewriting this code in PHP.
iCSV=Import["test.csv"] ->{{"C1","C2","C3","C4","C5"},{1,5,9,13,17},{2,6,10,14,18},{3,7,11,15,19},{4,8,12,16,20}} iCSV = Transpose@ Append[Transpose[iCSV], Join[{"Sum"}, Total /@ Drop[iCSV, 1]]]; iCSV // MatrixForm Export["test.csv",iCSV];
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Produce a functionally identical PHP code for the snippet given in MATLAB.
filename='data.csv'; fid = fopen(filename); header = fgetl(fid); fclose(fid); X = dlmread(filename,',',1,0); fid = fopen('data.out.csv','w+'); fprintf(fid,' for k=1:size(X,1), fprintf(fid," fprintf(fid," end; fclose(fid);
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Transform the following MATLAB implementation into PHP, maintaining the same output and logic.
filename='data.csv'; fid = fopen(filename); header = fgetl(fid); fclose(fid); X = dlmread(filename,',',1,0); fid = fopen('data.out.csv','w+'); fprintf(fid,' for k=1:size(X,1), fprintf(fid," fprintf(fid," end; fclose(fid);
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert the following code from Nim to PHP, ensuring the logic remains intact.
import strutils, streams let csv = newFileStream("data.csv", fmRead) outf = newFileStream("data-out.csv", fmWrite) var lineNumber = 1 while true: if atEnd(csv): break var line = readLine(csv) if lineNumber == 1: line.add(",SUM") else: var sum = 0 for n in split(line, ","): sum += p...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Change the following Nim code into PHP without altering its purpose.
import strutils, streams let csv = newFileStream("data.csv", fmRead) outf = newFileStream("data-out.csv", fmWrite) var lineNumber = 1 while true: if atEnd(csv): break var line = readLine(csv) if lineNumber == 1: line.add(",SUM") else: var sum = 0 for n in split(line, ","): sum += p...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Change the programming language of this snippet from OCaml to PHP without modifying what it does.
let list_add_last this lst = List.rev (this :: (List.rev lst)) let () = let csv = Csv.load "data.csv" in let fields, data = (List.hd csv, List.tl csv) in let fields = list_add_last "SUM" fields in let sums = List.map (fun row -> let tot = List.fold_left (fun tot this -> tot + int_o...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Rewrite this program in PHP while keeping its functionality equivalent to the OCaml version.
let list_add_last this lst = List.rev (this :: (List.rev lst)) let () = let csv = Csv.load "data.csv" in let fields, data = (List.hd csv, List.tl csv) in let fields = list_add_last "SUM" fields in let sums = List.map (fun row -> let tot = List.fold_left (fun tot this -> tot + int_o...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate an equivalent PHP version of this Pascal code.
program CSV_Data_Manipulation; uses Classes, SysUtils; var s: string; ts: tStringList; inFile, outFile: Text; Sum: integer; Number: string; begin Assign(inFile,'input.csv'); Reset(inFile); Assign(outFile,'result.csv'); Rewrite(outFile); ts:=tStringList.Create; ts.StrictDelimiter:=Tr...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Maintain the same structure and functionality when rewriting this code in PHP.
program CSV_Data_Manipulation; uses Classes, SysUtils; var s: string; ts: tStringList; inFile, outFile: Text; Sum: integer; Number: string; begin Assign(inFile,'input.csv'); Reset(inFile); Assign(outFile,'result.csv'); Rewrite(outFile); ts:=tStringList.Create; ts.StrictDelimiter:=Tr...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Write the same code in PHP as shown below in Perl.
use warnings; use strict; use List::Util 'sum'; my @header = split /,/, <>; chomp $header[-1]; my %column_number; for my $i (0 .. $ $column_number{$header[$i]} = $i; } my @rows = map [ split /,/ ], <>; chomp $_->[-1] for @rows; $_->[1]++ for @rows; $_->[ $column_number{C4} ] += $_->[ $column_number{C1} ]...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Rewrite this program in PHP while keeping its functionality equivalent to the Perl version.
use warnings; use strict; use List::Util 'sum'; my @header = split /,/, <>; chomp $header[-1]; my %column_number; for my $i (0 .. $ $column_number{$header[$i]} = $i; } my @rows = map [ split /,/ ], <>; chomp $_->[-1] for @rows; $_->[1]++ for @rows; $_->[ $column_number{C4} ] += $_->[ $column_number{C1} ]...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert the following code from PowerShell to PHP, ensuring the logic remains intact.
@" C1,C2,C3,C4,C5 1,5,9,13,17 2,6,10,14,18 3,7,11,15,19 4,8,12,16,20 "@ -split "`r`n" | Out-File -FilePath .\Temp.csv -Force $records = Import-Csv -Path .\Temp.csv $sums = $records | ForEach-Object { [int]$sum = 0 foreach ($field in $_.PSObject.Properties.Name) { $sum += $_.$field } $su...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Write the same algorithm in PHP as shown in this PowerShell implementation.
@" C1,C2,C3,C4,C5 1,5,9,13,17 2,6,10,14,18 3,7,11,15,19 4,8,12,16,20 "@ -split "`r`n" | Out-File -FilePath .\Temp.csv -Force $records = Import-Csv -Path .\Temp.csv $sums = $records | ForEach-Object { [int]$sum = 0 foreach ($field in $_.PSObject.Properties.Name) { $sum += $_.$field } $su...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Port the provided R code into PHP while preserving the original functionality.
write.csv(df, file = "foo.csv",row.names = FALSE)
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Change the following R code into PHP without altering its purpose.
write.csv(df, file = "foo.csv",row.names = FALSE)
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Write the same algorithm in PHP as shown in this Racket implementation.
#lang racket (require (planet neil/csv:1:=7) net/url) (define make-reader (make-csv-reader-maker '((separator-chars #\,) (strip-leading-whitespace? . #t) (strip-trailing-whitespace? . #t)))) (define (all-rows port) (define read-row (make-reader port)) (define head (append (read-row) '...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Write the same algorithm in PHP as shown in this Racket implementation.
#lang racket (require (planet neil/csv:1:=7) net/url) (define make-reader (make-csv-reader-maker '((separator-chars #\,) (strip-leading-whitespace? . #t) (strip-trailing-whitespace? . #t)))) (define (all-rows port) (define read-row (make-reader port)) (define head (append (read-row) '...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate an equivalent PHP version of this COBOL code.
IDENTIFICATION DIVISION. PROGRAM-ID. CSV. AUTHOR. Bill Gunshannon. INSTALLATION. Home. DATE-WRITTEN. 19 December 2021. ************************************************************ ** Program Abstract: ** CSVs are something COBOL does pretty well. ** Th...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Maintain the same structure and functionality when rewriting this code in PHP.
IDENTIFICATION DIVISION. PROGRAM-ID. CSV. AUTHOR. Bill Gunshannon. INSTALLATION. Home. DATE-WRITTEN. 19 December 2021. ************************************************************ ** Program Abstract: ** CSVs are something COBOL does pretty well. ** Th...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Preserve the algorithm and functionality while converting the code from REXX to PHP.
options replace format comments java crossref symbols import org.apache.commons.csv. -- ============================================================================= class RCsv public final properties private constant NL = String System.getProperty("line.separator") COL_NAME_SUM = String 'SUM, "intege...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Please provide an equivalent version of this REXX code in PHP.
options replace format comments java crossref symbols import org.apache.commons.csv. -- ============================================================================= class RCsv public final properties private constant NL = String System.getProperty("line.separator") COL_NAME_SUM = String 'SUM, "intege...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate a PHP translation of this Ruby snippet without changing its computational steps.
require 'csv' ar = CSV.table("test.csv").to_a ar.first << "SUM" ar[1..-1].each{|row| row << row.sum} CSV.open("out.csv", 'w') do |csv| ar.each{|line| csv << line} end
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Preserve the algorithm and functionality while converting the code from Ruby to PHP.
require 'csv' ar = CSV.table("test.csv").to_a ar.first << "SUM" ar[1..-1].each{|row| row << row.sum} CSV.open("out.csv", 'w') do |csv| ar.each{|line| csv << line} end
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Translate the given Scala code snippet into PHP without altering its behavior.
import java.io.File fun main(args: Array<String>) { val lines = File("example.csv").readLines().toMutableList() lines[0] += ",SUM" for (i in 1 until lines.size) { lines[i] += "," + lines[i].split(',').sumBy { it.toInt() } } val text = lines.joinToString("\n") File("example2.csv").writ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Convert the following code from Scala to PHP, ensuring the logic remains intact.
import java.io.File fun main(args: Array<String>) { val lines = File("example.csv").readLines().toMutableList() lines[0] += ",SUM" for (i in 1 until lines.size) { lines[i] += "," + lines[i].split(',').sumBy { it.toInt() } } val text = lines.joinToString("\n") File("example2.csv").writ...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Transform the following Tcl implementation into PHP, maintaining the same output and logic.
package require struct::matrix package require csv proc addSumColumn {filename {title "SUM"}} { set m [struct::matrix] set f [open $filename] csv::read2matrix $f $m "," auto close $f set sumcol [$m columns] $m add column $title for {set i 1} {$i < [$m rows]} {incr i} { $m set...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Generate an equivalent PHP version of this Tcl code.
package require struct::matrix package require csv proc addSumColumn {filename {title "SUM"}} { set m [struct::matrix] set f [open $filename] csv::read2matrix $f $m "," auto close $f set sumcol [$m columns] $m add column $title for {set i 1} {$i < [$m rows]} {incr i} { $m set...
<?php $handle = fopen('data_in.csv','r'); $handle_output = fopen('data_out.csv','w'); $row = 0; $arr = array(); while ($line = fgetcsv($handle)) { $arr[] = $line; } $arr[1][0] = 0; // 1,5,9,13,17 => 0,5,9,13,17 $arr[2][1] = 0; // 2,6,10,14,18 => 2,0,10,14,18 foreach ($arr as $line) { if ($row==0) ...
Port the provided C code into Rust while preserving the original functionality.
#define TITLE "CSV data manipulation" #define URL "http: #define _GNU_SOURCE #define bool int #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <errno.h> typedef struct { char * delim; unsigned int rows; unsigned int cols; char ** table; } CSV; int trim(char ** str) {...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Port the following code from C to Rust with equivalent syntax and logic.
#define TITLE "CSV data manipulation" #define URL "http: #define _GNU_SOURCE #define bool int #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include <errno.h> typedef struct { char * delim; unsigned int rows; unsigned int cols; char ** table; } CSV; int trim(char ** str) {...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Maintain the same structure and functionality when rewriting this code in Rust.
#include <map> #include <vector> #include <iostream> #include <fstream> #include <utility> #include <functional> #include <string> #include <sstream> #include <algorithm> #include <cctype> class CSV { public: CSV(void) : m_nCols( 0 ), m_nRows( 0 ) {} bool open( const char* filename, char delim = ',' ) ...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Preserve the algorithm and functionality while converting the code from C# to Rust.
using System.IO; using System.Linq; namespace CSV_data_manipulation { class Program { static void Main() { var input = File.ReadAllLines("test_in.csv"); var output = input.Select((line, i) => { if (i == 0) return line + ",S...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Please provide an equivalent version of this C# code in Rust.
using System.IO; using System.Linq; namespace CSV_data_manipulation { class Program { static void Main() { var input = File.ReadAllLines("test_in.csv"); var output = input.Select((line, i) => { if (i == 0) return line + ",S...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Rewrite this program in Rust while keeping its functionality equivalent to the Java version.
import java.io.*; import java.awt.Point; import java.util.HashMap; import java.util.Scanner; public class CSV { private HashMap<Point, String> _map = new HashMap<Point, String>(); private int _cols; private int _rows; public void open(File file) throws FileNotFoundException, IOException { ope...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Ensure the translated Rust code behaves exactly like the original Java snippet.
import java.io.*; import java.awt.Point; import java.util.HashMap; import java.util.Scanner; public class CSV { private HashMap<Point, String> _map = new HashMap<Point, String>(); private int _cols; private int _rows; public void open(File file) throws FileNotFoundException, IOException { ope...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Write a version of this Go function in Rust with identical behavior.
package main import ( "encoding/csv" "log" "os" "strconv" ) func main() { rows := readSample() appendSum(rows) writeChanges(rows) } func readSample() [][]string { f, err := os.Open("sample.csv") if err != nil { log.Fatal(err) } rows, err := csv.NewReader(f).ReadAll() f.Close() if err != nil { log.Fa...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Rewrite this program in Python while keeping its functionality equivalent to the Rust version.
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
import fileinput changerow, changecolumn, changevalue = 2, 4, '"Spam"' with fileinput.input('csv_data_manipulation.csv', inplace=True) as f: for line in f: if fileinput.filelineno() == changerow: fields = line.rstrip().split(',') fields[changecolumn-1] = changevalue lin...
Rewrite the snippet below in Python so it works the same as the original Rust code.
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
import fileinput changerow, changecolumn, changevalue = 2, 4, '"Spam"' with fileinput.input('csv_data_manipulation.csv', inplace=True) as f: for line in f: if fileinput.filelineno() == changerow: fields = line.rstrip().split(',') fields[changecolumn-1] = changevalue lin...
Change the following Rust code into VB without altering its purpose.
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Sub ReadCSV() Workbooks.Open Filename:="L:\a\input.csv" Range("F1").Value = "Sum" Range("F2:F5").Formula = "=SUM(A2:E2)" ActiveWorkbook.SaveAs Filename:="L:\a\output.csv", FileFormat:=xlCSV ActiveWindow.Close End Sub
Port the provided Rust code into VB while preserving the original functionality.
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Sub ReadCSV() Workbooks.Open Filename:="L:\a\input.csv" Range("F1").Value = "Sum" Range("F2:F5").Formula = "=SUM(A2:E2)" ActiveWorkbook.SaveAs Filename:="L:\a\output.csv", FileFormat:=xlCSV ActiveWindow.Close End Sub
Ensure the translated Rust code behaves exactly like the original C++ snippet.
#include <map> #include <vector> #include <iostream> #include <fstream> #include <utility> #include <functional> #include <string> #include <sstream> #include <algorithm> #include <cctype> class CSV { public: CSV(void) : m_nCols( 0 ), m_nRows( 0 ) {} bool open( const char* filename, char delim = ',' ) ...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Rewrite the snippet below in Rust so it works the same as the original Go code.
package main import ( "encoding/csv" "log" "os" "strconv" ) func main() { rows := readSample() appendSum(rows) writeChanges(rows) } func readSample() [][]string { f, err := os.Open("sample.csv") if err != nil { log.Fatal(err) } rows, err := csv.NewReader(f).ReadAll() f.Close() if err != nil { log.Fa...
use std::error::Error; use std::num::ParseIntError; use csv::{Reader, Writer}; fn main() -> Result<(), Box<dyn Error>> { let mut reader = Reader::from_path("data.csv")?; let mut writer = Writer::from_path("output.csv")?; let mut headers = reader.headers()?.clone(); headers.push_field("SUM"); ...
Transform the following Ada implementation into C#, maintaining the same output and logic.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
using System; namespace RosettaUrlParse { class Program { static void ParseUrl(string url) { var u = new Uri(url); Console.WriteLine("URL: {0}", u.AbsoluteUri); Console.WriteLine("Scheme: {0}", u.Scheme); Console.WriteLine("Host: ...
Change the following Ada code into C# without altering its purpose.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
using System; namespace RosettaUrlParse { class Program { static void ParseUrl(string url) { var u = new Uri(url); Console.WriteLine("URL: {0}", u.AbsoluteUri); Console.WriteLine("Scheme: {0}", u.Scheme); Console.WriteLine("Host: ...
Change the following Ada code into Go without altering its purpose.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
package main import ( "fmt" "log" "net" "net/url" ) func main() { for _, in := range []string{ "foo: "urn:example:animal:ferret:nose", "jdbc:mysql: "ftp: "http: "ldap: "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212", "telnet: "urn:oasis:names:s...
Change the following Ada code into Go without altering its purpose.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
package main import ( "fmt" "log" "net" "net/url" ) func main() { for _, in := range []string{ "foo: "urn:example:animal:ferret:nose", "jdbc:mysql: "ftp: "http: "ldap: "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212", "telnet: "urn:oasis:names:s...
Generate a Java translation of this Ada snippet without changing its computational steps.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
import java.net.URI; import java.net.URISyntaxException; public class WebAddressParser{ public static void main(String[] args){ parseAddress("foo: parseAddress("urn:example:animal:ferret:nose"); } static void parseAddress(String a){ System.out.println("Parsing " + a); try{ ...
Convert this Ada snippet to Java and keep its semantics consistent.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
import java.net.URI; import java.net.URISyntaxException; public class WebAddressParser{ public static void main(String[] args){ parseAddress("foo: parseAddress("urn:example:animal:ferret:nose"); } static void parseAddress(String a){ System.out.println("Parsing " + a); try{ ...
Convert the following code from Ada to Python, ensuring the logic remains intact.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
import urllib.parse as up url = up.urlparse('http://user:pass@example.com:8081/path/file.html;params?query1=1 print('url.scheme = ', url.scheme) print('url.netloc = ', url.netloc) print('url.hostname = ', url.hostname) print('url.port = ', url.port) print('url.path = ', url.path) print('url.params = ', url.params) p...
Generate an equivalent Python version of this Ada code.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
import urllib.parse as up url = up.urlparse('http://user:pass@example.com:8081/path/file.html;params?query1=1 print('url.scheme = ', url.scheme) print('url.netloc = ', url.netloc) print('url.hostname = ', url.hostname) print('url.port = ', url.port) print('url.path = ', url.path) print('url.params = ', url.params) p...
Change the programming language of this snippet from Ada to VB without modifying what it does.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
Function parse_url(url) parse_url = "URL: " & url If InStr(url,"//") Then scheme = Split(url,"//") parse_url = parse_url & vbcrlf & "Scheme: " & Mid(scheme(0),1,Len(scheme(0))-1) domain = Split(scheme(1),"/") If InStr(domain(0),"@") Then cred = Split(domain(0),"@") If InStr(cred(0),".") Then ...
Change the following Ada code into VB without altering its purpose.
with Ada.Text_IO; with AWS.URL; with AWS.Parameters; with AWS.Containers.Tables; procedure URL_Parser is procedure Parse (URL : in String) is use AWS.URL, Ada.Text_IO; use AWS.Containers.Tables; procedure Put_Cond (Item : in String; Value : in String; ...
Function parse_url(url) parse_url = "URL: " & url If InStr(url,"//") Then scheme = Split(url,"//") parse_url = parse_url & vbcrlf & "Scheme: " & Mid(scheme(0),1,Len(scheme(0))-1) domain = Split(scheme(1),"/") If InStr(domain(0),"@") Then cred = Split(domain(0),"@") If InStr(cred(0),".") Then ...
Generate an equivalent C# version of this Elixir code.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
using System; namespace RosettaUrlParse { class Program { static void ParseUrl(string url) { var u = new Uri(url); Console.WriteLine("URL: {0}", u.AbsoluteUri); Console.WriteLine("Scheme: {0}", u.Scheme); Console.WriteLine("Host: ...
Rewrite the snippet below in C# so it works the same as the original Elixir code.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
using System; namespace RosettaUrlParse { class Program { static void ParseUrl(string url) { var u = new Uri(url); Console.WriteLine("URL: {0}", u.AbsoluteUri); Console.WriteLine("Scheme: {0}", u.Scheme); Console.WriteLine("Host: ...
Change the programming language of this snippet from Elixir to Java without modifying what it does.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
import java.net.URI; import java.net.URISyntaxException; public class WebAddressParser{ public static void main(String[] args){ parseAddress("foo: parseAddress("urn:example:animal:ferret:nose"); } static void parseAddress(String a){ System.out.println("Parsing " + a); try{ ...
Preserve the algorithm and functionality while converting the code from Elixir to Java.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
import java.net.URI; import java.net.URISyntaxException; public class WebAddressParser{ public static void main(String[] args){ parseAddress("foo: parseAddress("urn:example:animal:ferret:nose"); } static void parseAddress(String a){ System.out.println("Parsing " + a); try{ ...
Maintain the same structure and functionality when rewriting this code in Python.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
import urllib.parse as up url = up.urlparse('http://user:pass@example.com:8081/path/file.html;params?query1=1 print('url.scheme = ', url.scheme) print('url.netloc = ', url.netloc) print('url.hostname = ', url.hostname) print('url.port = ', url.port) print('url.path = ', url.path) print('url.params = ', url.params) p...
Preserve the algorithm and functionality while converting the code from Elixir to Python.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
import urllib.parse as up url = up.urlparse('http://user:pass@example.com:8081/path/file.html;params?query1=1 print('url.scheme = ', url.scheme) print('url.netloc = ', url.netloc) print('url.hostname = ', url.hostname) print('url.port = ', url.port) print('url.path = ', url.path) print('url.params = ', url.params) p...
Convert this Elixir snippet to VB and keep its semantics consistent.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
Function parse_url(url) parse_url = "URL: " & url If InStr(url,"//") Then scheme = Split(url,"//") parse_url = parse_url & vbcrlf & "Scheme: " & Mid(scheme(0),1,Len(scheme(0))-1) domain = Split(scheme(1),"/") If InStr(domain(0),"@") Then cred = Split(domain(0),"@") If InStr(cred(0),".") Then ...
Translate this program into VB but keep the logic exactly as in Elixir.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
Function parse_url(url) parse_url = "URL: " & url If InStr(url,"//") Then scheme = Split(url,"//") parse_url = parse_url & vbcrlf & "Scheme: " & Mid(scheme(0),1,Len(scheme(0))-1) domain = Split(scheme(1),"/") If InStr(domain(0),"@") Then cred = Split(domain(0),"@") If InStr(cred(0),".") Then ...
Please provide an equivalent version of this Elixir code in Go.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
package main import ( "fmt" "log" "net" "net/url" ) func main() { for _, in := range []string{ "foo: "urn:example:animal:ferret:nose", "jdbc:mysql: "ftp: "http: "ldap: "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212", "telnet: "urn:oasis:names:s...
Write the same algorithm in Go as shown in this Elixir implementation.
test_cases = [ "foo://example.com:8042/over/there?name=ferret "urn:example:animal:ferret:nose", "jdbc:mysql://test_user:ouupppssss@localhost:3306/sakila?profileSQL=true", "ftp://ftp.is.co.za/rfc/rfc1808.txt", "http://www.ietf.org/rfc/rfc2396.txt "ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two", ...
package main import ( "fmt" "log" "net" "net/url" ) func main() { for _, in := range []string{ "foo: "urn:example:animal:ferret:nose", "jdbc:mysql: "ftp: "http: "ldap: "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212", "telnet: "urn:oasis:names:s...
Please provide an equivalent version of this F# code in C#.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
using System; namespace RosettaUrlParse { class Program { static void ParseUrl(string url) { var u = new Uri(url); Console.WriteLine("URL: {0}", u.AbsoluteUri); Console.WriteLine("Scheme: {0}", u.Scheme); Console.WriteLine("Host: ...
Transform the following F# implementation into C#, maintaining the same output and logic.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
using System; namespace RosettaUrlParse { class Program { static void ParseUrl(string url) { var u = new Uri(url); Console.WriteLine("URL: {0}", u.AbsoluteUri); Console.WriteLine("Scheme: {0}", u.Scheme); Console.WriteLine("Host: ...
Write the same algorithm in Java as shown in this F# implementation.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
import java.net.URI; import java.net.URISyntaxException; public class WebAddressParser{ public static void main(String[] args){ parseAddress("foo: parseAddress("urn:example:animal:ferret:nose"); } static void parseAddress(String a){ System.out.println("Parsing " + a); try{ ...
Produce a functionally identical Java code for the snippet given in F#.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
import java.net.URI; import java.net.URISyntaxException; public class WebAddressParser{ public static void main(String[] args){ parseAddress("foo: parseAddress("urn:example:animal:ferret:nose"); } static void parseAddress(String a){ System.out.println("Parsing " + a); try{ ...
Write the same code in Python as shown below in F#.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
import urllib.parse as up url = up.urlparse('http://user:pass@example.com:8081/path/file.html;params?query1=1 print('url.scheme = ', url.scheme) print('url.netloc = ', url.netloc) print('url.hostname = ', url.hostname) print('url.port = ', url.port) print('url.path = ', url.path) print('url.params = ', url.params) p...
Preserve the algorithm and functionality while converting the code from F# to Python.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
import urllib.parse as up url = up.urlparse('http://user:pass@example.com:8081/path/file.html;params?query1=1 print('url.scheme = ', url.scheme) print('url.netloc = ', url.netloc) print('url.hostname = ', url.hostname) print('url.port = ', url.port) print('url.path = ', url.path) print('url.params = ', url.params) p...
Keep all operations the same but rewrite the snippet in VB.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
Function parse_url(url) parse_url = "URL: " & url If InStr(url,"//") Then scheme = Split(url,"//") parse_url = parse_url & vbcrlf & "Scheme: " & Mid(scheme(0),1,Len(scheme(0))-1) domain = Split(scheme(1),"/") If InStr(domain(0),"@") Then cred = Split(domain(0),"@") If InStr(cred(0),".") Then ...
Convert this F# block to VB, preserving its control flow and logic.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
Function parse_url(url) parse_url = "URL: " & url If InStr(url,"//") Then scheme = Split(url,"//") parse_url = parse_url & vbcrlf & "Scheme: " & Mid(scheme(0),1,Len(scheme(0))-1) domain = Split(scheme(1),"/") If InStr(domain(0),"@") Then cred = Split(domain(0),"@") If InStr(cred(0),".") Then ...
Generate a Go translation of this F# snippet without changing its computational steps.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
package main import ( "fmt" "log" "net" "net/url" ) func main() { for _, in := range []string{ "foo: "urn:example:animal:ferret:nose", "jdbc:mysql: "ftp: "http: "ldap: "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212", "telnet: "urn:oasis:names:s...
Write a version of this F# function in Go with identical behavior.
open System open System.Text.RegularExpressions let writeline n v = if String.IsNullOrEmpty(v) then () else printfn "%-15s %s" n v let toUri = fun s -> Uri(s.ToString()) let urisFromString = (Regex(@"\S+").Matches) >> Seq.cast >> (Seq.map toUri) urisFromString """ foo: urn:example:animal:ferret:nose jdbc...
package main import ( "fmt" "log" "net" "net/url" ) func main() { for _, in := range []string{ "foo: "urn:example:animal:ferret:nose", "jdbc:mysql: "ftp: "http: "ldap: "mailto:John.Doe@example.com", "news:comp.infosystems.www.servers.unix", "tel:+1-816-555-1212", "telnet: "urn:oasis:names:s...