Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Produce a functionally identical REXX code for the snippet given in Go. | package main
import "fmt"
func sieve(limit int) []bool {
limit++
c := make([]bool, limit)
c[0] = true
c[1] = true
p := 3
for {
p2 := p * p
if p2 >= limit {
break
}
for i := p2; i < limit; i += 2 * p {
c[i] = true
}
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1050
if cols=='' | cols=="," then cols= 10
call genP
w= 10
@nsp= ' next special primes < ' commas(... |
Change the following Go code into REXX without altering its purpose. | package main
import "fmt"
func sieve(limit int) []bool {
limit++
c := make([]bool, limit)
c[0] = true
c[1] = true
p := 3
for {
p2 := p * p
if p2 >= limit {
break
}
for i := p2; i < limit; i += 2 * p {
c[i] = true
}
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1050
if cols=='' | cols=="," then cols= 10
call genP
w= 10
@nsp= ' next special primes < ' commas(... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import (
"fmt"
"strconv"
"strings"
)
func divByAll(num int, digits []byte) bool {
for _, digit := range digits {
if num%int(digit-'0') != 0 {
return false
}
}
return true
}
func main() {
magic := 9 * 8 * 7
high := 9876432 / magic * magic
fo... |
$= 7 * 8 * 9
t= 0
do #=9876432 % $ * $ by -$
if # // $ \==0 then iterate
if verify(50, #, 'M') \==0 then iterate
t= t+1
do j=1 ... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import (
"fmt"
"strconv"
"strings"
)
func divByAll(num int, digits []byte) bool {
for _, digit := range digits {
if num%int(digit-'0') != 0 {
return false
}
}
return true
}
func main() {
magic := 9 * 8 * 7
high := 9876432 / magic * magic
fo... |
$= 7 * 8 * 9
t= 0
do #=9876432 % $ * $ by -$
if # // $ \==0 then iterate
if verify(50, #, 'M') \==0 then iterate
t= t+1
do j=1 ... |
Keep all operations the same but rewrite the snippet in REXX. | package main
import (
"fmt"
"log"
"math/big"
)
func jacobi(a, n uint64) int {
if n%2 == 0 {
log.Fatal("'n' must be a positive odd integer")
}
a %= n
result := 1
for a != 0 {
for a%2 == 0 {
a /= 2
nn := n % 8
if nn == 3 || nn == 5 {
... |
parse arg rows cols .
if rows='' | rows=="," then rows= 17
if cols='' | cols=="," then cols= 16
call hdrs
do r=1 by 2 to rows; _= right(r, 3)
do c=0 to cols
... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"permute"
)
func determinant(m [][]float64) (d float64) {
p := make([]int, len(m))
for i := range p {
p[i] = i
}
it := permute.Iter(p)
for s := it(); s != 0; s = it() {
pr := 1.
for i, Ο := range p {
pr *= m[i][Ο]
}
... |
* Test the two functions determinant and permanent
* using the matrix specifications shown for other languages
* 21.05.2013 Walter Pachl
**********************************************************************/
Call test ' 1 2',
' 3 4',2
Call test ' 1 2 3 4',
' 4 5 6 7',
' 7 8 9 ... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import (
"fmt"
"permute"
)
func determinant(m [][]float64) (d float64) {
p := make([]int, len(m))
for i := range p {
p[i] = i
}
it := permute.Iter(p)
for s := it(); s != 0; s = it() {
pr := 1.
for i, Ο := range p {
pr *= m[i][Ο]
}
... |
* Test the two functions determinant and permanent
* using the matrix specifications shown for other languages
* 21.05.2013 Walter Pachl
**********************************************************************/
Call test ' 1 2',
' 3 4',2
Call test ' 1 2 3 4',
' 4 5 6 7',
' 7 8 9 ... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import (
"fmt"
"rcu"
"strings"
)
func main() {
var numbers []int
for n := 0; n < 1000; n++ {
ns := fmt.Sprintf("%d", n)
ds := fmt.Sprintf("%d", rcu.DigitSum(n, 10))
if strings.Contains(ns, ds) {
numbers = append(numbers, n)
}
}
fmt.P... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1000
if cols=='' | cols=="," then cols= 10
w= 10
@sdsN= ' integers whose sum of decimal digis of N is a substring of N, where N < ' ,
... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import (
"math/rand"
"fmt"
)
func main() {
list := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
for i := 1; i <= 10; i++ {
sattoloCycle(list)
fmt.Println(list)
}
}
func sattoloCycle(list []int) {
for x := len(list) -1; x > 0; x-- {
j := rand.Intn(x)
list[x], list[j] = list[j], list[x]
}
}
|
parse arg a; say 'original:' space(a)
do x=0 for words(a); @.x= word(a, x+1); end
do #=x-1 by -1 to 1; j= random(0, #-1)
parse value @.# @.j with @.j @.#
end
$=
... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"math/rand"
"fmt"
)
func main() {
list := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
for i := 1; i <= 10; i++ {
sattoloCycle(list)
fmt.Println(list)
}
}
func sattoloCycle(list []int) {
for x := len(list) -1; x > 0; x-- {
j := rand.Intn(x)
list[x], list[j] = list[j], list[x]
}
}
|
parse arg a; say 'original:' space(a)
do x=0 for words(a); @.x= word(a, x+1); end
do #=x-1 by -1 to 1; j= random(0, #-1)
parse value @.# @.j with @.j @.#
end
$=
... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, err := sql.Open("sqlite3", "rc.db")
if err != nil {
log.Print(err)
return
}
defer db.Close()
_, err = db.Exec(`create table addr (
id int uniq... |
options replace format comments java crossref symbols binary
import java.sql.Connection
import java.sql.Statement
import java.sql.SQLException
import java.sql.DriverManager
class RTableCreate01 public
properties private constant
addressDDL = String '' -
' create table Address' -
' (' -
' addrID ... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"fmt"
"math/rand"
"time"
)
func cyclesort(ints []int) int {
writes := 0
for cyclestart := 0; cyclestart < len(ints)-1; cyclestart++ {
item := ints[cyclestart]
pos := cyclestart
for i := cyclestart + 1; i < len(ints); i++ {
if ints[i] < item {
pos++
}
}
if pos == cycl... |
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Sort an array in place and return the number of writes.
method cycleSort(array = Rexx[]) public static
writes = 0
-- Loop through the array to ... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
"math/rand"
"time"
)
func cyclesort(ints []int) int {
writes := 0
for cyclestart := 0; cyclestart < len(ints)-1; cyclestart++ {
item := ints[cyclestart]
pos := cyclestart
for i := cyclestart + 1; i < len(ints); i++ {
if ints[i] < item {
pos++
}
}
if pos == cycl... |
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Sort an array in place and return the number of writes.
method cycleSort(array = Rexx[]) public static
writes = 0
-- Loop through the array to ... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import "fmt"
func sieve(limit uint64) []bool {
limit++
c := make([]bool, limit)
c[0] = true
c[1] = true
p := uint64(3)
for {
p2 := p * p
if p2 >= limit {
break
}
for i := p2; i < limit; i += 2 * p {
c[i] = true
... |
parse arg $ .
if $='' | $="," then $= 10 100 1000 10000 100000 1000000 10000000
w= length( commas( word($, words($) ) ) )
@found= ' twin prime pairs found under '
do i=1 for words($); x= word($, i)
say right( commas(genP(x)), 20) @found... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import (
"archive/tar"
"compress/gzip"
"flag"
"io"
"log"
"os"
"time"
)
func main() {
filename := flag.String("file", "TAPE.FILE", "filename within TAR")
data := flag.String("data", "", "data for file")
outfile := flag.String(... |
dsName = 'TAPE.FILE'
do j=1 for 100
call lineout dsName, 'this is record' j || "."
end
|
Produce a functionally identical REXX code for the snippet given in Go. | package main
import "fmt"
func main() {
a := []int{0}
used := make(map[int]bool, 1001)
used[0] = true
used1000 := make(map[int]bool, 1001)
used1000[0] = true
for n, foundDup := 1, false; n <= 15 || !foundDup || len(used1000) < 1001; n++ {
next := a[n-1] - n
if next < 1 || used[... |
parse arg N h .
if N=='' | N=="," then N= 15
if h=='' | h=="," then h= 1000
say "RecamΓ‘n's sequence for the first " N " numbers: " recaman(N)
say; say "The first duplicate number in the RecamΓ‘n's sequence is: " ... |
Please provide an equivalent version of this Go code in REXX. | package main
import "fmt"
func main() {
a := []int{0}
used := make(map[int]bool, 1001)
used[0] = true
used1000 := make(map[int]bool, 1001)
used1000[0] = true
for n, foundDup := 1, false; n <= 15 || !foundDup || len(used1000) < 1001; n++ {
next := a[n-1] - n
if next < 1 || used[... |
parse arg N h .
if N=='' | N=="," then N= 15
if h=='' | h=="," then h= 1000
say "RecamΓ‘n's sequence for the first " N " numbers: " recaman(N)
say; say "The first duplicate number in the RecamΓ‘n's sequence is: " ... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import "fmt"
type Func func(int) int
type FuncFunc func(Func) Func
type RecursiveFunc func (RecursiveFunc) Func
func main() {
fac := Y(almost_fac)
fib := Y(almost_fib)
fmt.Println("fac(10) = ", fac(10))
fmt.Println("fib(10) = ", fib(10))
}
func Y(f FuncFunc) Func {
g := func(r RecursiveFunc) Func ... |
numeric digits 1000
say ' fib' Y(fib (50) )
say ' fib' Y(fib (12 11 10 9 8 7 6 5 4 3 2 1 0) )
say ' fact' Y(fact (60) )
say ' fact' Y(fact (0 1 2 3 4 5 6 7 8 9 10 ... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import (
"fmt"
"strconv"
)
func main() {
var fact [12]uint64
fact[0] = 1
for n := uint64(1); n < 12; n++ {
fact[n] = fact[n-1] * n
}
for b := 9; b <= 12; b++ {
fmt.Printf("The factorions for base %d are:\n", b)
for i := uint64(1); i < 1500000; i++... |
parse arg LOb HIb lim .
if LOb=='' | LOb=="," then LOb= 9
if HIb=='' | HIb=="," then HIb= 12
if lim=='' | lim=="," then lim= 1500000 - 1
do fact=0 to HIb; !.fact= !(fact)
end
do base=LOb to HIb
@= 1 2... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import (
"fmt"
"strconv"
)
func main() {
var fact [12]uint64
fact[0] = 1
for n := uint64(1); n < 12; n++ {
fact[n] = fact[n-1] * n
}
for b := 9; b <= 12; b++ {
fmt.Printf("The factorions for base %d are:\n", b)
for i := uint64(1); i < 1500000; i++... |
parse arg LOb HIb lim .
if LOb=='' | LOb=="," then LOb= 9
if HIb=='' | HIb=="," then HIb= 12
if lim=='' | lim=="," then lim= 1500000 - 1
do fact=0 to HIb; !.fact= !(fact)
end
do base=LOb to HIb
@= 1 2... |
Convert this Go snippet to REXX and keep its semantics consistent. | package main
import "fmt"
func sumDivisors(n int) int {
sum := 0
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
sum += i
j := n / i
if j != i {
sum += j
}
}
i += k
}
return... |
parse arg n cols .
if n=='' | n=="," then n= 100
if cols=='' | cols=="," then cols= 10
say ' index β'center("sum of divisors", 102)
say 'ββββββββΌ'center("" , 102,'β')
w= 10
$=; ... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import "fmt"
func sumDivisors(n int) int {
sum := 0
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
sum += i
j := n / i
if j != i {
sum += j
}
}
i += k
}
return... |
parse arg n cols .
if n=='' | n=="," then n= 100
if cols=='' | cols=="," then cols= 10
say ' index β'center("sum of divisors", 102)
say 'ββββββββΌ'center("" , 102,'β')
w= 10
$=; ... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"rcu"
)
func main() {
primes := rcu.Primes(79)
ix := 0
n := 1
count := 0
var pi []int
for {
if primes[ix] <= n {
count++
if count == 22 {
break
}
ix++
}
n++
pi =... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 22
if cols=='' | cols=="," then cols= 10
call genP
w= 10
title= ' number of primes that are (for all N) β€ prime(22) whi... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"rcu"
)
func main() {
primes := rcu.Primes(79)
ix := 0
n := 1
count := 0
var pi []int
for {
if primes[ix] <= n {
count++
if count == 22 {
break
}
ix++
}
n++
pi =... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 22
if cols=='' | cols=="," then cols= 10
call genP
w= 10
title= ' number of primes that are (for all N) β€ prime(22) whi... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
"sort"
"strings"
)
var count int = 0
func interactiveCompare(s1, s2 string) bool {
count++
fmt.Printf("(%d) Is %s < %s? ", count, s1, s2)
var response string
_, err := fmt.Scanln(&response)
return err == nil && strings.HasPrefix(response, "y")
}
func main... |
colors= 'violet red green indigo blue yellow orange'
q= 0; #= 0; $=
do j=1 for words(colors); q= inSort( word(colors, j), q)
end
say
do i=1 for #; say ' query' right(i, length(#) )":" !.i
end
say
say 'final orde... |
Please provide an equivalent version of this Go code in REXX. | package main
import (
"fmt"
"sync"
)
var a = []int{170, 45, 75, 90, 802, 24, 2, 66}
var aMax = 1000
const bead = 'o'
func main() {
fmt.Println("before:", a)
beadSort()
fmt.Println("after: ", a)
}
func beadSort() {
all := make([]byte, aMax*len(a))
abacus := make([][]byte, ... |
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method bead_sort(harry = Rexx[]) public static binary returns Rexx[]
MIN_ = 'MIN'
MAX_ = 'MAX'
beads = Rexx 0
beads[MIN_] = 0
beads[MAX_] = 0... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"log"
"strconv"
)
func co9Peterson(base int) (cob func(string) (byte, error), err error) {
if base < 2 || base > 36 {
return nil, fmt.Errorf("co9Peterson: %d invalid base", base)
}
addDigits := func(a, b byte) (string, error) {... |
parse arg LO HI base .
if LO=='' | LO=="," then do; LO=1; HI=1000; end
if HI=='' | HI=="," then HI= LO
if base=='' | base=="," then base= 10
numeric digits max(9, 2*length(HI**2) )
numbers= castOut(LO, HI, base)
@cast_out= 'cast-ou... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import (
"fmt"
"log"
"strconv"
)
func co9Peterson(base int) (cob func(string) (byte, error), err error) {
if base < 2 || base > 36 {
return nil, fmt.Errorf("co9Peterson: %d invalid base", base)
}
addDigits := func(a, b byte) (string, error) {... |
parse arg LO HI base .
if LO=='' | LO=="," then do; LO=1; HI=1000; end
if HI=='' | HI=="," then HI= LO
if base=='' | base=="," then base= 10
numeric digits max(9, 2*length(HI**2) )
numbers= castOut(LO, HI, base)
@cast_out= 'cast-ou... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import (
"encoding/json"
"fmt"
"io"
"os"
"sort"
"strings"
"time"
"unicode"
)
type Item struct {
Stamp time.Time
Name string
Tags []string `json:",omitempty"`
Notes string `json:",omitempty"`
}
func (i *Item) String() string {
s := i.Stamp.Format... |
* 05.10.2014
*--------------------------------------------------------------------*/
x05='05'x
mydb='sidb.txt'
Say 'Enter your commands,Β ?, or end'
Do Forever
Parse Pull l
Parse Var l command text
Select
When command='?' Then
Call help
When command='add' Then Do
Parse Var text item ',' catego... |
Preserve the algorithm and functionality while converting the code from Go to REXX. |
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) > 1 {
fmt.Println(os.Args[1])
}
}
| #!/usr/local/bin/regina
say arg(1)
|
Keep all operations the same but rewrite the snippet in REXX. |
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) > 1 {
fmt.Println(os.Args[1])
}
}
| #!/usr/local/bin/regina
say arg(1)
|
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import "fmt"
func countDivisors(n int) int {
count := 0
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
count++
j := n / i
if j != i {
count++
}
}
i += k
}
retu... |
parse arg LO HI cols .
if LO=='' | LO=="," then LO= 1
if HI=='' | HI=="," then HI= LO + 100 - 1
if cols=='' | cols=="," then cols= 20
w= 2 + (HI>45359)
say 'The number of divisors (tau) for integers up to ' n " (i... |
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import "fmt"
func countDivisors(n int) int {
count := 0
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
count++
j := n / i
if j != i {
count++
}
}
i += k
}
retu... |
parse arg LO HI cols .
if LO=='' | LO=="," then LO= 1
if HI=='' | HI=="," then HI= LO + 100 - 1
if cols=='' | cols=="," then cols= 20
w= 2 + (HI>45359)
say 'The number of divisors (tau) for integers up to ' n " (i... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import "fmt"
func mΓΆbius(to int) []int {
if to < 1 {
to = 1
}
mobs := make([]int, to+1)
primes := []int{2}
for i := 1; i <= to; i++ {
j := i
cp := 0
spf := false
for _, p := range primes {
if p > j {
break
... |
parse arg LO HI grp .
if LO=='' | LO=="," then LO= 0
if HI=='' | HI=="," then HI= 199
if grp=='' | grp=="," then grp= 20
call genP HI
say center(' The MΓΆ... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import "fmt"
func main() {
bf(10, `++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++
++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>>
>+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++.
<+++++++.--------.<<<<<+.<+++.---.`)
}
func bf(dLen int, is string) {
ds := make([]byt... |
@.=0
p =0
! =0
parse arg $
if $='' then $=,
"++++++++++ ... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import "fmt"
func main() {
bf(10, `++++++++++[>+>+++>++++>+++++++>++++++++>+++++++++>++
++++++++>+++++++++++>++++++++++++<<<<<<<<<-]>>>>+.>>>
>+..<.<++++++++.>>>+.<<+.<<<<++++.<++.>>>+++++++.>>>.+++.
<+++++++.--------.<<<<<+.<+++.---.`)
}
func bf(dLen int, is string) {
ds := make([]byt... |
@.=0
p =0
! =0
parse arg $
if $='' then $=,
"++++++++++ ... |
Write a version of this Go function in REXX with identical behavior. | package main
import (
"fmt"
"rcu"
)
func contains(a []int, v int) bool {
for _, e := range a {
if e == v {
return true
}
}
return false
}
func main() {
const limit = 50
cpt := []int{1, 2}
for {
m := 1
l := len(cpt)
for contains(cpt, ... |
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 10
w= max(3, length( commas(n) ) )
@copt= ' coprime triplets where N < ' commas(n)
if cols>0 then say ' index ... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"rcu"
)
func contains(a []int, v int) bool {
for _, e := range a {
if e == v {
return true
}
}
return false
}
func main() {
const limit = 50
cpt := []int{1, 2}
for {
m := 1
l := len(cpt)
for contains(cpt, ... |
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 10
w= max(3, length( commas(n) ) )
@copt= ' coprime triplets where N < ' commas(n)
if cols>0 then say ' index ... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import "fmt"
func mertens(to int) ([]int, int, int) {
if to < 1 {
to = 1
}
merts := make([]int, to+1)
primes := []int{2}
var sum, zeros, crosses int
for i := 1; i <= to; i++ {
j := i
cp := 0
spf := false
for _, p := range primes {
... |
parse arg LO HI grp eqZ xZ .
if LO=='' | LO=="," then LO= 0
if HI=='' | HI=="," then HI= 199
if grp=='' | grp=="," then grp= 20
if eqZ=='' | eqZ=="," then eqZ= 1000
if xZ=='' | xZ=="," then xZ= 1000
call genP ... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import "fmt"
func prodDivisors(n int) int {
prod := 1
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
prod *= i
j := n / i
if j != i {
prod *= j
}
}
i += k
}
re... |
numeric digits 20
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 5
say ' index β'center("product of divisors", 102)
say 'ββββββββΌ'center("" , 102,'β')
w= max(... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import "fmt"
func prodDivisors(n int) int {
prod := 1
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
prod *= i
j := n / i
if j != i {
prod *= j
}
}
i += k
}
re... |
numeric digits 20
parse arg n cols .
if n=='' | n=="," then n= 50
if cols=='' | cols=="," then cols= 5
say ' index β'center("product of divisors", 102)
say 'ββββββββΌ'center("" , 102,'β')
w= max(... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import (
"fmt"
"rcu"
)
func main() {
limit := int(1e6)
lowerLimit := 2500
c := rcu.PrimeSieve(limit-1, true)
var erdos []int
lastErdos := 0
ec := 0
for i := 2; i < limit; {
if !c[i] {
found := true
for j, fact := 1, 1; fact < i; {
... |
parse arg n cols .
if n=='' | n=="," then n= 2500
if cols=='' | cols=="," then cols= 10
nn= n; n= abs(n)
call genP n
w= 10
if cols>0 then say... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
"rcu"
)
func main() {
limit := int(1e6)
lowerLimit := 2500
c := rcu.PrimeSieve(limit-1, true)
var erdos []int
lastErdos := 0
ec := 0
for i := 2; i < limit; {
if !c[i] {
found := true
for j, fact := 1, 1; fact < i; {
... |
parse arg n cols .
if n=='' | n=="," then n= 2500
if cols=='' | cols=="," then cols= 10
nn= n; n= abs(n)
call genP n
w= 10
if cols>0 then say... |
Convert this Go snippet to REXX and keep its semantics consistent. | package cards
import (
"math/rand"
)
type Suit uint8
const (
Spade Suit = 3
Heart Suit = 2
Diamond Suit = 1
Club Suit = 0
)
func (s Suit) String() string {
const suites = "CDHS"
return suites[s : s+1]
}
type Rank uint8
const (
Ace Rank = 1
Two Rank = 2
Three Rank = 3
Four Rank = 4
Fiv... |
* 1) Build ordered Card deck
* 2) Create shuffled stack
* 3) Deal 5 cards to 4 players each
* 4) show what cards have been dealt and what's left on the stack
* 05.07.2012 Walter Pachl
**********************************************************************/
colors='S H C D'
ranks ='A 2 3 4 5 6 7 8 9 T J Q K'
i=0
cards='... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"fmt"
"rcu"
)
func main() {
pairs := [][2]int{{21, 15}, {17, 23}, {36, 12}, {18, 29}, {60, 15}}
fmt.Println("The following pairs of numbers are coprime:")
for _, pair := range pairs {
if rcu.Gcd(pair[0], pair[1]) == 1 {
fmt.Println(pair)
}
}
}
|
parse arg @
if @='' | @=="," then @= '21,15 17,23 36,12 18,29 60,15 21,22,25,143 -2,0 0,-3'
do j=1 for words(@); say
stuff= translate( word(@, j), , ',')
cofactor= gcd(stuff)
if cofactor==1 then say stuf... |
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import (
"fmt"
"rcu"
)
func main() {
pairs := [][2]int{{21, 15}, {17, 23}, {36, 12}, {18, 29}, {60, 15}}
fmt.Println("The following pairs of numbers are coprime:")
for _, pair := range pairs {
if rcu.Gcd(pair[0], pair[1]) == 1 {
fmt.Println(pair)
}
}
}
|
parse arg @
if @='' | @=="," then @= '21,15 17,23 36,12 18,29 60,15 21,22,25,143 -2,0 0,-3'
do j=1 for words(@); say
stuff= translate( word(@, j), , ',')
cofactor= gcd(stuff)
if cofactor==1 then say stuf... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import "fmt"
func gcd(n, k int) int {
if n < k || k < 1 {
panic("Need n >= k and k >= 1")
}
s := 1
for n&1 == 0 && k&1 == 0 {
n >>= 1
k >>= 1
s <<= 1
}
t := n
if n&1 != 0 {
t = -k
}
for t != 0 {
for t&1 == 0 {
... |
parse arg N .
if N=='' | N=="," then N= 20
@.= .
p= 0
$=
do j=3 by 2 until p==N; s= phi(j)
a= s ... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import "fmt"
func gcd(n, k int) int {
if n < k || k < 1 {
panic("Need n >= k and k >= 1")
}
s := 1
for n&1 == 0 && k&1 == 0 {
n >>= 1
k >>= 1
s <<= 1
}
t := n
if n&1 != 0 {
t = -k
}
for t != 0 {
for t&1 == 0 {
... |
parse arg N .
if N=='' | N=="," then N= 20
@.= .
p= 0
$=
do j=3 by 2 until p==N; s= phi(j)
a= s ... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"fmt"
"math/big"
)
func main() {
limit := 100
last := 12
unsigned := true
l := make([][]*big.Int, limit+1)
for n := 0; n <= limit; n++ {
l[n] = make([]*big.Int, limit+1)
for k := 0; k <= limit; k++ {
l[n][k] = new(big.Int)
}
... |
parse arg lim .
if lim=='' | lim=="," then lim= 12
olim= lim
lim= abs(lim)
numeric digits max(9, 4*lim)
max#.= 0
!.=.
@.=
... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"math/big"
)
func main() {
limit := 100
last := 12
unsigned := true
l := make([][]*big.Int, limit+1)
for n := 0; n <= limit; n++ {
l[n] = make([]*big.Int, limit+1)
for k := 0; k <= limit; k++ {
l[n][k] = new(big.Int)
}
... |
parse arg lim .
if lim=='' | lim=="," then lim= 12
olim= lim
lim= abs(lim)
numeric digits max(9, 4*lim)
max#.= 0
!.=.
@.=
... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import "fmt"
func twoSum(a []int, targetSum int) (int, int, bool) {
len := len(a)
if len < 2 {
return 0, 0, false
}
for i := 0; i < len - 1; i++ {
if a[i] <= targetSum {
for j := i + 1; j < len; j++ {
sum := a[i] + a[j]
if sum ==... | a=.array~of( -5, 26, 0, 2, 11, 19, 90)
x=21
n=0
do i=1 To a~items
Do j=i+1 To a~items
If a[i]+a[j]=x Then Do
Say '['||i-1||','||j-1||']'
n=n+1
End
End
End
If n=0 Then
Say '[] - no items found'
|
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package main
import "fmt"
func twoSum(a []int, targetSum int) (int, int, bool) {
len := len(a)
if len < 2 {
return 0, 0, false
}
for i := 0; i < len - 1; i++ {
if a[i] <= targetSum {
for j := i + 1; j < len; j++ {
sum := a[i] + a[j]
if sum ==... | a=.array~of( -5, 26, 0, 2, 11, 19, 90)
x=21
n=0
do i=1 To a~items
Do j=i+1 To a~items
If a[i]+a[j]=x Then Do
Say '['||i-1||','||j-1||']'
n=n+1
End
End
End
If n=0 Then
Say '[] - no items found'
|
Transform the following Go implementation into REXX, maintaining the same output and logic. | package main
import (
"fmt"
"math/rand"
"time"
)
func cocktailShakerSort(a []int) {
var begin = 0
var end = len(a) - 2
for begin <= end {
newBegin := end
newEnd := begin
for i := begin; i <= end; i++ {
if a[i] > a[i+1] {
a[i+1], a[i] = a[i],... |
call gen
call show 'before sort'
say copies('β', 101)
call cocktailSort #
call show ' after sort'
exit
cocktailSort: proc... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"strconv"
)
func isPrime(n int) bool {
switch {
case n < 2:
return false
case n%2 == 0:
return n == 2
case n%3 == 0:
return n == 3
default:
d := 5
for d*d <= n {
if n%d == 0 {
return false
... |
parse arg n x hp .
if n=='' | n=="," then n= 35
if x=='' | x=="," then x= 600
if hp=='' | hp=="," then hp= 10000000
u= 0
eds=4; ed.1= 1; ed.2= 3; ed.3= 7; ed.4= 9
call genP hp ... |
Change the following Go code into REXX without altering its purpose. | package main
import "fmt"
func countDivisors(n int) int {
count := 0
i := 1
k := 2
if n%2 == 0 {
k = 1
}
for i*i <= n {
if n%i == 0 {
count++
j := n / i
if j != i {
count++
}
}
i += k
}
retu... |
parse arg n cols .
if n=='' | n=="," then n= 100
if cols=='' | cols=="," then cols= 10
w= max(8, length(n) )
@tau= ' the first ' commas(n) " tau numbers "
say ' index β'center(@tau, 1 + cols*(w+1) )
say 'ββββββββΌ'cente... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"fmt"
big "github.com/ncw/gmp"
"time"
)
func sieve(limit int) []bool {
limit++
c := make([]bool, limit)
c[0] = true
c[1] = true
p := 3
for {
p2 := p * p
if p2 >= limit {
break
}
for i := p2; i < limit; i... |
parse arg hi cols target .
if hi=='' | hi=="," then hi= 5000
if cols=='' | cols=="," then cols= 10
if target=='' | target=="," then target= 25
call genP
w= 10
title= ' primes tha... |
Change the programming language of this snippet from Go to REXX without modifying what it does. | package main
import (
"fmt"
big "github.com/ncw/gmp"
"time"
)
func sieve(limit int) []bool {
limit++
c := make([]bool, limit)
c[0] = true
c[1] = true
p := 3
for {
p2 := p * p
if p2 >= limit {
break
}
for i := p2; i < limit; i... |
parse arg hi cols target .
if hi=='' | hi=="," then hi= 5000
if cols=='' | cols=="," then cols= 10
if target=='' | target=="," then target= 25
call genP
w= 10
title= ' primes tha... |
Change the following Go code into REXX without altering its purpose. | package main
import (
"fmt"
"sort"
"strconv"
)
func combrep(n int, lst []byte) [][]byte {
if n == 0 {
return [][]byte{nil}
}
if len(lst) == 0 {
return nil
}
r := combrep(n, lst[1:])
for _, x := range combrep(n-1, lst) {
r = append(r, append(x, lst[0]))
}... |
parse arg LO HI COLS .
if LO=='' | LO=="," then LO= 337
if HI=='' | HI=="," then HI= 322222
if cols=='' | cols=="," then cols= 10
w= 10
title= ' decimal numbers found whose digits are ... |
Convert this Go block to REXX, preserving its control flow and logic. | package main
import (
"fmt"
"sort"
"strconv"
)
func combrep(n int, lst []byte) [][]byte {
if n == 0 {
return [][]byte{nil}
}
if len(lst) == 0 {
return nil
}
r := combrep(n, lst[1:])
for _, x := range combrep(n-1, lst) {
r = append(r, append(x, lst[0]))
}... |
parse arg LO HI COLS .
if LO=='' | LO=="," then LO= 337
if HI=='' | HI=="," then HI= 322222
if cols=='' | cols=="," then cols= 10
w= 10
title= ' decimal numbers found whose digits are ... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import (
"fmt"
big "github.com/ncw/gmp"
"strings"
)
func isPrime(n int) bool {
switch {
case n < 2:
return false
case n%2 == 0:
return n == 2
case n%3 == 0:
return n == 3
default:
d := 5
for d*d <= n {
if n%d == 0 {
... |
parse arg N hp .
if N=='' | N=="," then N= 19
if hp=='' | hp=="," then hip= 1000000
call genP
q= 024568
found= 0; $=
do j=1 until... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"rcu"
)
func main() {
primes := rcu.Primes(101)
var frobenius []int
for i := 0; i < len(primes)-1; i++ {
frob := primes[i]*primes[i+1] - primes[i] - primes[i+1]
if frob >= 10000 {
break
}
frobenius = append(frobenius, frob)
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 10000
if cols=='' | cols=="," then cols= 10
w= 10
call genP
title= ' Frobenius numbers that a... |
Write the same code in REXX as shown below in Go. | package main
import (
"fmt"
"rcu"
)
func main() {
primes := rcu.Primes(101)
var frobenius []int
for i := 0; i < len(primes)-1; i++ {
frob := primes[i]*primes[i+1] - primes[i] - primes[i+1]
if frob >= 10000 {
break
}
frobenius = append(frobenius, frob)
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 10000
if cols=='' | cols=="," then cols= 10
w= 10
call genP
title= ' Frobenius numbers that a... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import "fmt"
var a = []int{170, 45, 75, -90, -802, 24, 2, 66}
func main() {
fmt.Println("before:", a)
if len(a) > 1 && !recurse(len(a) - 1) {
panic("sorted permutation not found!")
}
fmt.Println("after: ", a)
}
func recurse(last int) bool {
... |
options replace format comments java crossref symbols nobinary
import java.util.List
import java.util.ArrayList
numeric digits 20
class RSortingPermutationsort public
properties private static
iterations
maxIterations
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
met... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import "fmt"
func main() {
fmt.Println(root(3, 8))
fmt.Println(root(3, 9))
fmt.Println(root(2, 2e18))
}
func root(N, X int) int {
for r := 1; ; {
x := X
for i := 1; i < N; i++ {
x /= r
}
x -= r
Ξ... |
parse arg num root digs .
if num=='' | num=="," then num= 2
if root=='' | root=="," then root= 2
if digs=='' | digs=="," then digs=2001
numeric digits digs
say 'number=' num
say ' root=' root... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import "fmt"
func main() {
fmt.Println(root(3, 8))
fmt.Println(root(3, 9))
fmt.Println(root(2, 2e18))
}
func root(N, X int) int {
for r := 1; ; {
x := X
for i := 1; i < N; i++ {
x /= r
}
x -= r
Ξ... |
parse arg num root digs .
if num=='' | num=="," then num= 2
if root=='' | root=="," then root= 2
if digs=='' | digs=="," then digs=2001
numeric digits digs
say 'number=' num
say ' root=' root... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import (
"fmt"
"math/big"
"rcu"
"sort"
)
func main() {
primes := rcu.Primes(379)
primorial := big.NewInt(1)
var fortunates []int
bPrime := new(big.Int)
for _, prime := range primes {
bPrime.SetUint64(uint64(prime))
primorial.Mul(primorial, bPrime)
... |
numeric digits 12
parse arg n cols .
if n=='' | n=="," then n= 8
if cols=='' | cols=="," then cols= 10
call genP n**2
pp.= 1
do i=1 for n+1; im= i - 1; pp.i= pp.im * @.i
end
i=i-1; call genp pp.... |
Change the following Go code into REXX without altering its purpose. |
package main
import "fmt"
func MeaningOfLife() int {
return 42
}
func libMain() {
fmt.Println("The meaning of life is", MeaningOfLife())
}
|
parse source . howInvoked @fn
say 'This program ('@fn") was invoked as a: " howInvoked
if howInvoked\=='COMMAND' then do
say 'This program ('@fn") wasn't invoked via a command."
exit 12
end
... |
Port the provided Go code into REXX while preserving the original functionality. |
package main
import "fmt"
func MeaningOfLife() int {
return 42
}
func libMain() {
fmt.Println("The meaning of life is", MeaningOfLife())
}
|
parse source . howInvoked @fn
say 'This program ('@fn") was invoked as a: " howInvoked
if howInvoked\=='COMMAND' then do
say 'This program ('@fn") wasn't invoked via a command."
exit 12
end
... |
Convert the following code from Go to REXX, ensuring the logic remains intact. | package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
"io/ioutil"
"os"
"sort"
)
func main() {
if len(os.Args) != 2 {
fmt.Println("usage ff <go source filename>")
return
}
src, err := ioutil.ReadFile(os.Args[1])
if err != nil {
fmt.Println(err)
... | fid='pgm.rex'
cnt.=0
funl=''
Do While lines(fid)>0
l=linein(fid)
Do Until p=0
p=pos('(',l)
If p>0 Then Do
do i=p-1 To 1 By -1 While is_tc(substr(l,i,1))
End
fn=substr(l,i+1,p-i-1)
If fn<>'' Then
Call store fn
l=substr(l,p+1)
End
End
End
Do While funl<>''
... |
Produce a language-to-language conversion: from Go to REXX, same semantics. | package main
import (
"encoding/binary"
"encoding/json"
"fmt"
"github.com/boltdb/bolt"
"log"
)
type StockTrans struct {
Id int
Date string
Trans string
Symbol string
Quantity int
Price float32
Settled bool
}
func (st *StockTrans) save(db *bolt.DB, ... | id = 000112222
table.id.!firstname = 'Robert'
table.id.!middlename = 'Jon'
table.id.!lastname = 'Smith'
table.id.!dob = '06/09/1946'
table.id.!gender = 'm'
table.id.!phone = '(111)-222-3333'
table.id.!addr = '123 Elm Drive\Apartment 6A'
table.id.!town = 'Gotham City'... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"encoding/binary"
"encoding/json"
"fmt"
"github.com/boltdb/bolt"
"log"
)
type StockTrans struct {
Id int
Date string
Trans string
Symbol string
Quantity int
Price float32
Settled bool
}
func (st *StockTrans) save(db *bolt.DB, ... | id = 000112222
table.id.!firstname = 'Robert'
table.id.!middlename = 'Jon'
table.id.!lastname = 'Smith'
table.id.!dob = '06/09/1946'
table.id.!gender = 'm'
table.id.!phone = '(111)-222-3333'
table.id.!addr = '123 Elm Drive\Apartment 6A'
table.id.!town = 'Gotham City'... |
Keep all operations the same but rewrite the snippet in REXX. | package main
import "fmt"
func isPrime(n int) bool {
switch {
case n < 2:
return false
case n%2 == 0:
return n == 2
case n%3 == 0:
return n == 3
default:
d := 5
for d*d <= n {
if n%d == 0 {
return false
}
d... |
n=1000
prime = .Array~new(n)~fill(.true)~~remove(1)
p.=0
Do i = 2 to n
If prime[i] = .true Then Do
Do j = i * i to n by i
prime~remove(j)
End
p.i=1
End
End
z=0
ol=''
Do i=500 To 1000
If p.i then Do
dr=digroot(i)
If p.dr Then Do
ol=ol' 'i'('dr')'
z=z+1
If z//10=0... |
Write the same algorithm in REXX as shown in this Go implementation. | package main
import "fmt"
func isPrime(n int) bool {
switch {
case n < 2:
return false
case n%2 == 0:
return n == 2
case n%3 == 0:
return n == 3
default:
d := 5
for d*d <= n {
if n%d == 0 {
return false
}
d... |
n=1000
prime = .Array~new(n)~fill(.true)~~remove(1)
p.=0
Do i = 2 to n
If prime[i] = .true Then Do
Do j = i * i to n by i
prime~remove(j)
End
p.i=1
End
End
z=0
ol=''
Do i=500 To 1000
If p.i then Do
dr=digroot(i)
If p.dr Then Do
ol=ol' 'i'('dr')'
z=z+1
If z//10=0... |
Please provide an equivalent version of this Go code in REXX. | package main
import (
"fmt"
"time"
)
func main() {
var year int
var t time.Time
var lastDay = [12]int { 31,29,31,30,31,30,31,31,30,31,30,31 }
for {
fmt.Print("Please select a year: ")
_, err := fmt.Scanf("%d", &year)
if err != nil {
fmt.Println(err)
continue
} else {
break
}
}
fmt.Prin... |
parse arg yyyy
do j=1 for 12
_ = lastDOW('Sunday', j, yyyy)
say right(_,4)'-'right(j,2,0)"-"left(word(_,2),2)
end
exit
β lastDOW: procedure to return the date of the last day-of-week of β
β ... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import (
"fmt"
"time"
)
func main() {
var year int
var t time.Time
var lastDay = [12]int { 31,29,31,30,31,30,31,31,30,31,30,31 }
for {
fmt.Print("Please select a year: ")
_, err := fmt.Scanf("%d", &year)
if err != nil {
fmt.Println(err)
continue
} else {
break
}
}
fmt.Prin... |
parse arg yyyy
do j=1 for 12
_ = lastDOW('Sunday', j, yyyy)
say right(_,4)'-'right(j,2,0)"-"left(word(_,2),2)
end
exit
β lastDOW: procedure to return the date of the last day-of-week of β
β ... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"math/rand"
"time"
)
type matrix [][]int
func shuffle(row []int, n int) {
rand.Shuffle(n, func(i, j int) {
row[i], row[j] = row[j], row[i]
})
}
func latinSquare(n int) {
if n <= 0 {
fmt.Println("[]\n")
return
}
latin := make(matrix,... |
parse arg N seed .
if N=='' | N=="," then N= 5
if datatype(seed, 'W') then call random ,,seed
w= length(N - 1)
$=
do i=0 for N; $= $ right(i, w, '_')
end
z= ... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import (
"bufio"
"fmt"
"log"
"os"
"sort"
"strings"
)
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
func readWords(fileName string) []string {
file, err := os.Open(fileName)
check(err)
defer file.Close()
var words []string
scanner :... |
parse arg iFID L .
if iFID==''|iFID=="," then iFID= 'wordlist.10k'
if L==''| L=="," then L= 3
#= 0
@.=
do r=0 while lines(iFID) \== 0
parse upper ... |
Translate the given Go code snippet into REXX without altering its behavior. | package main
import (
"fmt"
"sort"
"strconv"
"strings"
)
func fairshare(n, base int) []int {
res := make([]int, n)
for i := 0; i < n; i++ {
j := i
sum := 0
for j > 0 {
sum += j % base
j /= base
}
res[i] = sum % base
}
retu... |
parse arg n g
if n=='' | n=="," then n= 25
if g='' | g="," then g= 2 3 5 11
do p=1 for words(g); r= word(g, p)
$= 'base' right(r, 2)': '
do j=0 for... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"strconv"
)
func uabs(a, b uint64) uint64 {
if a > b {
return a - b
}
return b - a
}
func isEsthetic(n, b uint64) bool {
if n == 0 {
return false
}
i := n % b
n /= b
for n > 0 {
j := n % b
if uabs(i, j) != 1 {
... |
parse arg baseL baseH range
if baseL=='' | baseL=="," then baseL= 2
if baseH=='' | baseH=="," then baseH=16
if range=='' | range=="," then range=1000..9999
do radix=baseL to baseH; #= 0; if radix<2 then iterate
start= radix * 4; stop = rad... |
Rewrite this program in REXX while keeping its functionality equivalent to the Go version. | package permute
func Iter(p []int) func() int {
f := pf(len(p))
return func() int {
return f(p)
}
}
func pf(n int) func([]int) int {
sign := 1
switch n {
case 0, 1:
return func([]int) (s int) {
s = sign
sign = 0
return
}
defa... |
Parse Arg things
e.=''
Select
When things='?' Then
Call help
When things='' Then
things=4
When words(things)>1 Then Do
elements=things
things=words(things)
Do i=0 By 1 While elements<>''
Parse Var elements e.i elements
End
End
Otherwise
If datatype(things)<>'NUM' Then... |
Generate an equivalent REXX version of this Go code. | package main
import (
"fmt"
"math/rand"
"sort"
"time"
)
func main() {
s := rand.NewSource(time.Now().UnixNano())
r := rand.New(s)
for {
var values [6]int
vsum := 0
for i := range values {
var numbers [4]int
for j := range numbers {
... |
Generates 4 random, whole values between 1 and 6.
Saves the sum of the 3 largest values.
Generates a total of 6 values this way.
Displays the total, and all 6 values once finished.
*/
Do try=1 By 1
ge15=0
sum=0
ol=''
Do i=1 To 6
rl=''
Do j=1 To 4
rl=rl (random(5)+1)
End
rl=wordsort(rl)
... |
Rewrite the snippet below in REXX so it works the same as the original Go code. | package main
import "fmt"
func countDivisors(n int) int {
count := 0
for i := 1; i*i <= n; i++ {
if n%i == 0 {
if i == n/i {
count++
} else {
count += 2
}
}
}
return count
}
func main() {
const max = 15
seq :=... |
parse arg N .
if N=='' | N=="," then N= 15
say 'ββdivisorsββ ββsmallest number with N divisorsββ'
@.=
do i=1 for N; z= 1 + (i\==1)
do j=z by z
if @.... |
Keep all operations the same but rewrite the snippet in REXX. | package main
import (
"bufio"
"errors"
"fmt"
"math"
"os"
"regexp"
"strconv"
"strings"
)
func main() {
fmt.Println("Numbers please separated by space/commas:")
sc := bufio.NewScanner(os.Stdin)
sc.Scan()
s, n, min, max, err := spark(sc.Text())
if err != nil {
... |
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method sparkline(spark) private static
spark = spark.changestr(',', ' ')
bars = '\u2581 \u2582 \u2583 \u2584 \u2585 \u2586 \u2587 \u2588'
barK = ... |
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import (
"fmt"
"sort"
)
type Node struct {
val int
back *Node
}
func lis (n []int) (result []int) {
var pileTops []*Node
for _, x := range n {
j := sort.Search(len(pileTops), func (i int) bool { return pileTops[i].val >= x })
node := &Node{ x, nil }
if j != 0 { node.back =... |
$.=; $.1= 3 2 6 4 5 1
$.2= 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15
do j=1 while $.j\==''; say
say ' input: ' $.j
call LIS $.j
say 'output: ' result
end
exi... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import "fmt"
type person struct{
name string
age int
}
func copy(p person) person {
return person{p.name, p.age}
}
func main() {
p := person{"Dave", 40}
fmt.Println(p)
q := copy(p)
fmt.Println(q)
}
|
β The REXX language doesn't allow for the changing or overriding of β
β syntax per se, but any of the built-in-functions (BIFs) can be β
β overridden by just specifying your own. β
β β
β To use the REXX's version o... |
Write the same code in REXX as shown below in Go. | package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"sort"
"strings"
"unicode/utf8"
)
func main() {
wordList := "unixdict.txt"
b, err := ioutil.ReadFile(wordList)
if err != nil {
log.Fatal("Error reading file")
}
bwords := bytes.Fields(b)
var words []strin... |
parse arg minL iFID .
if minL=='' | minL=="," then minL= 9
if iFID=='' | iFID=="," then iFID='unixdict.txt'
#= 0; @.=; !.= 0
do recs=0 while lines(iFID)\==0
x= strip( linein( iFID) )
if leng... |
Maintain the same structure and functionality when rewriting this code in REXX. | package main
import (
"bufio"
"fmt"
"log"
"os"
"strconv"
"strings"
)
func check(err error) {
if err != nil {
log.Fatal(err)
}
}
func main() {
scanner := bufio.NewScanner(os.Stdin)
n := 0
for n < 1 || n > 5 {
fmt.Print("How many integer variables do you want... |
parse arg newVar newValue
say 'Arguments as they were entered via the command line: ' newVar newValue
say
call value newVar, newValue
say 'The newly assigned value (as per the VALUE bif)------' newVar value(newVar)
|
Write the same code in REXX as shown below in Go. | package main
import (
"fmt"
"rcu"
"sort"
)
func main() {
primes := rcu.Primes(333)
var oss []int
for i := 1; i < len(primes)-1; i++ {
for j := i + 1; j < len(primes); j++ {
n := primes[i] * primes[j]
if n >= 1000 {
break
}
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1000
if cols=='' | cols=="," then cols= 10
call genP
w= 10
@oss= ' odd squarefree semiprimes... |
Translate the given Go code snippet into REXX without altering its behavior. | package main
import (
"fmt"
"rcu"
"sort"
)
func main() {
primes := rcu.Primes(333)
var oss []int
for i := 1; i < len(primes)-1; i++ {
for j := i + 1; j < len(primes); j++ {
n := primes[i] * primes[j]
if n >= 1000 {
break
}
... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1000
if cols=='' | cols=="," then cols= 10
call genP
w= 10
@oss= ' odd squarefree semiprimes... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"fmt"
"math/big"
)
var one = big.NewInt(1)
var ten = big.NewInt(10)
var twenty = big.NewInt(20)
var hundred = big.NewInt(100)
func sqrt(n float64, limit int) {
if n < 0 {
log.Fatal("Number cannot be negative")
}
count := 0
for n != math.Trunc(n) {
n *= 10... |
signal on halt
parse arg xx digs .
if xx=='' | xx=="," then xx= 2
if digs=='' | digs=="," then digs= 500
numeric digits digs + digs % 2
call sqrtHand xx, digs
halt: say ... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"fmt"
"rcu"
)
func nonDescending(p int) bool {
var digits []int
for p > 0 {
digits = append(digits, p%10)
p = p / 10
}
for i := 0; i < len(digits)-1; i++ {
if digits[i+1] > digits[i] {
return false
}
}
return true
}
fun... |
parse arg n cols .
if n=='' | n=="," then n= 1000
if cols=='' | cols=="," then cols= 10
call genP
w= 10
title= ' primes whose decimal di... |
Ensure the translated REXX code behaves exactly like the original Go snippet. | package main
import (
"fmt"
"rcu"
)
func nonDescending(p int) bool {
var digits []int
for p > 0 {
digits = append(digits, p%10)
p = p / 10
}
for i := 0; i < len(digits)-1; i++ {
if digits[i+1] > digits[i] {
return false
}
}
return true
}
fun... |
parse arg n cols .
if n=='' | n=="," then n= 1000
if cols=='' | cols=="," then cols= 10
call genP
w= 10
title= ' primes whose decimal di... |
Produce a functionally identical REXX code for the snippet given in Go. | package main
import (
"fmt"
"math"
"math/big"
"strconv"
"strings"
)
func calkinWilf(n int) []*big.Rat {
cw := make([]*big.Rat, n+1)
cw[0] = big.NewRat(1, 1)
one := big.NewRat(1, 1)
two := big.NewRat(2, 1)
for i := 1; i < n; i++ {
t := new(big.Rat).Set(cw[i-1])
f... |
numeric digits 2000
parse arg LO HI te .
if LO=='' | LO=="," then LO= 1
if HI=='' | HI=="," then HI= 20
if te=='' | te=="," then te= '/'
if datatype(LO, 'W') then call CW_terms
if pos('/', te)>0 ... |
Port the provided Go code into REXX while preserving the original functionality. | package main
import (
"fmt"
"math"
"math/big"
"strconv"
"strings"
)
func calkinWilf(n int) []*big.Rat {
cw := make([]*big.Rat, n+1)
cw[0] = big.NewRat(1, 1)
one := big.NewRat(1, 1)
two := big.NewRat(2, 1)
for i := 1; i < n; i++ {
t := new(big.Rat).Set(cw[i-1])
f... |
numeric digits 2000
parse arg LO HI te .
if LO=='' | LO=="," then LO= 1
if HI=='' | HI=="," then HI= 20
if te=='' | te=="," then te= '/'
if datatype(LO, 'W') then call CW_terms
if pos('/', te)>0 ... |
Translate this program into REXX but keep the logic exactly as in Go. | package main
import (
"fmt"
"sort"
"strings"
)
type indexSort struct {
val sort.Interface
ind []int
}
func (s indexSort) Len() int { return len(s.ind) }
func (s indexSort) Less(i, j int) bool { return s.ind[i] < s.ind[j] }
func (s indexSort) Swap(i, j int) {
s.val.Swap(s.ind[i], s.ind[j])
s.ind[i], ... |
used = '0'x
@. =
@.1 = " the cat sat on the mat | mat cat "
@.2 = " the cat sat on the mat | cat mat "
@.3 = " A B C A B C A B C | C A C A " ... |
Preserve the algorithm and functionality while converting the code from Go to REXX. | package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"strings"
)
func isPrime(n int) bool {
if n < 2 {
return false
}
if n%2 == 0 {
return n == 2
}
if n%3 == 0 {
return n == 3
}
d := 5
for d*d <= n {
if n%d == 0 {
return ... |
parse arg iFID .
if iFID=='' | iFID=="," then iFID='unixdict.txt'
call genPrimes
say 'reading the dictionary file: ' iFID
say
#= 0
do recs=0 while lines(iFID)\==0
x= stri... |
Port the following code from Go to REXX with equivalent syntax and logic. | package main
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"strings"
)
func isPrime(n int) bool {
if n < 2 {
return false
}
if n%2 == 0 {
return n == 2
}
if n%3 == 0 {
return n == 3
}
d := 5
for d*d <= n {
if n%d == 0 {
return ... |
parse arg iFID .
if iFID=='' | iFID=="," then iFID='unixdict.txt'
call genPrimes
say 'reading the dictionary file: ' iFID
say
#= 0
do recs=0 while lines(iFID)\==0
x= stri... |
Please provide an equivalent version of this Go code in REXX. | package main
import (
"fmt"
"rcu"
)
func reversed(n int) int {
rev := 0
for n > 0 {
rev = rev*10 + n%10
n /= 10
}
return rev
}
func main() {
primes := rcu.Primes(99999)
var pals []int
for _, p := range primes {
if p == reversed(p) {
pals = appen... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1000
if cols=='' | cols=="," then cols= 10
call genP
w= max(8, length( commas(hi) ) )
title= ' palindromic primes in base ten that ar... |
Generate a REXX translation of this Go snippet without changing its computational steps. | package main
import (
"fmt"
"rcu"
)
func reversed(n int) int {
rev := 0
for n > 0 {
rev = rev*10 + n%10
n /= 10
}
return rev
}
func main() {
primes := rcu.Primes(99999)
var pals []int
for _, p := range primes {
if p == reversed(p) {
pals = appen... |
parse arg hi cols .
if hi=='' | hi=="," then hi= 1000
if cols=='' | cols=="," then cols= 10
call genP
w= max(8, length( commas(hi) ) )
title= ' palindromic primes in base ten that ar... |
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically? | package main
import (
"fmt"
"math/big"
)
func main() {
one := big.NewInt(1)
two := big.NewInt(2)
next := new(big.Int)
sylvester := []*big.Int{two}
prod := new(big.Int).Set(two)
count := 1
for count < 10 {
next.Add(prod, one)
sylvester = append(sylvester, new(big.Int... |
parse arg n .
if n=='' | n=="," then n= 10
numeric digits max(9, 2**(n-7) * 13 + 1)
@.0= 2
$= 0
do j=0 for n; jm= j - 1
if j>0 then @.j= @.jm**2 - @.jm + 1
say 'S... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.