Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Generate an equivalent REXX version of this Go code. | package main
import (
"fmt"
"math/big"
)
func harmonic(n int) *big.Rat {
sum := new(big.Rat)
for i := int64(1); i <= int64(n); i++ {
r := big.NewRat(1, i)
sum.Add(sum, r)
}
return sum
}
func main() {
fmt.Println("The first 20 harmonic numbers and the 100th, expressed in ra... |
parse arg digs sums high ints
if digs='' | digs="," then digs= 80
if sums='' | sums="," then sums= 20
if high='' | high="," then high= 10
if ints='' | ints="," then ints= 1 2 3 4 5 6 7 8 9 10
w= length(sums) + 2
numeric digi... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import "fmt"
func f(s1, s2, sep string) string {
return s1 + sep + sep + s2
}
func main() {
fmt.Println(f("Rosetta", "Code", ":"))
}
|
say f(a,b,c)
exit
f:return arg(1)arg(3)arg(3)arg(2)
|
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"bitbucket.org/binet/go-eval/pkg/eval"
"fmt"
"go/parser"
"go/token"
)
func main() {
squareExpr := "x*x"
fset := token.NewFileSet()
squareAst, err := parser.ParseExpr(squareExpr)
if err != nil {
fmt.Println(err)
return
}
w :=... | say evalWithX("x**2", 2)
say evalWithX("x**2", 3.1415926)
::routine evalWithX
use arg expression, x
-- X now has the value of the second argument
interpret "return" expression
|
Generate an equivalent REXX version of this Go code. | package main
import (
"bitbucket.org/binet/go-eval/pkg/eval"
"fmt"
"go/parser"
"go/token"
)
func main() {
squareExpr := "x*x"
fset := token.NewFileSet()
squareAst, err := parser.ParseExpr(squareExpr)
if err != nil {
fmt.Println(err)
return
}
w :=... | say evalWithX("x**2", 2)
say evalWithX("x**2", 3.1415926)
::routine evalWithX
use arg expression, x
-- X now has the value of the second argument
interpret "return" expression
|
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"bitbucket.org/binet/go-eval/pkg/eval"
"go/token"
)
func main() {
w := eval.NewWorld();
fset := token.NewFileSet();
code, err := w.Compile(fset, "1 + 2")
if err != nil {
fmt.Println("Compile error");
return
}
val, err := code.Run();
if err != nil {
fmt.Println("Run time er... | a = .array~of(1, 2, 3)
ins = "loop num over a; say num; end"
interpret ins
|
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import (
"fmt"
"bitbucket.org/binet/go-eval/pkg/eval"
"go/token"
)
func main() {
w := eval.NewWorld();
fset := token.NewFileSet();
code, err := w.Compile(fset, "1 + 2")
if err != nil {
fmt.Println("Compile error");
return
}
val, err := code.Run();
if err != nil {
fmt.Println("Run time er... | a = .array~of(1, 2, 3)
ins = "loop num over a; say num; end"
interpret ins
|
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"fmt"
"math/big"
)
func rank(l []uint) (r big.Int) {
for _, n := range l {
r.Lsh(&r, n+1)
r.SetBit(&r, int(n), 1)
}
return
}
func unrank(n big.Int) (l []uint) {
m := new(big.Int).Set(&n)
for a := m.BitLen(); a > 0; {
m.SetBit(m, a-1, 0)
... |
parse arg $
if $='' | $="," then $=3 14 159 265358979323846
$= translate( space($), ',', " ")
numeric digits max(9, 2 * length($) )
say 'original list=' $
N= rank($); s... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import (
"fmt"
"log"
"math/rand"
"time"
)
func generate(from, to int64) {
if to < from || from < 0 {
log.Fatal("Invalid range.")
}
span := to - from + 1
generated := make([]bool, span)
count := span
for count > 0 {
n := from + rand.Int63n(span) ... |
parse arg n cols seed .
if n=='' | n=="," then n= 20
if cols=='' | cols=="," then cols= 10
if datatype(seed, 'W') then call random ,,seed
w= 6
title= ' random integers (1 βββΊ ' n") with no repeats"
say ' index β'center(title, 1 + ... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"rcu"
"strconv"
"strings"
)
func findFirst(list []int) (int, int) {
for i, n := range list {
if n > 1e7 {
return n, i
}
}
return -1, -1
}
func reverse(s string) string {
chars := []rune(s)
for i, j := 0, len(chars)-1; i < j; ... |
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 10
call genP
w= max(10, length( commas(@.#) ) )
pri?= 0; bli?= 0; pal?= 0; call 0 ' first ' commas(n) ... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
"log"
)
var endings = [][]string{
{"o", "as", "at", "amus", "atis", "ant"},
{"eo", "es", "et", "emus", "etis", "ent"},
{"o", "is", "it", "imus", "itis", "unt"},
{"io", "is", "it", "imus", "itis", "iunt"},
}
var infinEndings = []string{"are", "Δre", "ere", "ire"}
v... |
parse arg verbs
if verbs='' | verbs="," then verbs= 'amare dare'
suffix= 'o as at amus atis ant'
#= words(verbs)
do j=1 for #; say
$= word(verbs, j); $$= $; upper $$
if \datatype($, 'M') then call ser "the follo... |
Generate an equivalent REXX version of this Go code. | package main
import (
"fmt"
"log"
)
var endings = [][]string{
{"o", "as", "at", "amus", "atis", "ant"},
{"eo", "es", "et", "emus", "etis", "ent"},
{"o", "is", "it", "imus", "itis", "unt"},
{"io", "is", "it", "imus", "itis", "iunt"},
}
var infinEndings = []string{"are", "Δre", "ere", "ire"}
v... |
parse arg verbs
if verbs='' | verbs="," then verbs= 'amare dare'
suffix= 'o as at amus atis ant'
#= words(verbs)
do j=1 for #; say
$= word(verbs, j); $$= $; upper $$
if \datatype($, 'M') then call ser "the follo... |
Generate an equivalent REXX version of this Go code. | package main
import (
"fmt"
"rcu"
"strings"
)
func main() {
limit := 100_000
primes := rcu.Primes(limit * 10)
var results []int
for _, p := range primes {
if p < 1000 || p > 99999 {
continue
}
ps := fmt.Sprintf("%s", p)
if strings.Contains(ps, "1... |
parse arg hi cols str .
if hi=='' | hi=="," then hi= 100000
if cols=='' | cols=="," then cols= 10
if str=='' | str=="," then str= 123
call genP
w= 10
title= ' primes N ... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"rcu"
"strings"
)
func main() {
limit := 100_000
primes := rcu.Primes(limit * 10)
var results []int
for _, p := range primes {
if p < 1000 || p > 99999 {
continue
}
ps := fmt.Sprintf("%s", p)
if strings.Contains(ps, "1... |
parse arg hi cols str .
if hi=='' | hi=="," then hi= 100000
if cols=='' | cols=="," then cols= 10
if str=='' | str=="," then str= 123
call genP
w= 10
title= ' primes N ... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import (
"fmt"
"rcu"
)
func main() {
c := rcu.PrimeSieve(5505, false)
var triples [][3]int
fmt.Println("Prime triplets: p, p + 2, p + 6 where p < 5,500:")
for i := 3; i < 5500; i += 2 {
if !c[i] && !c[i+2] && !c[i+6] {
triples = append(triples, [3]int{i, i + 2,... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 5500
if cols=='' | cols=="," then cols= 4
call genP hi + 6
do p=1 while @.p<hi
end
w= 30
__= ' '; @trip= ' prime tr... |
Keep all operations the same but rewrite the snippet in REXX. | package main
import (
"fmt"
"rcu"
)
func main() {
c := rcu.PrimeSieve(5505, false)
var triples [][3]int
fmt.Println("Prime triplets: p, p + 2, p + 6 where p < 5,500:")
for i := 3; i < 5500; i += 2 {
if !c[i] && !c[i+2] && !c[i+6] {
triples = append(triples, [3]int{i, i + 2,... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 5500
if cols=='' | cols=="," then cols= 4
call genP hi + 6
do p=1 while @.p<hi
end
w= 30
__= ' '; @trip= ' prime tr... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"rcu"
)
func main() {
primes := rcu.Primes(504)
var nprimes []int
fmt.Println("Neighbour primes < 500:")
for i := 0; i < len(primes)-1; i++ {
p := primes[i]*primes[i+1] + 2
if rcu.IsPrime(p) {
nprimes = append(nprimes, primes[i])
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 500
if cols=='' | cols=="," then cols= 10
call genP hi+50
do p=1 while @.p<hi
end
call genP @.p * @.q + 2
w= 10 ... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"fmt"
"rcu"
)
func main() {
primes := rcu.Primes(504)
var nprimes []int
fmt.Println("Neighbour primes < 500:")
for i := 0; i < len(primes)-1; i++ {
p := primes[i]*primes[i+1] + 2
if rcu.IsPrime(p) {
nprimes = append(nprimes, primes[i])
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 500
if cols=='' | cols=="," then cols= 10
call genP hi+50
do p=1 while @.p<hi
end
call genP @.p * @.q + 2
w= 10 ... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import (
"fmt"
"math"
"sort"
)
func isSquare(n int) bool {
s := int(math.Sqrt(float64(n)))
return s*s == n
}
func main() {
lists := [][]int{
{3, 4, 34, 25, 9, 12, 36, 56, 36},
{2, 8, 81, 169, 34, 55, 76, 49, 7},
{75, 121, 75, 144, 35, 16, 46, 35},
}
... | Parse Version v
Say v
l.1=.array~of(3,4,34,25,9,12,36,56,36)
l.2=.array~of(2,8,81,169,34,55,76,49,7)
l.3=.array~of(75,121,75,144,35,16,46,35)
st.0=0
Do li=1 To 3
Do e over l.li
If is_square(e) Then
Call store s
End
End
Call Show
Exit
is_square:
Parse Arg x
Do i=1 By 1 UNtil i**2>x
if i**2=x Then Re... |
Please provide an equivalent version of this Go code in REXX. | package main
import (
"fmt"
"math"
"sort"
)
func isSquare(n int) bool {
s := int(math.Sqrt(float64(n)))
return s*s == n
}
func main() {
lists := [][]int{
{3, 4, 34, 25, 9, 12, 36, 56, 36},
{2, 8, 81, 169, 34, 55, 76, 49, 7},
{75, 121, 75, 144, 35, 16, 46, 35},
}
... | Parse Version v
Say v
l.1=.array~of(3,4,34,25,9,12,36,56,36)
l.2=.array~of(2,8,81,169,34,55,76,49,7)
l.3=.array~of(75,121,75,144,35,16,46,35)
st.0=0
Do li=1 To 3
Do e over l.li
If is_square(e) Then
Call store s
End
End
Call Show
Exit
is_square:
Parse Arg x
Do i=1 By 1 UNtil i**2>x
if i**2=x Then Re... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import (
"fmt"
"regexp"
"strings"
)
var elements = `
hydrogen helium lithium beryllium
boron carbon nitrogen oxygen
fluorine neon sodium magnesium
aluminum silicon phosphorous sulfur
chlorine argon ... |
$= 'hydrogen helium lithium beryllium boron carbon' ,
'nitrogen oxygen fluorine neon sodium magnesium' ,
'aluminum silicon phosphorous sulfur chlorine argon' ,
'potassium calcium scandium titanium vanadium chromi... |
Translate the given Go code snippet into REXX without altering its behavior. | package main
import (
"fmt"
"sort"
)
func reverse(s string) string {
var r = []rune(s)
for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {
r[i], r[j] = r[j], r[i]
}
return string(r)
}
func longestPalSubstring(s string) []string {
var le = len(s)
if le <= 1 {
return []str... |
parse arg s
if s==''|s=="," then s='babaccd rotator reverse forever several palindrome abaracadaraba'
do i=1 for words(s); x= word(s, i)
L= length(x); m= 0
do LL=2 f... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"rcu"
"strconv"
"strings"
)
func reverse(s string) string {
chars := []rune(s)
for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
chars[i], chars[j] = chars[j], chars[i]
}
return string(chars)
}
func main() {
fmt.Println("Primes < 500 which a... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 500
if cols=='' | cols=="," then cols= 10
call genP
w= 8
title= ' palindromic primes in base 16 that are < ' hi
if cols>0 t... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
"rcu"
"strconv"
"strings"
)
func reverse(s string) string {
chars := []rune(s)
for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
chars[i], chars[j] = chars[j], chars[i]
}
return string(chars)
}
func main() {
fmt.Println("Primes < 500 which a... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 500
if cols=='' | cols=="," then cols= 10
call genP
w= 8
title= ' palindromic primes in base 16 that are < ' hi
if cols>0 t... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"bufio"
"fmt"
"io"
"os"
)
func Runer(r io.RuneReader) func() (rune, error) {
return func() (r rune, err error) {
r, _, err = r.ReadRune()
return
}
}
func main() {
runes := Runer(bufio.NewReader(os.Stdin))
for r, err := runes(); err != nil; r,err =... |
options replace format comments java crossref symbols nobinary
numeric digits 20
runSample(arg)
return
-- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
method readCharacters(fName) public static binary returns String
slurped = String('')
slrp = StringBuilder()
fr = Reader null
... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"math/rand"
"time"
)
const boxW = 41
const boxH = 37
const pinsBaseW = 19
const nMaxBalls = 55
const centerH = pinsBaseW + (boxW-pinsBaseW*2+1)/2 - 1
const (
empty = ' '
ball = 'o'
wall = '|'
corner = '+'
floor = '-'
pin = '.'
)
... |
trace off
if !all(arg()) then exit
signal on halt
parse arg rows balls freeze seed .
if rows =='' | rows=="," then rows= 0
if balls=='' | balls=="," then balls= 100
if freeze=='' | fre... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import (
"fmt"
"math"
)
func isSquare(n int) bool {
s := int(math.Sqrt(float64(n)))
return s*s == n
}
func main() {
var squares []int
outer:
for i := 1; i < 50; i++ {
if isSquare(i) {
squares = append(squares, i)
} else {
n := i
... |
numeric digits 20
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 10
w= 10
say ' index β'center(" smallest squares that begin with N < " n, ... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"math"
)
func isSquare(n int) bool {
s := int(math.Sqrt(float64(n)))
return s*s == n
}
func main() {
var squares []int
outer:
for i := 1; i < 50; i++ {
if isSquare(i) {
squares = append(squares, i)
} else {
n := i
... |
numeric digits 20
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 10
w= 10
say ' index β'center(" smallest squares that begin with N < " n, ... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import "fmt"
func circleSort(a []int, lo, hi, swaps int) int {
if lo == hi {
return swaps
}
high, low := hi, lo
mid := (hi - lo) / 2
for lo < hi {
if a[lo] > a[hi] {
a[lo], a[hi] = a[hi], a[lo]
swaps++
}
lo++
hi--
}
... |
parse arg x
if x='' | x="," then x= 6 7 8 9 2 5 3 4 1
call make_array 'before sort:'
call circleSort #
call make_list ' after sort:'
exit
circleSort: d... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"sort"
"strings"
)
func main() {
b, err := ioutil.ReadFile("unixdict.txt")
if err != nil {
log.Fatal("Error reading file")
}
letters := "deegklnow"
wordsAll := bytes.Split(b, []byte{'\n'})
var words [][]... |
parse arg grid minL iFID .
if grid==''|grid=="," then grid= 'ndeokgelw'
if minL==''|minL=="," then minL= 3
if iFID==''|iFID=="," then iFID= 'UNIXDICT.TXT'
oMinL= minL; minL= abs(minL)
gridU= grid; upper gridU
Lg= length(grid); ... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package expand
type Expander interface {
Expand() []string
}
type Text string
func (t Text) Expand() []string { return []string{string(t)} }
type Alternation []Expander
func (alt Alternation) Expand() []string {
var out []string
for _, e := range alt {
out = append(out, e.Expand()...)
}
return out
}
... |
* Brace expansion
* 26.07.2016
* s.* holds the set of strings
*--------------------------------------------------------------------*/
text.1='{,{,gotta have{ ,\, again\, }}more }cowbell!'
text.2='~/{Downloads,Pictures}
text.3='It{{em,alic}iz,erat}e{d,}, please. '
text.4='{}} some }{,{\\{ edge, edge} \,}{ cases, {here}... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"sort"
"strconv"
)
type wheel struct {
next int
values []string
}
type wheelMap = map[string]wheel
func generate(wheels wheelMap, start string, maxCount int) {
count := 0
w := wheels[start]
for {
s := w.values[w.next]
v, err := strconv.At... |
@.=
parse arg lim @.1
if lim='' | lim="," then lim= 20
if @.1='' | @.1="," then do; @.1= ' A: 1 2 3 '
@.2= ' A: 1 B 2, B: 3 4 '
@.3= ' A: 1 D D, D: 6... |
Please provide an equivalent version of this Go code in REXX. | package main
import (
"fmt"
"sort"
"strconv"
)
type wheel struct {
next int
values []string
}
type wheelMap = map[string]wheel
func generate(wheels wheelMap, start string, maxCount int) {
count := 0
w := wheels[start]
for {
s := w.values[w.next]
v, err := strconv.At... |
@.=
parse arg lim @.1
if lim='' | lim="," then lim= 20
if @.1='' | @.1="," then do; @.1= ' A: 1 2 3 '
@.2= ' A: 1 B 2, B: 3 4 '
@.3= ' A: 1 D D, D: 6... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import (
"fmt"
"github.com/go-vgo/robotgo"
)
func main() {
x, y := robotgo.GetMousePos()
color := robotgo.GetPixelColor(x, y)
fmt.Printf("Color of pixel at (%d, %d) is 0x%s\n", x, y, color)
}
|
parse value cursor() with r c .
hue=scrRead(r, c, 1, 'A')
if hue=='00'x then color= 'black'
if hue=='01'x then color= 'darkblue'
if hue=='02'x then color= 'darkgreen'
if hue=='03'x then color= 'darkturquoise'
if hue=='04'x then color= 'darkred' ... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"math"
)
var (
Two = "Two circles."
R0 = "R==0.0 does not describe circles."
Co = "Coincident points describe an infinite number of circles."
CoR0 = "Coincident points with r==0.0 describe a degenerate circle."
Diam = "Points form a diameter and describe on... |
a.=''
a.1=0.1234 0.9876 0.8765 0.2345 2
a.2=0.0000 2.0000 0.0000 0.0000 1
a.3=0.1234 0.9876 0.1234 0.9876 2
a.4=0.1234 0.9876 0.8765 0.2345 0.5
a.5=0.1234 0.9876 0.1234 0.9876 0
Say ' x1 y1 x2 y2 radius cir1x cir1y cir2x cir2y'
Say ' ------ ------ ------ ------ ------ ... |
Transform the following Go implementation into REXX, maintaining the same output and logic. | package main
import (
"fmt"
"math"
)
var (
Two = "Two circles."
R0 = "R==0.0 does not describe circles."
Co = "Coincident points describe an infinite number of circles."
CoR0 = "Coincident points with r==0.0 describe a degenerate circle."
Diam = "Points form a diameter and describe on... |
a.=''
a.1=0.1234 0.9876 0.8765 0.2345 2
a.2=0.0000 2.0000 0.0000 0.0000 1
a.3=0.1234 0.9876 0.1234 0.9876 2
a.4=0.1234 0.9876 0.8765 0.2345 0.5
a.5=0.1234 0.9876 0.1234 0.9876 0
Say ' x1 y1 x2 y2 radius cir1x cir1y cir2x cir2y'
Say ' ------ ------ ------ ------ ------ ... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"math"
)
func max(a, b uint64) uint64 {
if a > b {
return a
}
return b
}
func min(a, b uint64) uint64 {
if a < b {
return a
}
return b
}
func ndigits(x uint64) (n int) {
for ; x > 0; x /= 10 {
n++
}
return
}
fu... |
parse arg N .
if N=='' | N=="," then N= 25
!.0= 1260; !.1= 11453481; !.2= 115672; !.3= 124483; !.4= 105264
!.5= 1395; !.6= 126846; !.7= 1827; !.8= 110758; !.9= 156289
L= length(N); aN= abs(N)
numeric digits max(9,... |
Write a version of this Go function in REXX with identical behavior. | package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
var pack [52]byte
for i := 0; i < 26; i++ {
pack[i] = 'R'
pack[26+i] = 'B'
}
rand.Seed(time.Now().UnixNano())
rand.Shuffle(52, func(i, j int) {
pack[i], pack[j] = pack[j], pack[i]
})
... |
parse arg trials # shuffs seed .
if trials=='' | trials=="," then trials= 1000
if #=='' | #=="," then #= 52
if shuffs=='' | shuffs=="," then shuffs= #%4
if datatype(seed, 'W') then call random ,,seed
ok=0
... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"math/rand"
"time"
)
func main() {
var pack [52]byte
for i := 0; i < 26; i++ {
pack[i] = 'R'
pack[26+i] = 'B'
}
rand.Seed(time.Now().UnixNano())
rand.Shuffle(52, func(i, j int) {
pack[i], pack[j] = pack[j], pack[i]
})
... |
parse arg trials # shuffs seed .
if trials=='' | trials=="," then trials= 1000
if #=='' | #=="," then #= 52
if shuffs=='' | shuffs=="," then shuffs= #%4
if datatype(seed, 'W') then call random ,,seed
ok=0
... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import "fmt"
var n = make([][]string, 15)
func initN() {
for i := 0; i < 15; i++ {
n[i] = make([]string, 11)
for j := 0; j < 11; j++ {
n[i][j] = " "
}
n[i][5] = "x"
}
}
func horiz(c1, c2, r int) {
for c := c1; c <= c2; c++ {
n[r][c] = "x"
... |
parse arg m
if m='' | m="," then m= 0 1 20 300 4000 5555 6789 9393
$.=; nnn= words(m)
do j=1 for nnn; z= word(m, j)
if \datatype(z, 'W') then call serr "number isn't numeric: " z
if \datatype(... |
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import "fmt"
var n = make([][]string, 15)
func initN() {
for i := 0; i < 15; i++ {
n[i] = make([]string, 11)
for j := 0; j < 11; j++ {
n[i][j] = " "
}
n[i][5] = "x"
}
}
func horiz(c1, c2, r int) {
for c := c1; c <= c2; c++ {
n[r][c] = "x"
... |
parse arg m
if m='' | m="," then m= 0 1 20 300 4000 5555 6789 9393
$.=; nnn= words(m)
do j=1 for nnn; z= word(m, j)
if \datatype(z, 'W') then call serr "number isn't numeric: " z
if \datatype(... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import (
"fmt"
"sort"
"strings"
)
type card struct {
face byte
suit byte
}
const faces = "23456789tjqka"
const suits = "shdc"
func isStraight(cards []card) bool {
sorted := make([]card, 5)
copy(sorted, cards)
sort.Slice(sorted, func(i, j int) bool {
return sorted... |
* 10.12.2013 Walter Pachl
*--------------------------------------------------------------------*/
d.1='2h 2d 2s ks qd'; x.1='three-of-a-kind'
d.2='2h 5h 7d 8s 9d'; x.2='high-card'
d.3='ah 2d 3s 4s 5s'; x.3='straight'
d.4='2h 3h 2d 3s 3d'; x.4='full-house'
d.5='2h 7h 2d 3s 3d'; x.5='two-pair'
d.6='2h 7h 7d 7s 7c'; x.6... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"sort"
"strings"
)
type card struct {
face byte
suit byte
}
const faces = "23456789tjqka"
const suits = "shdc"
func isStraight(cards []card) bool {
sorted := make([]card, 5)
copy(sorted, cards)
sort.Slice(sorted, func(i, j int) bool {
return sorted... |
* 10.12.2013 Walter Pachl
*--------------------------------------------------------------------*/
d.1='2h 2d 2s ks qd'; x.1='three-of-a-kind'
d.2='2h 5h 7d 8s 9d'; x.2='high-card'
d.3='ah 2d 3s 4s 5s'; x.3='straight'
d.4='2h 3h 2d 3s 3d'; x.4='full-house'
d.5='2h 7h 2d 3s 3d'; x.5='two-pair'
d.6='2h 7h 7d 7s 7c'; x.6... |
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import (
"github.com/fogleman/gg"
"strings"
)
func wordFractal(i int) string {
if i < 2 {
if i == 1 {
return "1"
}
return ""
}
var f1 strings.Builder
f1.WriteString("1")
var f2 strings.Builder
f2.WriteString("0")
for j := i - 2; j >=... |
parse arg order .
if order=='' | order=="," then order= 23
tell= order>=0
s= FibWord( abs(order) )
x= 0; maxX= 0; dx= 0; b= ' '; @. = b; xp= 0
y=... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import "fmt"
import "math/rand"
func main(){
var a1,a2,a3,y,match,j,k int
var inp string
y=1
for y==1{
fmt.Println("Enter your sequence:")
fmt.Scanln(&inp)
var Ai [3] int
var user [3] int
for j=0;j<3;j++{
if(inp[j]==104){
user[j]=1
}else{
user[j]=0
}
}
for k=0;k<3;k++{
Ai[k]=rand.Intn(2)
}
for user[0]==Ai[... |
__= copies('β', 9)
signal on halt
parse arg # seed .
if #=='' | #=="," then #= 3
if datatype(seed,'W') then call random ,,seed
wins=0; do games=1
call gam... |
Translate the given Go code snippet into REXX without altering its behavior. | package main
import (
"fmt"
"strings"
)
func printBlock(data string, le int) {
a := []byte(data)
sumBytes := 0
for _, b := range a {
sumBytes += int(b - 48)
}
fmt.Printf("\nblocks %c, cells %d\n", a, le)
if le-sumBytes <= 0 {
fmt.Println("No solution")
return
... |
$.=; $.1= 5 2 1
$.2= 5
$.3= 10 8
$.4= 15 2 3 2 3
$.5= 5 2 3
do i=1 while $.i\==''
parse var $.i N blocks
N= strip(N); blocks= space(blocks)
call nono ... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"strings"
)
func printBlock(data string, le int) {
a := []byte(data)
sumBytes := 0
for _, b := range a {
sumBytes += int(b - 48)
}
fmt.Printf("\nblocks %c, cells %d\n", a, le)
if le-sumBytes <= 0 {
fmt.Println("No solution")
return
... |
$.=; $.1= 5 2 1
$.2= 5
$.3= 10 8
$.4= 15 2 3 2 3
$.5= 5 2 3
do i=1 while $.i\==''
parse var $.i N blocks
N= strip(N); blocks= space(blocks)
call nono ... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import "fmt"
type Range struct {
start, end uint64
print bool
}
func main() {
rgs := []Range{
{2, 1000, true},
{1000, 4000, true},
{2, 1e4, false},
{2, 1e5, false},
{2, 1e6, false},
{2, 1e7, false},
{2, 1e8, false},
{2, 1e9... |
numeric digits 20
parse arg $
if $='' then $= '1 1000 1000 4000 1 -10000 1 -100000 1 -1000000 1 -10000000'
do k=1 by 2 to words($)
call banE word($, k), word($, k+1)
end
exit ... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import "fmt"
type Range struct {
start, end uint64
print bool
}
func main() {
rgs := []Range{
{2, 1000, true},
{1000, 4000, true},
{2, 1e4, false},
{2, 1e5, false},
{2, 1e6, false},
{2, 1e7, false},
{2, 1e8, false},
{2, 1e9... |
numeric digits 20
parse arg $
if $='' then $= '1 1000 1000 4000 1 -10000 1 -100000 1 -1000000 1 -10000000'
do k=1 by 2 to words($)
call banE word($, k), word($, k+1)
end
exit ... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"fmt"
"strconv"
)
const (
ul = "β"
uc = "β¦"
ur = "β"
ll = "β"
lc = "β©"
lr = "β"
hb = "β"
vb = "β"
)
var mayan = [5]string{
" ",
" β ",
" ββ ",
"βββ ",
"ββββ",
}
const (
m0 = " Ξ "
m5 = "ββββ"
)
func dec2vig(n uint64) []u... |
parse arg $
if $='' then $= 4005 8017 326205 886205,
172037122592320200101
do j=1 for words($)
#= word($, j)
say
say center('converting the decimal number ' # " to ... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import "fmt"
func main() {
coconuts := 11
outer:
for ns := 2; ns < 10; ns++ {
hidden := make([]int, ns)
coconuts = (coconuts/ns)*ns + 1
for {
nc := coconuts
for s := 1; s <= ns; s++ {
if nc%ns == 1 {
hidden[s-1] =... |
parse arg L H .; if L=='' then L= 5
if H=='' then H= 6
do n=L to H
do $=0 while \valid(n, $)
end
say 'sailors='n " coco... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import "fmt"
func main() {
coconuts := 11
outer:
for ns := 2; ns < 10; ns++ {
hidden := make([]int, ns)
coconuts = (coconuts/ns)*ns + 1
for {
nc := coconuts
for s := 1; s <= ns; s++ {
if nc%ns == 1 {
hidden[s-1] =... |
parse arg L H .; if L=='' then L= 5
if H=='' then H= 6
do n=L to H
do $=0 while \valid(n, $)
end
say 'sailors='n " coco... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"fmt"
"strings"
"time"
)
func main() {
watches := []string{
"First", "Middle", "Morning", "Forenoon",
"Afternoon", "Dog", "First",
}
for {
t := time.Now()
h := t.Hour()
m := t.Minute()
s := t.Second()
if (m == 0 || m... |
Parse Arg msg
If msg='?' Then Do
Say 'Ring a nautical bell'
Exit
End
Signal on Halt
Do Forever
Parse Value time() With hh ':' mn ':' ss
ct=time('C')
hhmmc=left(right(ct,7,0),5)
If msg>'' Then
Say center(arg(1) ct time(),79)
If ss==00 & ( mn==00... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"fmt"
"strings"
"time"
)
func main() {
watches := []string{
"First", "Middle", "Morning", "Forenoon",
"Afternoon", "Dog", "First",
}
for {
t := time.Now()
h := t.Hour()
m := t.Minute()
s := t.Second()
if (m == 0 || m... |
Parse Arg msg
If msg='?' Then Do
Say 'Ring a nautical bell'
Exit
End
Signal on Halt
Do Forever
Parse Value time() With hh ':' mn ':' ss
ct=time('C')
hhmmc=left(right(ct,7,0),5)
If msg>'' Then
Say center(arg(1) ct time(),79)
If ss==00 & ( mn==00... |
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import (
"encoding/binary"
"log"
"math"
"os"
"strings"
)
func main() {
const (
sampleRate = 44100
duration = 8
dataLength = sampleRate * duration
hdrSize = 44
fileLen = dataLength + hdrSize - 8
)
buf1 := make([]byte, 1)... |
* 24.02.2013 Walter Pachl derived from original REXX version
* Changes: sound(f,sec) --> beep(trunc(f),millisec)
* $ -> sc
* @. -> f.
* re > ra (in sc)
*--------------------------------------------------------------------*/
sc='do ra mi fa so la te do'
dur=1250
... |
Please provide an equivalent version of this Go code in REXX. | package main
import (
"encoding/binary"
"log"
"math"
"os"
"strings"
)
func main() {
const (
sampleRate = 44100
duration = 8
dataLength = sampleRate * duration
hdrSize = 44
fileLen = dataLength + hdrSize - 8
)
buf1 := make([]byte, 1)... |
* 24.02.2013 Walter Pachl derived from original REXX version
* Changes: sound(f,sec) --> beep(trunc(f),millisec)
* $ -> sc
* @. -> f.
* re > ra (in sc)
*--------------------------------------------------------------------*/
sc='do ra mi fa so la te do'
dur=1250
... |
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import (
"fmt"
"math"
"sort"
)
type Patient struct {
id int
lastName string
}
var patientDir = make(map[int]string)
var patientIds []int
func patientNew(id int, lastName string) Patient {
patientDir[id] = lastName
patientIds = append(patientIds, id)
sort.Ints(pa... |
patients='patients.csv'
l=linein(patients)
Parse Var l h1 ',' h2
n=0
idl=''
Do n=1 By 1 While lines(patients)>0
l=linein(patients)
Parse Var l id ',' lastname.id
idl=idl id
End
n=n-1
visits='visits.csv'
l=linein(visits)
h3='LAST_VISIT'
h4='SCORE_SUM'
h5='SCORE_AVG'
date.=''
score.=0
Say '|' h1 '|' h2 '|' h3 ... |
Translate the given Go code snippet into REXX without altering its behavior. | package main
import (
"log"
"github.com/jtblin/go-ldap-client"
)
func main() {
client := &ldap.LDAPClient{
Base: "dc=example,dc=com",
Host: "ldap.example.com",
Port: 389,
UseSSL: false,
BindDN: "uid=readonlyuser,ou=People,dc=examp... |
options replace format comments java crossref symbols binary
import org.apache.directory.ldap.client.api.LdapConnection
import org.apache.directory.ldap.client.api.LdapNetworkConnection
import org.apache.directory.shared.ldap.model.exception.LdapException
import org.slf4j.Logger
import org.slf4j.LoggerFactory
class ... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"flag"
"fmt"
)
func main() {
b := flag.Bool("b", false, "just a boolean")
s := flag.String("s", "", "any ol' string")
n := flag.Int("n", 0, "your lucky number")
flag.Parse()
fmt.Println("b:", *b)
fmt.Println("s:", *s)
fmt.Println("n:", *n)
}
|
parse arg opts
opts=space(opts)
!.=
do while opts\==''
parse var opts x opts
select
when x=='-e' ... |
Generate an equivalent REXX version of this Go code. | package main
import (
"flag"
"fmt"
)
func main() {
b := flag.Bool("b", false, "just a boolean")
s := flag.String("s", "", "any ol' string")
n := flag.Int("n", 0, "your lucky number")
flag.Parse()
fmt.Println("b:", *b)
fmt.Println("s:", *s)
fmt.Println("n:", *n)
}
|
parse arg opts
opts=space(opts)
!.=
do while opts\==''
parse var opts x opts
select
when x=='-e' ... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
var board [][]int
var start, given []int
func setup(input []string) {
puzzle := make([][]string, len(input))
for i := 0; i < len(input); i++ {
puzzle[i] = strings.Fields(input[i])
}
nCols := len(puzzle[0])
nRows... |
maxR=0; maxC=0; maxX=0; minR=9e9; minC=9e9; minX=9e9; cells=0; @.=
parse arg xxx; PZ='Hidato puzzle'
xxx=translate(xxx, , "/\;:_", ',')
do while xxx\=''; parse var xxx r c marks ',' xxx
do while marks\=''; _=@... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
var board [][]int
var start, given []int
func setup(input []string) {
puzzle := make([][]string, len(input))
for i := 0; i < len(input); i++ {
puzzle[i] = strings.Fields(input[i])
}
nCols := len(puzzle[0])
nRows... |
maxR=0; maxC=0; maxX=0; minR=9e9; minC=9e9; minX=9e9; cells=0; @.=
parse arg xxx; PZ='Hidato puzzle'
xxx=translate(xxx, , "/\;:_", ',')
do while xxx\=''; parse var xxx r c marks ',' xxx
do while marks\=''; _=@... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import "fmt"
type link struct {
int
next *link
}
func linkInts(s []int) *link {
if len(s) == 0 {
return nil
}
return &link{s[0], linkInts(s[1:])}
}
func (l *link) String() string {
if l == nil {
return "nil"
}
r := fmt.Sprintf("[%d", l.int)
for l = l.... |
options replace format comments java crossref savelog symbols binary
import java.util.List
placesList = [String -
"UK London", "US New York", "US Boston", "US Washington" -
, "UK Washington", "US Birmingham", "UK Birmingham", "UK Boston" -
]
lists = [ -
placesList -
, strandSort(St... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"math"
"strconv"
"strings"
)
func d2d(d float64) float64 { return math.Mod(d, 360) }
func g2g(g float64) float64 { return math.Mod(g, 400) }
func m2m(m float64) float64 { return math.Mod(m, 6400) }
func r2r(r float64) float64 { return math.Mod(r, 2*math.Pi) }
func d2g(d... |
numeric digits length( pi() ) - length(.)
parse arg x
if x='' | x="," then x= '-2 -1 0 1 2 6.2831853 16 57.2957795 359 399 6399 1000000'
w= 20; w7= w+7
@deg = 'degrees'; @grd= "gradians"; @mil = 'mils'; @rad = "rad... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import (
"encoding/xml"
"fmt"
"log"
"os"
)
type Inventory struct {
XMLName xml.Name `xml:"inventory"`
Title string `xml:"title,attr"`
Sections []struct {
XMLName xml.Name `xml:"section"`
Name string `xml:"name,attr"`
Items []struct {
XMLName xml.Name `xml:"item"`
Name ... |
options replace format comments java symbols binary
import javax.xml.parsers.
import javax.xml.xpath.
import org.w3c.dom.
import org.w3c.dom.Node
import org.xml.sax.
xmlStr = '' -
|| '<inventory title="OmniCorp Store #45x10^3">' -
|| ' <section name="health">' -
|| ' <item upc="123456789" stock="12">' -
... |
Generate an equivalent REXX version of this Go code. | package main
import (
"fmt"
"log"
"os/exec"
"strings"
"time"
)
func main() {
s := "Actions speak louder than words."
prev := ""
prevLen := 0
bs := ""
for _, word := range strings.Fields(s) {
cmd := exec.Command("espeak", word)
if err := cmd.Run(); err != nil {
... |
parse arg t
#= words(t)
if #==0 then exit
dq= '"'
rate= 1
do j=1 for #
x= word(t, j); upper x ... |
Write a version of this Go function in REXX with identical behavior. | package main
import (
"fmt"
"log"
"os/exec"
"strings"
"time"
)
func main() {
s := "Actions speak louder than words."
prev := ""
prevLen := 0
bs := ""
for _, word := range strings.Fields(s) {
cmd := exec.Command("espeak", word)
if err := cmd.Run(); err != nil {
... |
parse arg t
#= words(t)
if #==0 then exit
dq= '"'
rate= 1
do j=1 for #
x= word(t, j); upper x ... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"strings"
"unicode"
)
type line struct {
kind lineKind
option string
value string
disabled bool
}
type lineKind int
const (
_ lineKind = iota
ignore
parseError
comment
blank
value
)
func (l line) String() string {
switch l.kind {
cas... |
parse arg iFID oFID .
if iFID=='' | iFID=="," then iFID= 'UPDATECF.TXT'
if oFID=='' | oFID=="," then oFID='\TEMP\UPDATECF.$$$'
call lineout iFID; call lineout oFID
$.=0
call dos 'ERASE' oFID
cha... |
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import (
"fmt"
"strings"
)
func main() {
key := `
8752390146
ET AON RIS
5BC/FGHJKLM
0PQD.VWXYZU`
p := "you have put on 7.5 pounds since I saw you."
fmt.Println(p)
c := enc(key, p)
fmt.Println(c)
fmt.Println(dec(key, c))
}
func enc(bd, pt string) (ct string) {
enc :=... |
parse arg msg
if msg='' then msg= 'One night-it was the twentieth of March, 1888-I was returning'
say 'plain text=' msg
call genCipher 'et aon ris', 'bcdfghjklm', 'pq/uvwxyz.'
enc= encrypt(msg); say ' encrypted=' enc
dec= decrypt(enc); say... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import (
"bufio"
"fmt"
"log"
"os"
"regexp"
"strings"
)
func main() {
f, err := os.Open("unixdict.txt")
if err != nil {
log.Fatalln(err)
}
defer f.Close()
s := bufio.NewScanner(f)
rie := regexp.MustCompile("^ie|[^c]ie")
rei := regexp.MustCompile("^ei|[^c]ei")
var cie, ie int
var cei, ei ... |
parse arg iFID .
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT'
#.=0
do r=0 while lines(iFID)\==0
u=space( lineIn(iFID), 0); upper u
if u=='' then iterate
#.words=#.wor... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"bufio"
"fmt"
"log"
"os"
"regexp"
"strings"
)
func main() {
f, err := os.Open("unixdict.txt")
if err != nil {
log.Fatalln(err)
}
defer f.Close()
s := bufio.NewScanner(f)
rie := regexp.MustCompile("^ie|[^c]ie")
rei := regexp.MustCompile("^ei|[^c]ei")
var cie, ie int
var cei, ei ... |
parse arg iFID .
if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT'
#.=0
do r=0 while lines(iFID)\==0
u=space( lineIn(iFID), 0); upper u
if u=='' then iterate
#.words=#.wor... |
Write a version of this Go function in REXX with identical behavior. | package raster
import "math"
func ipart(x float64) float64 {
return math.Floor(x)
}
func round(x float64) float64 {
return ipart(x + .5)
}
func fpart(x float64) float64 {
return x - ipart(x)
}
func rfpart(x float64) float64 {
return 1 - fpart(x)
}
func (g *Grmap) AaLine(x1, y1, x2, y2 float64) {
... |
background= 'Β·'
image.= background
plotC= 'ββββ'
EoE= 3000
do j=-EoE to +EoE
image.j.0= 'β'
... |
Write the same code in REXX as shown below in Go. | package main
import (
"fmt"
"sort"
)
func permute(s string) []string {
var res []string
if len(s) == 0 {
return res
}
b := []byte(s)
var rc func(int)
rc = func(np int) {
if np == 1 {
res = append(res, string(b))
return
}
np1 := n... |
parse arg n
if n='' | n="," then n= 0 9 12 21 12453 738440 45072010 95322020
w= length( commas( word(n, words(n) ) ) )
do j=1 for words(n); y= word(n, j)
masky= mask(y)
lim= copies(9, length(y) ) ... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import (
"fmt"
"sort"
)
func permute(s string) []string {
var res []string
if len(s) == 0 {
return res
}
b := []byte(s)
var rc func(int)
rc = func(np int) {
if np == 1 {
res = append(res, string(b))
return
}
np1 := n... |
parse arg n
if n='' | n="," then n= 0 9 12 21 12453 738440 45072010 95322020
w= length( commas( word(n, words(n) ) ) )
do j=1 for words(n); y= word(n, j)
masky= mask(y)
lim= copies(9, length(y) ) ... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import (
"github.com/micmonay/keybd_event"
"log"
"runtime"
"time"
)
func main() {
kb, err := keybd_event.NewKeyBonding()
if err != nil {
log.Fatal(err)
}
if runtime.GOOS == "linux" {
time.Sleep(2 * time.Second)
}
kb.SetKeys(keybd_event.V... |
call press 'This text will be put into a buffer as if it came from the keyboard'
|
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import (
"fmt"
"math"
"strings"
)
func main() {
for _, n := range [...]int64{
0, 4, 6, 11, 13, 75, 100, 337, -164,
math.MaxInt64,
} {
fmt.Println(fourIsMagic(n))
}
}
func fourIsMagic(n int64) string {
s := say(n)
s = strings.ToUpper(s[:1]) + s[1:]
t := s
for n != 4 {
n = int64(len(s))
... |
numeric digits 3003
parse arg x
if x='' then x= -164 0 4 6 11 13 75 100 337 9223372036854775807
@.= .
do j=1 for words(x)
say 4_is( word(x, j) )
... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
var cylinder = [6]bool{}
func rshift() {
t := cylinder[5]
for i := 4; i >= 0; i-- {
cylinder[i+1] = cylinder[i]
}
cylinder[0] = t
}
func unload() {
for i := 0; i < 6; i++ {
cylinder[i] = false
}
}
fun... |
parse arg cyls tests seed .
if cyls=='' | cyls=="," then cyls= 6
if tests=='' | tests=="," then tests= 100000
if datatype(seed, 'W') then call random ,,seed
cyls_ = cyls - 1; @0= copies(0, cyls)
@abc= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
scenarios= 'LSLSFsF... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import (
"bytes"
"fmt"
"strings"
)
var in = `
00000000000000000000000000000000
01111111110000000111111110000000
01110001111000001111001111000000
01110000111000001110000111000000
01110001111000001110000000000000
01111111110000001110000000000000
01110111100000001110000111000000
0111001111001110... |
parse arg iFID .; if iFID=='' then iFID='ZHANG_SUEN.DAT'
white=' '; @.=white
do row=1 while lines(iFID)\==0; _=linein(iFID)
_=translate(_,,.0); cols.row=length(_)
do col=1 for cols.row; @.row.col=substr(_,col,1)
end ... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"math/rand"
)
type symbols struct{ k, q, r, b, n rune }
var A = symbols{'K', 'Q', 'R', 'B', 'N'}
var W = symbols{'β', 'β', 'β', 'β', 'β'}
var B = symbols{'β', 'β', 'β', 'β', 'β'}
var krn = []string{
"nnrkr", "nrnkr", "nrknr", "nrkrn",
"rnnkr", "rnknr", "rnkrn",
"rknnr... |
parse arg seed .
if seed\=='' then call random ,,seed
@.=.
r1=random(1,6)
@.r1='R'
do until r2\==r1 & r2\==r1-1 & r2\==r1+1
r2=random(1,8)
end
@.r2=... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"regexp"
)
var bits = []string{
"0 0 0 1 1 0 1 ",
"0 0 1 1 0 0 1 ",
"0 0 1 0 0 1 1 ",
"0 1 1 1 1 0 1 ",
"0 1 0 0 0 1 1 ",
"0 1 1 0 0 0 1 ",
"0 1 0 1 1 1 1 ",
"0 1 1 1 0 1 1 ",
"0 1 1 0 1 1 1 ",
"0 0 0 1 0 1 1 ",
}
var (
lhs = make(map[st... |
#.0= ' ## #'
#.1= ' ## #'
#.2= ' # ##'
#.3= ' #### #'
#.4= ' # ##'
#.5= ' ## #'
#.6= ' # ####'
#.7= ' ### ##'
#.8= ' ## ###'
#.9= ' # ##' ; do i=0 for 10; ... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import (
"fmt"
"os/exec"
)
func main() {
command := "EventCreate"
args := []string{"/T", "INFORMATION", "/ID", "123", "/L", "APPLICATION",
"/SO", "Go", "/D", "\"Rosetta Code Example\""}
cmd := exec.Command(command, args...)
err := cmd.Run()
if err != nil {
fmt.... |
eCMD = 'EVENTCREATE'
type = 'INFORMATION'
id = 234
logName = 'APPLICATION'
source = 'REXX'
desc = 'attempting to add an entry for a Rosetta Code demonstrat... |
Port the following code from Go to REXX with equivalent syntax and logic. | import (
"fmt"
"strings"
)
func main() {
for _, n := range []int64{
1, 2, 3, 4, 5, 11, 65, 100, 101, 272, 23456, 8007006005004003,
} {
fmt.Println(sayOrdinal(n))
}
}
var irregularOrdinals = map[string]string{
"one": "first",
"two": "second",
"three": "third",
"five": "fifth",
"eight": "eighth"... |
numeric digits 3000
parse arg n
if n='' | n="," then n= 1 2 3 4 5 11 65 100 101 272 23456 8007006005004003
pgmOpts= 'ordinal quiet'
do j=1 for words(n)
x=word(n, j) ... |
Transform the following Go implementation into REXX, maintaining the same output and logic. | package main
import (
"encoding/hex"
"fmt"
"io"
"net"
"os"
"strconv"
"strings"
"text/tabwriter"
)
func parseIPPort(address string) (net.IP, *uint64, error) {
ip := net.ParseIP(address)
if ip != nil {
return ip, nil, nil
}
host, portStr, err := net.SplitHostPort(address)
if err != nil {
return nil,... |
_= "_"; say center('input IP address' , 30),
center('hex IP address' , 32),
center('decimal IP address' , 39) "space port"
say copies(_, 30) copies(_, 32) copies(_, 39) copies(_, 5) copies(_, 5)
call IP_parse 127.0.0.1
call IP... |
Generate an equivalent REXX version of this Go code. | package main
import (
"fmt"
"math"
)
const eps = 1e-14
type point struct{ x, y float64 }
func (p point) String() string {
if p.x == 0 {
p.x = 0
}
if p.y == 0 {
p.y = 0
}
return fmt.Sprintf("(%g, %g)", p.x, p.y)
}
func sq(x float64) float64 { return x * x }
... |
parse arg x1 y1 x2 y2 cx cy r .
if x1=='' | x1=="," then x1= 0
if y1=='' | y1=="," then y1= -3
if x2=='' | x2=="," then x2= 0
if y2=='' | y2=="," then y2= 6
if cx=='' | cx=="," then cx= 0
if cy=='' | cy==",... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import (
"fmt"
"github.com/rivo/uniseg"
"log"
"regexp"
"strings"
)
func join(words, seps []string) string {
lw := len(words)
ls := len(seps)
if lw != ls+1 {
log.Fatal("mismatch between number of words and separators")
}
var sb strings.Builder
for i := 0... |
zDefault= 'Tom? Toms bottom tomato is in his stomach while playing the "Tom-tom"' ,
"brand tom-toms. That's so tom."
parse arg x '~' z
if x=='' | x=="," then x= 'Tom tom t'
if z= '' | z= "," then z= zDefault
options= 'wβsβn wβiβn pβsβn ... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"log"
"math"
"strings"
)
var error = "Argument must be a numeric literal or a decimal numeric string."
func getNumDecimals(n interface{}) int {
switch v := n.(type) {
case int:
return 0
case float64:
if v == math.Trunc(v) {
return 0
... |
numeric digits 1000
@.=;
parse arg @.1; if @.1='' then do; #= 9
@.1 = 12
@.2 = 12.345
@.3 = 12.345555555555
... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import "fmt"
func printMinCells(n int) {
fmt.Printf("Minimum number of cells after, before, above and below %d x %d square:\n", n, n)
p := 1
if n > 20 {
p = 2
}
for r := 0; r < n; r++ {
cells := make([]int, n)
for c := 0; c < n; c++ {
nums := []int{... |
parse arg $
if $='' | $="," then $= 21 10 9 2 1
@title= ' the minimum number of cells after, before, above, and below a '
do j=1 for words($); g= word($, j)
w= length( (g-1) % 2)
say center(@title g"x"g ' squa... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"math"
)
func main() {
list := []float64{1, 8, 2, -3, 0, 1, 1, -2.3, 0, 5.5, 8, 6, 2, 9, 11, 10, 3}
maxDiff := -1.0
var maxPairs [][2]float64
for i := 1; i < len(list); i++ {
diff := math.Abs(list[i-1] - list[i])
if diff > maxDiff {
maxDi... |
parse arg $
if $='' | S=="," then $= ,
'1,8,2,-3,0,1,1,-2.3,0,5.5,8,6,2,9,11,10,3'
w= 0
$= translate($, , ',')
#= words($)
do i=1... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import (
"fmt"
"sort"
)
var board = []string{
".00.00.",
"0000000",
"0000000",
".00000.",
"..000..",
"...0...",
}
var moves = [][2]int{
{-3, 0}, {0, 3}, {3, 0}, {0, -3},
{2, 2}, {2, -2}, {-2, 2}, {-2, -2},
}
var grid [][]int
var totalToFill = 0
func solve(r, c,... |
call time 'Reset'
maxR=0; maxC=0; maxX=0; minR=9e9; minC=9e9; minX=9e9; cells=0; @.=
parse arg xxx
xxx=translate(xxx, , "/\;:_", ',')
do while xxx\=''; parse var xxx r c marks ',' x... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import (
"fmt"
"sort"
)
var board = []string{
".00.00.",
"0000000",
"0000000",
".00000.",
"..000..",
"...0...",
}
var moves = [][2]int{
{-3, 0}, {0, 3}, {3, 0}, {0, -3},
{2, 2}, {2, -2}, {-2, 2}, {-2, -2},
}
var grid [][]int
var totalToFill = 0
func solve(r, c,... |
call time 'Reset'
maxR=0; maxC=0; maxX=0; minR=9e9; minC=9e9; minX=9e9; cells=0; @.=
parse arg xxx
xxx=translate(xxx, , "/\;:_", ',')
do while xxx\=''; parse var xxx r c marks ',' x... |
Transform the following Go implementation into REXX, maintaining the same output and logic. | package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
var example1 = []string{
"00,00,00,00,00,00,00,00,00",
"00,00,46,45,00,55,74,00,00",
"00,38,00,00,43,00,00,78,00",
"00,35,00,00,00,00,00,71,00",
"00,00,33,00,00,00,59,00,00",
"00,17,00,00,00,00,00,67,00",
"00,18,00,00... |
maxR= 0; maxC= 0; maxX= 0;
minR= 9e9; minC= 9e9; minX= 9e9;
cells= 0
parse arg xxx
xxx=translate(xxx, ',,,,,' , "/\;:_")
@.=
do while xxx\=''; parse var xxx r c marks... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
var example1 = []string{
"00,00,00,00,00,00,00,00,00",
"00,00,46,45,00,55,74,00,00",
"00,38,00,00,43,00,00,78,00",
"00,35,00,00,00,00,00,71,00",
"00,00,33,00,00,00,59,00,00",
"00,17,00,00,00,00,00,67,00",
"00,18,00,00... |
maxR= 0; maxC= 0; maxX= 0;
minR= 9e9; minC= 9e9; minX= 9e9;
cells= 0
parse arg xxx
xxx=translate(xxx, ',,,,,' , "/\;:_")
@.=
do while xxx\=''; parse var xxx r c marks... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"reflect"
)
type example struct{}
func (example) Foo() int {
return 42
}
func (e example) CallMethod(n string) int {
if m := reflect.ValueOf(e).MethodByName(n); m.IsValid() {
return int(m.Call(nil)[0].Int())
}
fmt.Println("Unknown method:", ... | u = .unknown~new
u~foo(1, 2, 3)
::class unknown
::method unknown
use arg name, args
say "Unknown method" name "invoked with arguments:" args~tostring('l',', ')
|
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"strconv"
"strings"
)
var atomicMass = map[string]float64{
"H": 1.008,
"He": 4.002602,
"Li": 6.94,
"Be": 9.0121831,
"B": 10.81,
"C": 12.011,
"N": 14.007,
"O": 15.999,
"F": 18.998403163,
"Ne": 20.1797,
"Na": 22.9897692... |
numeric digits 30
@.= ; @.Co= 58.933195 ; @.H = 1.00794 ; @.Np=237 ; @.Se= 78.96
@.Cr= 51.9961 ; @.In=114.818 ; @.N = 14.0067 ; @.Sg=266
@.Ac=227 ; @.Cs=132.9054519; @.Ir=192.217 ; @.Og=294 ; @.Si= 28.0855
@.Ag=... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
"os"
"sort"
"strings"
"text/template"
)
func main() {
const t = `[[[{{index .P 1}}, {{index .P 2}}],
[{{index .P 3}}, {{index .P 4}}, {{index .P 1}}],
{{index .P 5}}]]
`
type S struct {
P map[int]string
}
var s S
s.P = map[int]string{
... |
tok.=''
Do i=0 To 6
tok.i="'Payload#"i"'"
End
t1='[[[1,2],[3,4,1],5]]'
t2='[[[1,6],[3,4,7,0],5]]'
Call transform t1
Call transform t2
Exit
transform:
Parse Arg t 1 tt
[[['Payload#1', 'Payload#2'],
['Payload#3', 'Payload#4', 'Payload#1'],
'Payload#5']]
*/
lvl=0
n.=0
o=''
w=''
used.=0
Do While t<>''
Parse V... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
fn := "myth"
bx := ".backup"
var err error
if tf, err := os.Readlink(fn); err == nil {
fn = tf
}
var fi os.FileInfo
if fi, err = os.Stat(fn); err != nil {
fmt.Println(err)
return
... |
parse arg oFID .
if oFID=='' then do
say '***error*** no fileID was specified.'
exit 13
end
tFID= oFID'.$$$'
call lineout oFID
call lineo... |
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
fn := "myth"
bx := ".backup"
var err error
if tf, err := os.Readlink(fn); err == nil {
fn = tf
}
var fi os.FileInfo
if fi, err = os.Stat(fn); err != nil {
fmt.Println(err)
return
... |
parse arg oFID .
if oFID=='' then do
say '***error*** no fileID was specified.'
exit 13
end
tFID= oFID'.$$$'
call lineout oFID
call lineo... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import "fmt"
import "io/ioutil"
import "log"
import "os"
import "regexp"
import "strings"
func main() {
err := fix()
if err != nil {
log.Fatalln(err)
}
}
func fix() (err error) {
buf, err := ioutil.ReadAll(os.Stdin)
if err != nil {
return err
}
out, err := Lang(string(buf))
if err != nil {
... |
@="<"; old.=; old.1 = @'%s>' ; new.1 = @"lang %s>"
old.2 = @'/%s>' ; new.2 = @"/lang>"
old.3 = @'code %s>' ; new.3 = @"lang %s>"
old.4 = @'/code>' ; new.4 = @"/lang>"
iFID = 'Wikisource.txt' ... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"sort"
)
func firstMissingPositive(a []int) int {
var b []int
for _, e := range a {
if e > 0 {
b = append(b, e)
}
}
sort.Ints(b)
le := len(b)
if le == 0 || b[0] > 1 {
return 1
}
for i := 1; i < le; i++ {
if... |
parse arg a
if a='' | a="," then a= '[1,2,0] [3,4,-1,1] [7,8,9,11,12] [1,2,3,4,5]' ,
"[-6,-5,-2,-1] [5,-5] [-2] [1] []"
say 'the smallest missing positive integer for the following sets is:'
say
do j=1 for words(a) ... |
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import (
"fmt"
"math/rand"
"time"
)
var snl = map[int]int{
4: 14, 9: 31, 17: 7, 20: 38, 28: 84, 40: 59, 51: 67, 54: 34,
62: 19, 63: 81, 64: 60, 71: 91, 87: 24, 93: 73, 95: 75, 99: 78,
}
const sixThrowsAgain = true
func turn(player, square int) int {
for {
roll := 1 + ran... |
parse arg np seed .
if np=='' | np=="," then np= 3
if datatype(seed, 'W') then call random ,,seed
pad= left('',7)
do k=1 for 100; @.k= k
end
... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"math/rand"
"time"
)
var snl = map[int]int{
4: 14, 9: 31, 17: 7, 20: 38, 28: 84, 40: 59, 51: 67, 54: 34,
62: 19, 63: 81, 64: 60, 71: 91, 87: 24, 93: 73, 95: 75, 99: 78,
}
const sixThrowsAgain = true
func turn(player, square int) int {
for {
roll := 1 + ran... |
parse arg np seed .
if np=='' | np=="," then np= 3
if datatype(seed, 'W') then call random ,,seed
pad= left('',7)
do k=1 for 100; @.k= k
end
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.