Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Translate the given Clojure code snippet into Java without altering its behavior.
(require '[clojure.string :only [join] :refer [join]]) (def day-row "Su Mo Tu We Th Fr Sa") (def col-width (count day-row)) (defn month-to-word "Translate a month from 0 to 11 into its word representation." [month] ((vec (.getMonths (new java.text.DateFormatSymbols))) month)) (defn month [date] (.get date ...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Convert this Clojure snippet to Python and keep its semantics consistent.
(require '[clojure.string :only [join] :refer [join]]) (def day-row "Su Mo Tu We Th Fr Sa") (def col-width (count day-row)) (defn month-to-word "Translate a month from 0 to 11 into its word representation." [month] ((vec (.getMonths (new java.text.DateFormatSymbols))) month)) (defn month [date] (.get date ...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Maintain the same structure and functionality when rewriting this code in VB.
(require '[clojure.string :only [join] :refer [join]]) (def day-row "Su Mo Tu We Th Fr Sa") (def col-width (count day-row)) (defn month-to-word "Translate a month from 0 to 11 into its word representation." [month] ((vec (.getMonths (new java.text.DateFormatSymbols))) month)) (defn month [date] (.get date ...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Can you help me rewrite this code in Go instead of Clojure, keeping it the same logically?
(require '[clojure.string :only [join] :refer [join]]) (def day-row "Su Mo Tu We Th Fr Sa") (def col-width (count day-row)) (defn month-to-word "Translate a month from 0 to 11 into its word representation." [month] ((vec (.getMonths (new java.text.DateFormatSymbols))) month)) (defn month [date] (.get date ...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Write the same code in C as shown below in Common_Lisp.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Port the following code from Common_Lisp to C# with equivalent syntax and logic.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Produce a functionally identical C++ code for the snippet given in Common_Lisp.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Translate the given Common_Lisp code snippet into Java without altering its behavior.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Translate this program into Python but keep the logic exactly as in Common_Lisp.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Convert this Common_Lisp snippet to VB and keep its semantics consistent.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Produce a functionally identical Go code for the snippet given in Common_Lisp.
(ql:quickload '(date-calc)) (defparameter *day-row* "Su Mo Tu We Th Fr Sa") (defparameter *calendar-margin* 3) (defun month-to-word (month) "Translate a MONTH from 1 to 12 into its word representation." (svref #("January" "February" "March" "April" "May" "June" "July" "August" "September" "O...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Maintain the same structure and functionality when rewriting this code in C.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Convert the following code from D to C#, ensuring the logic remains intact.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Transform the following D implementation into C++, maintaining the same output and logic.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Rewrite this program in Java while keeping its functionality equivalent to the D version.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Write the same code in Python as shown below in D.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Translate this program into VB but keep the logic exactly as in D.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Convert the following code from D to Go, ensuring the logic remains intact.
import std.stdio, std.datetime, std.string, std.conv; void printCalendar(in uint year, in uint nCols) in { assert(nCols > 0 && nCols <= 12); } body { immutable rows = 12 / nCols + (12 % nCols != 0); auto date = Date(year, 1, 1); int offs = date.dayOfWeek; const months = "January February March Apri...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Maintain the same structure and functionality when rewriting this code in C.
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Keep all operations the same but rewrite the snippet in C#.
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Keep all operations the same but rewrite the snippet in C++.
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Can you help me rewrite this code in Java instead of Delphi, keeping it the same logically?
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Port the following code from Delphi to Python with equivalent syntax and logic.
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Generate an equivalent VB version of this Delphi code.
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Keep all operations the same but rewrite the snippet in Go.
program Calendar; uses System.SysUtils, System.DateUtils; function Center(s: string; width: Integer): string; var side: Integer; begin if s.Length >= width then exit(s); side := (width - s.Length) div 2; Result := s + string.Create(' ', side); Result := string.Create(' ', width - Result.Length) + ...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Can you help me rewrite this code in C instead of F#, keeping it the same logically?
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Convert this F# snippet to C# and keep its semantics consistent.
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Change the programming language of this snippet from F# to C++ without modifying what it does.
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Translate this program into Java but keep the logic exactly as in F#.
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Write the same algorithm in Python as shown in this F# implementation.
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Rewrite this program in VB while keeping its functionality equivalent to the F# version.
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Write the same code in Go as shown below in F#.
let getCalendar year = let day_of_week month year = let t = [|0; 3; 2; 5; 0; 3; 5; 1; 4; 6; 2; 4|] let y = if month < 3 then year - 1 else year let m = month let d = 1 (y + y / 4 - y / 100 + y / 400 + t.[m - 1] + d) % 7 let last_day_of_month month year = ...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Port the provided Factor code into C while preserving the original functionality.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Translate this program into C# but keep the logic exactly as in Factor.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Translate the given Factor code snippet into C++ without altering its behavior.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Port the provided Factor code into Java while preserving the original functionality.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Change the programming language of this snippet from Factor to Python without modifying what it does.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Port the following code from Factor to VB with equivalent syntax and logic.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Write a version of this Factor function in Go with identical behavior.
USING: arrays calendar.format grouping io.streams.string kernel math.ranges prettyprint sequences sequences.interleaved ; IN: rosetta-code.calendar : calendar ( year -- ) 12 [1,b] [ 2array [ month. ] with-string-writer ] with map 3 <groups> [ " " <interleaved> ] map 5 " " <repetition> <interleaved> simpl...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Transform the following Haskell implementation into C, maintaining the same output and logic.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Convert this Haskell block to C#, preserving its control flow and logic.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Transform the following Haskell implementation into C++, maintaining the same output and logic.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Change the programming language of this snippet from Haskell to Java without modifying what it does.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Preserve the algorithm and functionality while converting the code from Haskell to Python.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Convert this Haskell snippet to VB and keep its semantics consistent.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Transform the following Haskell implementation into Go, maintaining the same output and logic.
import qualified Data.Text as T import Data.Time import Data.Time.Calendar import Data.Time.Calendar.WeekDate import Data.List.Split (chunksOf) import Data.List data Day = Su | Mo | Tu | We | Th | Fr | Sa deriving (Show, Eq, Ord, Enum) data Month = January | February | March | April | May ...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Translate this program into C but keep the logic exactly as in Icon.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Convert this Icon block to C#, preserving its control flow and logic.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Translate the given Icon code snippet into C++ without altering its behavior.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Convert this Icon snippet to Java and keep its semantics consistent.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Transform the following Icon implementation into Python, maintaining the same output and logic.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Generate a VB translation of this Icon snippet without changing its computational steps.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Keep all operations the same but rewrite the snippet in Go.
procedure main(A) printCalendar(\A[1]|1969) end procedure printCalendar(year) cols := 3 mons := [] "January February March April May June " || "July August September October November December " ? while p...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Write a version of this J function in C with identical behavior.
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Can you help me rewrite this code in C# instead of J, keeping it the same logically?
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Maintain the same structure and functionality when rewriting this code in C++.
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Write the same algorithm in Java as shown in this J implementation.
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Write the same algorithm in Python as shown in this J implementation.
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Ensure the translated VB code behaves exactly like the original J snippet.
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Change the following J code into Go without altering its purpose.
require 'dates format' require 'dates general/misc/format' calBody=: (1 1 }. _1 _1 }. ":)@(-@(<.@%&22)@[ ]\ calendar@]) calTitle=: (<: - 22&|)@[ center '[Insert Snoopy here]' , '' ,:~ ":@] formatCalendar=: calTitle , calBody
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Convert this Julia snippet to C and keep its semantics consistent.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Port the provided Julia code into C# while preserving the original functionality.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Preserve the algorithm and functionality while converting the code from Julia to C++.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Convert this Julia snippet to Java and keep its semantics consistent.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Change the programming language of this snippet from Julia to Python without modifying what it does.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Keep all operations the same but rewrite the snippet in VB.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Write a version of this Julia function in Go with identical behavior.
using Dates const pagesizes = Dict( "lpr" => [132, 66], "tn3270" => [80, 43]) pagefit(prn) = haskey(pagesizes, prn) ? [div(pagesizes[prn][1], 22), div(pagesizes[prn][2], 12)] : [1, 1] pagecols(prn) = haskey(pagesizes, prn) ? pagesizes[prn][1] : 20 function centerobject(x, cols) content = string(x) rpa...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Please provide an equivalent version of this Lua code in C.
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Maintain the same structure and functionality when rewriting this code in C#.
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Port the following code from Lua to C++ with equivalent syntax and logic.
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Transform the following Lua implementation into Java, maintaining the same output and logic.
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Convert the following code from Lua to Python, ensuring the logic remains intact.
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Translate the given Lua code snippet into VB without altering its behavior.
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Can you help me rewrite this code in Go instead of Lua, keeping it the same logically?
function print_cal(year) local months={"JANUARY","FEBRUARY","MARCH","APRIL","MAY","JUNE", "JULY","AUGUST","SEPTEMBER","OCTOBER","NOVEMBER","DECEMBER"} local daysTitle="MO TU WE TH FR SA SU" local daysPerMonth={31,28,31,30,31,30,31,31,30,31,30,31} local startday=((year-1)*365+math.floor((year-1)/...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Can you help me rewrite this code in C instead of Mathematica, keeping it the same logically?
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Can you help me rewrite this code in C# instead of Mathematica, keeping it the same logically?
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Write the same code in C++ as shown below in Mathematica.
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Produce a functionally identical Java code for the snippet given in Mathematica.
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Preserve the algorithm and functionality while converting the code from Mathematica to Python.
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Generate an equivalent VB version of this Mathematica code.
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Write the same algorithm in Go as shown in this Mathematica implementation.
DataGrid[ rowHeights:{__Integer}, colWidths:{__Integer}, spacings:{_Integer,_Integer}, borderWidths:{{_Integer,_Integer},{_Integer,_Integer}}, options_Association, data:{__List?MatrixQ}]:= With[ {alignment=Lookup[options,"alignment",{0,0}], background=Lookup[options,"background"," "], d...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Please provide an equivalent version of this Nim code in C.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Translate the given Nim code snippet into C# without altering its behavior.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Convert this Nim block to C++, preserving its control flow and logic.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Maintain the same structure and functionality when rewriting this code in Java.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Preserve the algorithm and functionality while converting the code from Nim to Python.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Generate a VB translation of this Nim snippet without changing its computational steps.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Preserve the algorithm and functionality while converting the code from Nim to Go.
import times import strformat proc printCalendar(year, nCols: int) = var rows = 12 div nCols var date = initDateTime(1, mJan, year, 0, 0, 0, utc()) if rows mod nCols != 0: inc rows var offs = getDayOfWeek(date.monthday, date.month, date.year).int var mons: array[12, array[8, string]] for m in 0..11: ...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Can you help me rewrite this code in C instead of OCaml, keeping it the same logically?
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Convert the following code from OCaml to C#, ensuring the logic remains intact.
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Convert this OCaml block to C++, preserving its control flow and logic.
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Preserve the algorithm and functionality while converting the code from OCaml to Java.
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Change the following OCaml code into Python without altering its purpose.
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...
Transform the following OCaml implementation into VB, maintaining the same output and logic.
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
docal 1969,6,"" function center (s,n) x=n-len(s):center=space(x\2+(x and 1))& s & space(x\2):end function sub print(x) wscript.stdout.writeline x : end sub function iif(a,b,c) :if a then iif=b else iif =c end if : end function sub docal (yr,nmonth,sloc) dim ld(6) dim d(6) if nmonth=5 or nmonth>6 or nmonth<1 th...
Preserve the algorithm and functionality while converting the code from OCaml to Go.
#load "unix.cma" let lang = "en" let usage () = Printf.printf "Usage:\n%s\n" Sys.argv.(0) let month_pattern = [ [ 0; 4; 8 ]; [ 1; 5; 9 ]; [ 2; 6; 10 ]; [ 3; 7; 11 ]; ] let month_langs = [ "en", [| "January"; "February"; "March"; "April"; "May"; "June"; "July"; "Augu...
package main import ( "fmt" "time" ) const pageWidth = 80 func main() { printCal(1969) } func printCal(year int) { thisDate := time.Date(year, 1, 1, 1, 1, 1, 1, time.UTC) var ( dayArr [12][7][6]int month, lastMonth time.Month weekInMonth, dayInMonth int ) for thisDate.Year() ==...
Generate a C translation of this Perl snippet without changing its computational steps.
use strict; use warnings; use Time::Local; my $year = shift // 1969; my $width = shift // 80; my $columns = int +($width + 2) / 22 or die "width too short at $width"; print map { center($_, $width), "\n" } '<reserved for snoopy>', $year; my @months = qw( January February March April May June July August September...
#include <stdio.h> #include <stdlib.h> #include <string.h> int width = 80, year = 1969; int cols, lead, gap; const char *wdays[] = { "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" }; struct months { const char *name; int days, start_wday, at; } months[12] = { { "January", 31, 0, 0 }, { "February", 28, 0, 0 }, { "March...
Convert this Perl snippet to C# and keep its semantics consistent.
use strict; use warnings; use Time::Local; my $year = shift // 1969; my $width = shift // 80; my $columns = int +($width + 2) / 22 or die "width too short at $width"; print map { center($_, $width), "\n" } '<reserved for snoopy>', $year; my @months = qw( January February March April May June July August September...
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace CalendarStuff { class Program { static void Main(string[] args) { Console.WindowHeight = 46; Console.Write(buildMonths(new DateTime(1969, 1, 1))); Console.Read(...
Write the same code in C++ as shown below in Perl.
use strict; use warnings; use Time::Local; my $year = shift // 1969; my $width = shift // 80; my $columns = int +($width + 2) / 22 or die "width too short at $width"; print map { center($_, $width), "\n" } '<reserved for snoopy>', $year; my @months = qw( January February March April May June July August September...
#include <windows.h> #include <iostream> using namespace std; class calender { public: void drawCalender( int y ) { year = y; for( int i = 0; i < 12; i++ ) firstdays[i] = getfirstday( i ); isleapyear(); build(); } private: void isleapyear() { isleap = false; if( !( year % 4 ) ) {...
Generate a Java translation of this Perl snippet without changing its computational steps.
use strict; use warnings; use Time::Local; my $year = shift // 1969; my $width = shift // 80; my $columns = int +($width + 2) / 22 or die "width too short at $width"; print map { center($_, $width), "\n" } '<reserved for snoopy>', $year; my @months = qw( January February March April May June July August September...
import java.text.*; import java.util.*; public class CalendarTask { public static void main(String[] args) { printCalendar(1969, 3); } static void printCalendar(int year, int nCols) { if (nCols < 1 || nCols > 12) throw new IllegalArgumentException("Illegal column width."); ...
Convert the following code from Perl to Python, ensuring the logic remains intact.
use strict; use warnings; use Time::Local; my $year = shift // 1969; my $width = shift // 80; my $columns = int +($width + 2) / 22 or die "width too short at $width"; print map { center($_, $width), "\n" } '<reserved for snoopy>', $year; my @months = qw( January February March April May June July August September...
>>> import calendar >>> help(calendar.prcal) Help on method pryear in module calendar: pryear(self, theyear, w=0, l=0, c=6, m=3) method of calendar.TextCalendar instance Print a years calendar. >>> calendar.prcal(1969) 1969 January February ...