Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import "fmt" type frac struct{ num, den int } func (f frac) String() string { return fmt.Sprintf("%d/%d", f.num, f.den) } func f(l, r frac, n int) { m := frac{l.num + r.num, l.den + r.den} if m.den <= n { f(l, m, n) fmt.Print(m, " ") f(m, r, n) } } func main() {...
parse arg LO HI INC . if LO=='' | LO=="," then LO= 1 if HI=='' | HI=="," then HI= LO if INC=='' | INC=="," then INC= 1 sw= linesize() - 1 oLO= LO do j=abs(LO)...
Produce a functionally identical REXX code for the snippet given in Go.
package main import "fmt" type frac struct{ num, den int } func (f frac) String() string { return fmt.Sprintf("%d/%d", f.num, f.den) } func f(l, r frac, n int) { m := frac{l.num + r.num, l.den + r.den} if m.den <= n { f(l, m, n) fmt.Print(m, " ") f(m, r, n) } } func main() {...
parse arg LO HI INC . if LO=='' | LO=="," then LO= 1 if HI=='' | HI=="," then HI= LO if INC=='' | INC=="," then INC= 1 sw= linesize() - 1 oLO= LO do j=abs(LO)...
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(999) sum := 0 fmt.Println(" i p[i] Σp[i]") fmt.Println("----------------") for i := 0; i < len(primes); i += 2 { sum += primes[i] if rcu.IsPrime(sum) { fmt.Printf("%3d %3d %6s\n", i+1, p...
parse arg hi . if hi=='' | hi=="," then hi= 1000 call genP title= 'odd indexed primes the sum of the odd indexed primes' say ' index │'center(title, 65) say '───────┼'center("" , 65, '─') found...
Write the same algorithm in REXX as shown in this Go implementation.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(999) sum := 0 fmt.Println(" i p[i] Σp[i]") fmt.Println("----------------") for i := 0; i < len(primes); i += 2 { sum += primes[i] if rcu.IsPrime(sum) { fmt.Printf("%3d %3d %6s\n", i+1, p...
parse arg hi . if hi=='' | hi=="," then hi= 1000 call genP title= 'odd indexed primes the sum of the odd indexed primes' say ' index │'center(title, 65) say '───────┼'center("" , 65, '─') found...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "math" "strings" ) const threshold = uint64(1) << 47 func indexOf(s []uint64, search uint64) int { for i, e := range s { if e == search { return i } } return -1 } func contains(s []uint64, search uint64) bool { return indexOf(s, sea...
parse arg low high $L high= word(high low 10,1); low= word(low 1,1) if $L='' then $L=11 12 28 496 220 1184 12496 1264460 790 909 562 1064 1488 15355717786080 numeric digits 100 big= 2**47; NTlimit= 16 + 1 numeric digits max(9, length...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "math" "strings" ) const threshold = uint64(1) << 47 func indexOf(s []uint64, search uint64) int { for i, e := range s { if e == search { return i } } return -1 } func contains(s []uint64, search uint64) bool { return indexOf(s, sea...
parse arg low high $L high= word(high low 10,1); low= word(low 1,1) if $L='' then $L=11 12 28 496 220 1184 12496 1264460 790 909 562 1064 1488 15355717786080 numeric digits 100 big= 2**47; NTlimit= 16 + 1 numeric digits max(9, length...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import "fmt" func main() { var i int32 = 1 fmt.Printf("i : type %-7T value %d\n", i, i) j := 2 fmt.Printf("j : type %-7T value %d\n", j, j) var k int64 = int64(i) + int64(j) fmt.Printf("k : type %-7T value %d\n", k, k) ...
digs=digits() ; say digs a=.1.2...$ ; say a a=+7 ; say a a='+66' ; say a a='- 66.' ; ...
Generate an equivalent REXX version of this Go code.
package main import "fmt" func main() { var i int32 = 1 fmt.Printf("i : type %-7T value %d\n", i, i) j := 2 fmt.Printf("j : type %-7T value %d\n", j, j) var k int64 = int64(i) + int64(j) fmt.Printf("k : type %-7T value %d\n", k, k) ...
digs=digits() ; say digs a=.1.2...$ ; say a a=+7 ; say a a='+66' ; say a a='- 66.' ; ...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import "fmt" func isPrime(n uint64) bool { switch { case n < 2: return false case n%2 == 0: return n == 2 case n%3 == 0: return n == 3 default: d := uint64(5) for d*d <= n { if n%d == 0 { return false } ...
parse arg bet.1 bet.2 bet.3 highP . if bet.1=='' | bet.1=="," then bet.1= 1..45 if bet.2=='' | bet.2=="," then bet.2= 241..250 if bet.3=='' | bet.3=="," then bet.3= 391..400 if highP=='' | highP=="," then highP= 1000000 call genP do j=1 for 3...
Convert this Go block to REXX, preserving its control flow and logic.
package main import ( "fmt" "time" "math/big" ) func main() { start := time.Now() one := big.NewInt(1) mp := big.NewInt(0) bp := big.NewInt(0) const max = 22 for count, p := 0, uint(2); count < max; { mp.Lsh(one, p) mp.Sub(mp, one) if mp.ProbablyPrime(0) { elapsed := time.Since(start).Seconds()...
do j=1; if \isPrime(j) then iterate r= testMer(j) if r==0 then say right('M'j, 10) "──────── is a Mersenne prime." else say right('M'j, 50) "is composite, a factor:" r end ex...
Write the same code in REXX as shown below in Go.
package main import ( "fmt" "time" "math/big" ) func main() { start := time.Now() one := big.NewInt(1) mp := big.NewInt(0) bp := big.NewInt(0) const max = 22 for count, p := 0, uint(2); count < max; { mp.Lsh(one, p) mp.Sub(mp, one) if mp.ProbablyPrime(0) { elapsed := time.Since(start).Seconds()...
do j=1; if \isPrime(j) then iterate r= testMer(j) if r==0 then say right('M'j, 10) "──────── is a Mersenne prime." else say right('M'j, 50) "is composite, a factor:" r end ex...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "fmt" "math" ) 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] =...
parse arg hi cols . if hi=='' | hi=="," then hi= 15000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= 'the smallest primes < ' commas(hi) ...
Produce a functionally identical REXX code for the snippet given in Go.
package main import ( "fmt" "math" ) 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] =...
parse arg hi cols . if hi=='' | hi=="," then hi= 15000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= 'the smallest primes < ' commas(hi) ...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
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 N endU end2 end3 end4 end5 . if N=='' | N=="," then N= 1000035 - 1 if endU=='' | endU=="," then endU= 10 if end2=='' | end2=="," then end2= 5 if end3=='' | end3=="," then end3= 5 if end4=='' | end4=="," then end4= 5 if end5=='' | end5...
Produce a functionally identical REXX code for the snippet given in Go.
package main import ( "container/heap" "fmt" "strings" ) type CubeSum struct { x, y uint16 value uint64 } func (c *CubeSum) fixvalue() { c.value = cubes[c.x] + cubes[c.y] } type CubeSumHeap []*CubeSum func (h CubeSumHeap) Len() int { return len(h) } func (h CubeSumHeap) Less(i, j int) bool { retu...
parse arg L.1 H.1 L.2 H.2 L.3 H.3 . if L.1=='' | L.1=="," then L.1= 1 if H.1=='' | H.1=="," then H.1= 25 if L.2=='' | L.2=="," then L.2= 454 if H.2=='' | H.2=="," then H.2= 456 if L.3=='' | L.3=="," then L.3=2000 if H.3=='' | H.3...
Transform the following Go implementation into REXX, maintaining the same output and logic.
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 N kind _ . 1 . okind; upper kind if N=='' | N=="," then N= 36 if kind=='' | kind=="," then kind= 'STRONG' if _\=='' then call ser 'too many arguments specified.' if kind\=='WEAK' & kind\=='STRONG' then call ser 'invalid 2nd argument: ' okind ...
Write the same code in REXX as shown below in Go.
package main import ( "fmt" "math/big" ) func main() { fmt.Print("!0 through !10: 0") one := big.NewInt(1) n := big.NewInt(1) f := big.NewInt(1) l := big.NewInt(1) next := func() { f.Mul(f, n); l.Add(l, f); n.Add(n, one) } for ; ; next() { fmt.Print(" ", l) if n.Int...
parse arg bot top inc . if bot=='' | bot=="," then bot= 1 if top=='' | top=="," then top= bot if inc='' | inc=="," then inc= 1 tell= bot<0 bot= abs(bot) w= length(top) ...
Change the programming language of this snippet from Go to REXX without modifying what it does.
package main import ( "fmt" "math/big" ) func main() { fmt.Print("!0 through !10: 0") one := big.NewInt(1) n := big.NewInt(1) f := big.NewInt(1) l := big.NewInt(1) next := func() { f.Mul(f, n); l.Add(l, f); n.Add(n, one) } for ; ; next() { fmt.Print(" ", l) if n.Int...
parse arg bot top inc . if bot=='' | bot=="," then bot= 1 if top=='' | top=="," then top= bot if inc='' | inc=="," then inc= 1 tell= bot<0 bot= abs(bot) w= length(top) ...
Translate the given Go code snippet into REXX without altering its behavior.
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...
parse arg hi . if hi=='' | hi=="," then hi= 30 tell= hi>0; hi= abs(hi); hi= hi - 1 if tell>0 then say 'list of unique triplet strange primes whose sum is a prime.:' call genP finds= 0 ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
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...
parse arg hi . if hi=='' | hi=="," then hi= 30 tell= hi>0; hi= abs(hi); hi= hi - 1 if tell>0 then say 'list of unique triplet strange primes whose sum is a prime.:' call genP finds= 0 ...
Translate the given Go code snippet into REXX without altering its behavior.
package main import ( "fmt" "rcu" ) func motzkin(n int) []int { m := make([]int, n+1) m[0] = 1 m[1] = 1 for i := 2; i <= n; i++ { m[i] = (m[i-1]*(2*i+1) + m[i-2]*(3*i-3)) / (i + 2) } return m } func main() { fmt.Println(" n M[n] Prime?") fmt.Printl...
numeric digits 92 parse arg n . if n=='' | n=="," then n= 42 w= length(n) + 1; wm= digits()%4 say center('n', w ) center("Motzkin[n]", wm) center(' primality', 11) say center('' , w, "─") center('' ...
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "fmt" "rcu" ) func main() { var primes []int candidates := []int{3, 33} for i := 303; i <= 393; i += 10 { candidates = append(candidates, i) } for i := 3003; i <= 3993; i += 10 { candidates = append(candidates, i) } for _, cand := range candida...
parse arg hi cols dig . if hi=='' | hi=="," then hi= 4000 if cols=='' | cols=="," then cols= 10 if dig=='' | dig=="," then dig= 3 call genP w= 10 title= ' primes N ...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "rcu" ) func main() { var primes []int candidates := []int{3, 33} for i := 303; i <= 393; i += 10 { candidates = append(candidates, i) } for i := 3003; i <= 3993; i += 10 { candidates = append(candidates, i) } for _, cand := range candida...
parse arg hi cols dig . if hi=='' | hi=="," then hi= 4000 if cols=='' | cols=="," then cols= 10 if dig=='' | dig=="," then dig= 3 call genP w= 10 title= ' primes N ...
Produce a functionally identical REXX code for the snippet given in Go.
package main import ( "fmt" "rcu" ) const MAX = 1e7 - 1 var primes = rcu.Primes(MAX) func specialNP(limit int, showAll bool) { if showAll { fmt.Println("Neighbor primes, p1 and p2, where p1 + p2 - 1 is prime:") } count := 0 for i := 1; i < len(primes); i++ { p2 := primes[i] ...
parse arg hi cols . if hi=='' | hi=="," then hi= 100 if cols=='' | cols=="," then cols= 5 call genP hi do p=1 while @.p<hi end #m= # - 1 call genP @.# + @.#m - 1 w= 20 ...
Rewrite this program in REXX while keeping its functionality equivalent to the Go version.
package main import ( "fmt" "rcu" ) const MAX = 1e7 - 1 var primes = rcu.Primes(MAX) func specialNP(limit int, showAll bool) { if showAll { fmt.Println("Neighbor primes, p1 and p2, where p1 + p2 - 1 is prime:") } count := 0 for i := 1; i < len(primes); i++ { p2 := primes[i] ...
parse arg hi cols . if hi=='' | hi=="," then hi= 100 if cols=='' | cols=="," then cols= 5 call genP hi do p=1 while @.p<hi end #m= # - 1 call genP @.# + @.#m - 1 w= 20 ...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import "fmt" func isPrime(n int) bool { return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17 } func main() { count := 0 var d []int fmt.Println("Strange plus numbers in the open interval (100, 500) are:\n") for i := 101; i < 500; i++ { d = d[:0] ...
parse arg LO HI . if LO=='' | LO=="," then LO= 101 if HI=='' | HI=="," then HI= 499 !.= 0; !.2= 1; !.3= 1; !.5= 1; !.7= 1 !.11= 1; !.13= 1; !.17= 1 $= #= 0 ...
Generate an equivalent REXX version of this Go code.
package main import "fmt" func isPrime(n int) bool { return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17 } func main() { count := 0 var d []int fmt.Println("Strange plus numbers in the open interval (100, 500) are:\n") for i := 101; i < 500; i++ { d = d[:0] ...
parse arg LO HI . if LO=='' | LO=="," then LO= 101 if HI=='' | HI=="," then HI= 499 !.= 0; !.2= 1; !.3= 1; !.5= 1; !.7= 1 !.11= 1; !.13= 1; !.17= 1 $= #= 0 ...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "math/big" ) var b = new(big.Int) func isSPDSPrime(n uint64) bool { nn := n for nn > 0 { r := nn % 10 if r != 2 && r != 3 && r != 5 && r != 7 { return false } nn /= 10 } b.SetUint64(n) if b.ProbablyPrime(0) { ...
parse arg n q if n=='' | n=="," then n= 25 if q='' then q= 100 1000 say '═══listing the first' n "SPDS primes═══" call spds n do i=1 for words(q)+1; y=word(q, i); if y=='' | y=="," then iterate ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "log" "strings" ) const dimensions int = 8 func setupMagicSquareData(d int) ([][]int, error) { var output [][]int if d < 4 || d%4 != 0 { return [][]int{}, fmt.Errorf("Square dimension must be a positive number which is divisible by 4") } var bits uint = 0x9669 size := d * d mu...
n= 8; s= n%4; L= n%2-s+1; w= length(n**2) @.= 0; H= n%2+s call gen call diag call corn call midd call swap ...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "fmt" "math" ) func sieve(limit uint64) []uint64 { primes := []uint64{2} c := make([]bool, limit+1) p := uint64(3) for { p2 := p * p if p2 > limit { break } for i := p2; i <= limit; i += 2 * p { c[i] = true ...
numeric digits 20 parse arg LO HI . if LO=='' | LO=="," then LO= 1 if HI=='' | HI=="," then HI= 145 sw= linesize() - 1 # = 0 $= ...
Write the same code in REXX as shown below in Go.
package main import ( "fmt" "time" ) func sumDigits(n int) int { sum := 0 for n > 0 { sum += n % 10 n /= 10 } return sum } func max(x, y int) int { if x > y { return x } return y } func main() { st := time.Now() count := 0 var selfs []int i...
parse arg n . if n=='' | n=="," then n= 50 tell = n>0; n= abs(n) @.= . do j=1 for n*10 $= j do...
Convert this Go snippet to REXX and keep its semantics consistent.
package main import "fmt" type is func() uint64 func newSum() is { var ms is ms = func() uint64 { ms = newSum() return ms() } var msd, d uint64 return func() uint64 { if d < 9 { d++ } else { d = 0 msd = ms() } ret...
parse arg lim . if lim=='' | lim==',' then lim= 10000000 numeric digits 2 + max(8, length(lim) ) gap= 0; old= 0 @gsa= 'gap starts at Niven #' call tell center('gap size', 12) cent...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "bufio" "fmt" "os" "strconv" "strings" ) func main() { units := []string{ "tochka", "liniya", "dyuim", "vershok", "piad", "fut", "arshin", "sazhen", "versta", "milia", "centimeter", "meter", "kilometer", } convs := []float32{ 0.025...
numeric digits 200 KM= 1000; CM=100 sw= linesize() -1 parse arg N what _ __ if N=='' then call err 'no arguments specified.'...
Change the following Go code into REXX without altering its purpose.
package main import "fmt" func pancake(n int) int { gap, sum, adj := 2, 2, -1 for sum < n { adj++ gap = gap*2 - 1 sum += gap } return n + adj } func main() { for i := 0; i < 4; i++ { for j := 1; j < 6; j++ { n := i*5 + j fmt.Printf("p(%2d) =...
pad= center('' , 10) say pad center('pancakes', 10 ) center('pancake flips', 15 ) say pad center('' , 10, "─") center('', 15, "─") do #=1 for 20; say pad center(#, 10) center( pancake(#), 15) end exit 0...
Write the same algorithm in REXX as shown in this Go implementation.
package main import "fmt" const ( N = 2200 N2 = N * N * 2 ) func main() { s := 3 var s1, s2 int var r [N + 1]bool var ab [N2 + 1]bool for a := 1; a <= N; a++ { a2 := a * a for b := a; b <= N; b++ { ab[a2 + b * b] = true } } for c := 1; ...
parse arg hi . if hi=='' | hi=="," then hi=2200; high= 3 * hi @.=. !.=. do j=1 for high _= j*j; !._= j; if j<=hi then @.j= _ end d.=. ...
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import "fmt" type pair struct{ x, y int } func main() { const max = 1685 var all []pair for a := 2; a < max; a++ { for b := a + 1; b < max-a; b++ { all = append(all, pair{a, b}) } } fmt.Println("There are", len(all), "pairs where a+b <", max, "(and a<b)") products := countProducts(all...
all =.set~new Call time 'R' cnt.=0 do a=2 to 100 do b=a+1 to 100-2 p=a b if a+b>100 then leave b all~put(p) prd=a*b cnt.prd+=1 End End Say "There are" all~items "pairs where X+Y <=" max "(and X<Y)" spairs=.set~new Do Until all~items=0 do p over all d=decompositions(p) If take...
Ensure the translated REXX code behaves exactly like the original Go snippet.
package main import "fmt" const max = 12 var ( super []byte pos int cnt [max]int ) func factSum(n int) int { s := 0 for x, f := 0, 1; x < n; { x++ f *= x s += f } return s } func r(n int) bool { if n == 0 { return false } c := super[pos-n...
parse arg cycles . if cycles=='' | cycles=="," then cycles= 7 do n=0 to cycles #= 0; $.= do pop=1 for n; @.pop= d2x(pop); $.0= $.0 || @.pop end do while aPerm(n, 0) ...
Please provide an equivalent version of this Go code in REXX.
package main import ( "fmt" "math" "math/big" "reflect" "strings" "unsafe" ) func Float64IsInt(f float64) bool { _, frac := math.Modf(f) return frac == 0 } func Float32IsInt(f float32) bool { return Float64IsInt(float64(f)) } func Complex128IsInt(c complex128) bool { return imag(c) == 0 && Float6...
* 22.06.2014 Walter Pachl using a complex data class * ooRexx Distribution contains an elaborate complex class * parts of which are used here * see REXX for Extra Credit implementation *--------------------------------------------------------------------*/ Numeric Digits 1000 Call test_integer .complex~new(1e+12,0e-3)...
Translate the given Go code snippet into REXX without altering its behavior.
package main import ( "bufio" "fmt" "log" "os" "strconv" "strings" "time" ) func main() { fmt.Println("CPU usage % at 1 second intervals:\n") var prevIdleTime, prevTotalTime uint64 for i := 0; i < 10; i++ { file, err := os.Open("/proc/stat") if err != nil { ...
signal on halt numeric digits 20 parse arg n wait iFID . if n=='' | n="," then n= 10 if wait=='' | wait="," then wait= 1 if iFID=='' | iFID="," then iFID= '/proc/stat' prevTot = 0; ...
Produce a functionally identical REXX code for the snippet given in Go.
package main import "fmt" func ulam(n int) int { ulams := []int{1, 2} set := map[int]bool{1: true, 2: true} i := 3 for { count := 0 for j := 0; j < len(ulams); j++ { _, ok := set[i-ulams[j]] if ok && ulams[j] != (i-ulams[j]) { count++ ...
parse arg $ if $='' | $="," then $= 10 100 1000 10000 do k=1 for words($) x= Ulam( word($, k) ) say 'the ' commas(#)th(#) ' Ulam number is: ' commas(x) end exit 0 ...
Write the same code in REXX as shown below in Go.
package main import "fmt" var ( a [17][17]int idx [4]int ) func findGroup(ctype, min, max, depth int) bool { if depth == 4 { cs := "" if ctype == 0 { cs = "un" } fmt.Printf("Totally %sconnected group:", cs) for i := 0; i < 4; i++ { fmt.Pri...
@.=0; #=17 do d=0 for #; @.d.d= 2 end do k=1 by 0 while k<=8 do i=0 for #; j= (i+k) // # @.i.j= 1; @.j.i= 1 end k= k + k ...
Write a version of this Go function in REXX with identical behavior.
package main import ( "fmt" "math/big" "strconv" "strings" ) func commatize(s string) string { neg := false if strings.HasPrefix(s, "-") { s = s[1:] neg = true } le := len(s) for i := le - 3; i >= 1; i -= 3 { s = s[0:i] + "," + s[i:] } if !neg { ...
numeric digits 100 parse arg hi . if hi=='' | hi=="," then hi= 22 w= 50 @smp6= ' smallest power of six (expressed in decimal) which contains N' say ' N │ power │'center(@...
Write a version of this Go function in REXX with identical behavior.
package main import "fmt" type any = interface{} func showType(a any) { switch a.(type) { case rune: fmt.Printf("The type of '%c' is %T\n", a, a) default: fmt.Printf("The type of '%v' is %T\n", a, a) } } func main() { values := []any{5, 7.5, 2 + 3i, 'd', true, "Rosetta"} for ...
signal on noValue y= 1938 ; call showType y y= 77.1 ; call showType y y= ; call showType y y= ' ' ; call showType y y= 'abc' ; call showType y y= 'ABC' ; ...
Rewrite this program in REXX while keeping its functionality equivalent to the Go version.
package main import ( "fmt" "rcu" ) func allButOneEven(prime int) bool { digits := rcu.Digits(prime, 10) digits = digits[:len(digits)-1] allEven := true for _, d := range digits { if d&1 == 1 { allEven = false break } } return allEven } func mai...
parse arg hi cols . if hi=='' | hi=="," then hi= 1000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= ' primes N (in base ten) that only contain one odd digit, w...
Translate the given Go code snippet into REXX without altering its behavior.
package main import ( "fmt" "rcu" ) func allButOneEven(prime int) bool { digits := rcu.Digits(prime, 10) digits = digits[:len(digits)-1] allEven := true for _, d := range digits { if d&1 == 1 { allEven = false break } } return allEven } func mai...
parse arg hi cols . if hi=='' | hi=="," then hi= 1000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= ' primes N (in base ten) that only contain one odd digit, w...
Convert this Go block to REXX, preserving its control flow and logic.
package main import "fmt" func sieve(limit uint64) []bool { limit++ c := make([]bool, limit) c[0] = true c[1] = true for i := uint64(4); i < limit; i += 2 { c[i] = true } p := uint64(3) for { p2 := p * p if p2 >= limit { break } ...
parse arg N kind _ . 1 . okind; upper kind if N=='' | N=="," then N= 35 if kind=='' | kind=="," then kind= 'SAFE' if _\=='' then call ser 'too many arguments specified.' if kind\=='SAFE' & kind\=='UNSAFE' then call ser 'invalid 2nd argument: ' okind ...
Rewrite this program in REXX while keeping its functionality equivalent to the Go version.
package main import "fmt" func main() { tableA := []struct { value int key string }{ {27, "Jonah"}, {18, "Alan"}, {28, "Glory"}, {18, "Popeye"}, {28, "Alan"}, } tableB := []struct { key string value string }{ {"Jonah", "Whales"}, {"Jonah"...
S. = ; R. = S.1 = 27 'Jonah' ; R.1 = "Jonah Whales" S.2 = 18 'Alan' ; R.2 = "Jonah Spiders" S.3 = 28 'Glory' ; R.3 = "Alan Ghosts" S.4 = 18 ...
Change the following Go code into REXX without altering its purpose.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(499) var sprimes []int for _, p := range primes { digits := rcu.Digits(p, 10) var b1 = true for _, d := range digits { if !rcu.IsPrime(d) { b1 = false break ...
parse arg n cols . if n=='' | n=="," then n= 500 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= ' primes (base ten) where all substrings are also primes, wher...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "rcu" ) func main() { primes := rcu.Primes(499) var sprimes []int for _, p := range primes { digits := rcu.Digits(p, 10) var b1 = true for _, d := range digits { if !rcu.IsPrime(d) { b1 = false break ...
parse arg n cols . if n=='' | n=="," then n= 500 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= ' primes (base ten) where all substrings are also primes, wher...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "fmt" "rcu" ) func countDivisors(n int) int { count := 0 i := 1 k := 1 if n%2 == 1 { k = 2 } for ; i*i <= n; i += k { if n%i == 0 { count++ j := n / i if j != i { count++ } } ...
parse arg hi cols . if hi=='' | hi=="," then hi= 1000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= ' positive integers N whose number of divisors is prime (and...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "time" ) func main() { start := time.Now() for a := 3; ; a++ { for b := a + 1; ; b++ { c := 1000 - a - b if c <= b { break } if a*a+b*b == c*c { fmt.Printf("a = %d, b = %d, c = %d\n", a,...
parse arg sum hi n . if sum=='' | sum=="," then sum= 1000 if hi=='' | hi=="," then hi= 1000 if n=='' | n=="," then n= 1 hh= hi - 2 do j=1 for hi; @.j= j*j ...
Keep all operations the same but rewrite the snippet in REXX.
package main import "fmt" var ( n = 3 values = []string{"A", "B", "C", "D"} k = len(values) decide = func(p []string) bool { return p[0] == "B" && p[1] == "C" } ) func main() { pn := make([]int, n) p := make([]string, n) for { for i, x := range pn { ...
parse arg things bunch inbetweenChars names call permSets things, bunch, inBetweenChars, names exit p: return word( arg(1), 1) permSets: procedure; parse arg x,y,between,uSy...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import "fmt" var ( n = 3 values = []string{"A", "B", "C", "D"} k = len(values) decide = func(p []string) bool { return p[0] == "B" && p[1] == "C" } ) func main() { pn := make([]int, n) p := make([]string, n) for { for i, x := range pn { ...
parse arg things bunch inbetweenChars names call permSets things, bunch, inBetweenChars, names exit p: return word( arg(1), 1) permSets: procedure; parse arg x,y,between,uSy...
Convert this Go snippet to REXX and keep its semantics consistent.
package main import ( "fmt" "go/ast" "go/parser" "strings" "unicode" ) func isValidIdentifier(identifier string) bool { node, err := parser.ParseExpr(identifier) if err != nil { return false } ident, ok := node.(*ast.Ident) return ok && ident.Name == identifier } type runeRanges struct { ranges []stri...
Parse Version v Say v symbol_characters='' do j=0 To 255 c=d2c(j) if datatype(c,'S') then symbol_characters=symbol_characters || c end say 'symbol characters:' symbol_characters
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "encoding/json" "log" "os" "bytes" "errors" "strings" ) type s1 struct { A string B string C int D string } type s2 struct { A string C intString X string } type intString string func (i *intString) UnmarshalJSON(b []byte) error { if ...
-- nrc -keepasjava -savelog copys options replace format comments java crossref symbols nobinary parse arg ddname_IN ddname_OUT . do if ddname_IN.length = 0 then ddname_IN = 'copys.in.txt' if ddname_OUT.length = 0 then ddname_OUT = 'copys.out.txt' dd_IN = File(ddname_IN) dd_OUT = File(ddname_OUT) scanner_I...
Please provide an equivalent version of this Go code in REXX.
package main import ( "bufio" "fmt" "log" "os" "os/exec" "strconv" "time" ) func main() { scanner := bufio.NewScanner(os.Stdin) number := 0 for number < 1 { fmt.Print("Enter number of seconds delay > 0 : ") scanner.Scan() input := scanner.Text() ...
say '──────── Please enter a number of seconds to wait:' parse pull waitTime . say '──────── Please enter a name of an MP3 file to play:' parse pull MP3FILE call sleep waitTime MP3FILE'.MP3'
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "math" ) 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] =...
parse arg hi cols . if hi=='' | hi=="," then hi= 16000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= 'the smallest primes < ' commas(hi) ...
Generate an equivalent REXX version of this Go code.
package main import ( "fmt" "math" ) 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] =...
parse arg hi cols . if hi=='' | hi=="," then hi= 16000 if cols=='' | cols=="," then cols= 10 call genP w= 10 title= 'the smallest primes < ' commas(hi) ...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "fmt" "log" ) func minimum(a []int) int { min := a[0] for i := 1; i < len(a); i++ { if a[i] < min { min = a[i] } } return min } func sum(a []int) int { s := 0 for _, i := range a { s = s + i } return s } func hourglass...
t4= 0 mx= 10000 do t4=0 by 4 to mx t7_left= 7 - t4 % 7 if t7_left==9-4 then leave end say if t4>mx then do say 'Not found.' exit 4 end say "Turn over both sandglasses (at the same time) and continue" say "flipping t...
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "fmt" "log" ) func minimum(a []int) int { min := a[0] for i := 1; i < len(a); i++ { if a[i] < min { min = a[i] } } return min } func sum(a []int) int { s := 0 for _, i := range a { s = s + i } return s } func hourglass...
t4= 0 mx= 10000 do t4=0 by 4 to mx t7_left= 7 - t4 % 7 if t7_left==9-4 then leave end say if t4>mx then do say 'Not found.' exit 4 end say "Turn over both sandglasses (at the same time) and continue" say "flipping t...
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "fmt" "rcu" "strings" ) var grid = [][]int { { 8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8}, {49, 49, 99, 40, 17, 81, 18, 57, 60, 87, 17, 40, 98, 43, 69, 48, 4, 56, 62, 0}, {81, 49, 31, 73, 55, 79, 14, 29, 93, 71, 40, 67, 53, 88, 30, 3...
a.1=.array~of(08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08) a.2=.array~of(49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00) a.3=.array~of(81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65) a.4=.array~of(52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91) a.5=.array~of(22,31...
Translate the given Go code snippet into REXX without altering its behavior.
package main import ( "fmt" "time" ) func main() { fmt.Print("\033[?1049h\033[H") fmt.Println("Alternate screen buffer\n") s := "s" for i := 5; i > 0; i-- { if i == 1 { s = "" } fmt.Printf("\rgoing back in %d second%s...", i, s) time.Sleep(time.Secon...
parse value scrsize() with sd sw . parse value cursor(1,1) with curRow curCol . do original=1 for sd @line.original=scrRead(original,1, sw) end 'CLS' do sd % 2 ...
Please provide an equivalent version of this Go code in REXX.
package main import ( "go/build" "log" "path/filepath" "github.com/unixpickle/gospeech" "github.com/unixpickle/wav" ) const pkgPath = "github.com/unixpickle/gospeech" const input = "This is an example of speech synthesis." func main() { p, err := build.Import(pkgPath, ".", build.FindOnly) ...
parse arg t if t='' then exit dquote= '"' rate= 1 'NIRCMD' "speak text" dquote t dquote rate
Produce a functionally identical REXX code for the snippet given in Go.
package main import "fmt" type sBox [8][16]byte type gost struct { k87, k65, k43, k21 [256]byte enc []byte } func newGost(s *sBox) *gost { var g gost for i := range g.k87 { g.k87[i] = s[7][i>>4]<<4 | s[6][i&15] g.k65[i] = s[5][i>>4]<<4 | s[4][i&15] g.k43[i] = s...
numeric digits 12 @.0 = 4 10 9 2 13 8 0 14 6 11 1 12 7 15 5 3 @.1 = 14 11 4 12 6 13 15 10 2 3 8 1 0 7 5 9 @.2 = 5 8 1 13 10 3 4 ...
Port the provided Go code into REXX while preserving the original functionality.
package main import "fmt" const jobs = 12 type environment struct{ seq, cnt int } var ( env [jobs]environment seq, cnt *int ) func hail() { fmt.Printf("% 4d", *seq) if *seq == 1 { return } (*cnt)++ if *seq&1 != 0 { *seq = 3*(*seq) + 1 } else { *seq /= 2 ...
parse arg n . if n=='' | n=="," then n= 12 @.= do i=1 for n; @.i= i end w= length(n) do forever until @.0; @.0= 1 ...
Rewrite this program in REXX while keeping its functionality equivalent to the Go version.
package main import ( "fmt" "log" "os/exec" "time" ) func main() { out, err := exec.Command("xrandr", "-q").Output() if err != nil { log.Fatal(err) } fmt.Println(string(out)) time.Sleep(3 * time.Second) err = exec.Command("xrandr", "-s", "1024x768").Run() ...
parse arg cols lines . 'MODE' "CON: COLS="cols 'LINES='lines
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "log" "os/exec" "time" ) func main() { out, err := exec.Command("xrandr", "-q").Output() if err != nil { log.Fatal(err) } fmt.Println(string(out)) time.Sleep(3 * time.Second) err = exec.Command("xrandr", "-s", "1024x768").Run() ...
parse arg cols lines . 'MODE' "CON: COLS="cols 'LINES='lines
Generate an equivalent REXX version of this Go code.
package main import "C" import "fmt" func main() { for i := 0; i < 80*25; i++ { fmt.Print("A") } fmt.Println() conOut := C.GetStdHandle(C.STD_OUTPUT_HANDLE) info := C.CONSOLE_SCREEN_BUFFER_INFO{} pos := C.COORD{} C.GetConsoleScreenBufferInfo(conOut, &info) pos.X = info.srWin...
row = 6 col = 3 howMany = 1 stuff = scrRead(row, col, howMany) other = scrRead(40, 3, 1)
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import "fmt" func ts(n, p int) (R1, R2 int, ok bool) { powModP := func(a, e int) int { s := 1 for ; e > 0; e-- { s = s * a % p } return s } ls := func(a int) int { return powModP(a, (p-1)/2) } if ls(n) != 1 { ...
Numeric Digits 1000000 ttest ='[(10, 13), (56, 101), (1030, 10009), (44402, 100049)]' Do While pos('(',ttest)>0 Parse Var ttest '(' n ',' p ')' ttest r = tonelli(n, p) Say "n =" n "p =" p Say " roots :" r (p - r) End Exit legendre: Procedure Parse Arg a, p return pow(a, (p - 1) % 2, p) tonelli...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import "fmt" func ts(n, p int) (R1, R2 int, ok bool) { powModP := func(a, e int) int { s := 1 for ; e > 0; e-- { s = s * a % p } return s } ls := func(a int) int { return powModP(a, (p-1)/2) } if ls(n) != 1 { ...
Numeric Digits 1000000 ttest ='[(10, 13), (56, 101), (1030, 10009), (44402, 100049)]' Do While pos('(',ttest)>0 Parse Var ttest '(' n ',' p ')' ttest r = tonelli(n, p) Say "n =" n "p =" p Say " roots :" r (p - r) End Exit legendre: Procedure Parse Arg a, p return pow(a, (p - 1) % 2, p) tonelli...
Ensure the translated REXX code behaves exactly like the original Go snippet.
package main import "fmt" type Set func(float64) bool func Union(a, b Set) Set { return func(x float64) bool { return a(x) || b(x) } } func Inter(a, b Set) Set { return func(x float64) bool { return a(x) && b(x) } } func Diff(a, b Set) Set { return func(x float64) bool { return a(x) && !b(x) } } func...
call quertySet 1, 3, '[1,2)' call quertySet , , '[0,2) union (1,3)' call quertySet , , '[0,1) union (2,3]' call quertySet , , '[0,2] inter (1,3)' call quertySet , , '(1,2) ∩ (2,3]' call quertySet , , '[0,2) \ (1,3)' say; say center(' star...
Produce a functionally identical REXX code for the snippet given in Go.
package main import "fmt" type Set func(float64) bool func Union(a, b Set) Set { return func(x float64) bool { return a(x) || b(x) } } func Inter(a, b Set) Set { return func(x float64) bool { return a(x) && b(x) } } func Diff(a, b Set) Set { return func(x float64) bool { return a(x) && !b(x) } } func...
call quertySet 1, 3, '[1,2)' call quertySet , , '[0,2) union (1,3)' call quertySet , , '[0,1) union (2,3]' call quertySet , , '[0,2] inter (1,3)' call quertySet , , '(1,2) ∩ (2,3]' call quertySet , , '[0,2) \ (1,3)' say; say center(' star...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "unicode" ) var states = []string{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland",...
!='Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida, Georgia,', 'Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, ', 'Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, ...
Generate a REXX translation of this Go snippet without changing its computational steps.
package main import ( "fmt" "math/big" "strings" "time" ) func main() { start := time.Now() rd := []string{"22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"} one := big.NewInt(1) nine := big.NewInt(9) for i := big.NewInt(2); i.Cmp(nine) <= 0; i.Add(i, one) ...
numeric digits 100 parse arg n LO HI . if n=='' | n=="," then n= 10 if LO=='' | LO=="," then LO= 2 if HI=='' | HI=="," then HI= 9 do d=LO to HI...
Write a version of this Go function in REXX with identical behavior.
package main import ( "fmt" "math/big" "strings" "time" ) func main() { start := time.Now() rd := []string{"22", "333", "4444", "55555", "666666", "7777777", "88888888", "999999999"} one := big.NewInt(1) nine := big.NewInt(9) for i := big.NewInt(2); i.Cmp(nine) <= 0; i.Add(i, one) ...
numeric digits 100 parse arg n LO HI . if n=='' | n=="," then n= 10 if LO=='' | LO=="," then LO= 2 if HI=='' | HI=="," then HI= 9 do d=LO to HI...
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "fmt" "math" "math/big" "strings" ) func padovanRecur(n int) []int { p := make([]int, n) p[0], p[1], p[2] = 1, 1, 1 for i := 3; i < n; i++ { p[i] = p[i-2] + p[i-3] } return p } func padovanFloor(n int) []int { var p, s, t, u = new(big.Rat), new(bi...
numeric digits 40 parse arg n nF Ln cL . if n=='' | n=="," then n= 20 if nF=='' | nF=="," then nF= 64 if Ln=='' | Ln=="," then Ln= 10 if cL=='' | cL=="," then cL= 32 PR= 1.3247179572447...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "strconv" ) type maybe struct{ value *int } func (m maybe) bind(f func(p *int) maybe) maybe { return f(m.value) } func unit(p *int) maybe { return maybe{p} } func decrement(p *int) maybe { if p == nil { return unit(nil) } else { q := *p - 1 ...
call add 1, 2 call add 1, 2.0 call add 1, 2.0, -6 call add self, 2 exit 0 add: void= 'VOID'; f= do j=1 for arg() call bind( arg(j) ); f= f arg(j) end say ...
Generate a REXX translation of this Go snippet without changing its computational steps.
package main import ( "bufio" "flag" "fmt" "io" "log" "os" "strings" "unicode" ) func main() { log.SetFlags(0) log.SetPrefix("textonyms: ") wordlist := flag.String("wordlist", "wordlist", "file containing the list of words to check") flag.Parse() if flag.NArg() != 0 { flag.Usage() os.Exit(2) } t ...
parse arg iFID . if iFID=='' | iFID=="," then iFID='UNIXDICT.TXT' @.= 0 !.=; $.= alphabet= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' digitKey= 22233344455566677778889999 digKey= 0; ...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "math" "os" "strconv" "text/template" ) func sqr(x string) string { f, err := strconv.ParseFloat(x, 64) if err != nil { return "NA" } return strconv.FormatFloat(f*f, 'f', -1, 64) } func sqrt(x string) string { f, err := strconv.ParseFloat(x, 64) i...
parse arg N call squareIt N say result ' ◄───' exit 0 squareIt: return arg(1) ** 2
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "math" "os" "strconv" "text/template" ) func sqr(x string) string { f, err := strconv.ParseFloat(x, 64) if err != nil { return "NA" } return strconv.FormatFloat(f*f, 'f', -1, 64) } func sqrt(x string) string { f, err := strconv.ParseFloat(x, 64) i...
parse arg N call squareIt N say result ' ◄───' exit 0 squareIt: return arg(1) ** 2
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "log" "strconv" "strings" ) func check(err error) { if err != nil { log.Fatal(err) } } func canonicalize(cidr string) string { split := strings.Split(cidr, "/") dotted := split[0] size, err := strconv.Atoi(split[1]) check(err) ...
parse arg a . if a=='' | a=="," then a= '87.70.141.1/22' , '36.18.154.103/12' , '62.62.197.11/29' , '67.137.119.181/4' , '161.214.74.21/24' , ...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "log" "strconv" "strings" ) func check(err error) { if err != nil { log.Fatal(err) } } func canonicalize(cidr string) string { split := strings.Split(cidr, "/") dotted := split[0] size, err := strconv.Atoi(split[1]) check(err) ...
parse arg a . if a=='' | a=="," then a= '87.70.141.1/22' , '36.18.154.103/12' , '62.62.197.11/29' , '67.137.119.181/4' , '161.214.74.21/24' , ...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import ( "fmt" "math/big" ) func main() { var n, p int64 fmt.Printf("A sample of permutations from 1 to 12:\n") for n = 1; n < 13; n++ { p = n / 3 fmt.Printf("P(%d,%d) = %d\n", n, p, perm(big.NewInt(n), big.NewInt(p))) } fmt.Printf("\nA sample of combinations from 10 to 60:\n") for n = 10; n ...
numeric digits 100 do j=1 for 12; _= do k=1 for j _=_ 'P('j","k')='perm(j,k)" " end say strip(_) end say ...
Write the same algorithm in REXX as shown in this Go implementation.
package main import ( "fmt" "math/big" ) func main() { one := big.NewFloat(1) two := big.NewFloat(2) four := big.NewFloat(4) prec := uint(768) a := big.NewFloat(1).SetPrec(prec) g := new(big.Float).SetPrec(prec) t := new(big.Float).SetPrec(prec) u := new(big.Float).SetP...
parse arg d .; if d=='' | d=="," then d= 500 numeric digits d+5 z= 1/4; a= 1; g= sqrt(1/2) n= 1 do j=1 until a==old; old= a x= (a+g) * .5; g= sqrt(a*g) z= z - n*(x-a)**2; n= n+n; a= x end ...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import ( "fmt" "math/big" ) func main() { one := big.NewFloat(1) two := big.NewFloat(2) four := big.NewFloat(4) prec := uint(768) a := big.NewFloat(1).SetPrec(prec) g := new(big.Float).SetPrec(prec) t := new(big.Float).SetPrec(prec) u := new(big.Float).SetP...
parse arg d .; if d=='' | d=="," then d= 500 numeric digits d+5 z= 1/4; a= 1; g= sqrt(1/2) n= 1 do j=1 until a==old; old= a x= (a+g) * .5; g= sqrt(a*g) z= z - n*(x-a)**2; n= n+n; a= x end ...
Write the same algorithm in REXX as shown in this Go implementation.
package main import "fmt" func sieve(limit int) []int { var primes []int c := make([]bool, limit + 1) p := 3 p2 := p * p for p2 <= limit { for i := p2; i <= limit; i += 2 * p { c[i] = true } for ok := true; ok; ok = c[p] { p += 2 } ...
parse arg a if a='' | a="," then a= '500 -500 -1000 -2000 -4000 -8000 -16000' , '-32000 -64000 -128000 -512000 -1024000' do k=1 for words(a); H=word(a, k) neg= H<1 H= abs(H) ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "math/big" "time" "github.com/jbarham/primegen.go" ) func main() { start := time.Now() pg := primegen.New() var i uint64 p := big.NewInt(1) tmp := new(big.Int) for i <= 9 { fmt.Printf("primorial(%v) = %v\n", i, p) i++ p = p.Mul(p, tmp.SetUint64(pg.Next())) } for _, j := ...
parse arg N H . if N=='' | N==',' then N= 10 if H=='' | H==',' then H= 100000 numeric digits 600000 w= length( commas( digits() ) ) @.=.; @.0= 1; @.1= 2; @.2= 3; @.3= 5; @.4= 7; @.5= 11; @.6= 13...
Write a version of this Go function in REXX with identical behavior.
package main import ( "fmt" "math/big" "strings" ) var zero = new(big.Int) var one = big.NewInt(1) func toEgyptianRecursive(br *big.Rat, fracs []*big.Rat) []*big.Rat { if br.Num().Cmp(zero) == 0 { return fracs } iquo := new(big.Int) irem := new(big.Int) iquo.QuoRem(br.Denom(),...
parse arg fract '' -1 t; z=$egyptF(fract) if t\==. then say fract ' ───► ' z return z $egyptF: parse arg z 1 zn '/' zd,,$; if zd=='' then zd=1 if z='' then call erx "no fraction was specified." if zd==0 then call erx "denominator can'...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "math/big" "strings" ) var zero = new(big.Int) var one = big.NewInt(1) func toEgyptianRecursive(br *big.Rat, fracs []*big.Rat) []*big.Rat { if br.Num().Cmp(zero) == 0 { return fracs } iquo := new(big.Int) irem := new(big.Int) iquo.QuoRem(br.Denom(),...
parse arg fract '' -1 t; z=$egyptF(fract) if t\==. then say fract ' ───► ' z return z $egyptF: parse arg z 1 zn '/' zd,,$; if zd=='' then zd=1 if z='' then call erx "no fraction was specified." if zd==0 then call erx "denominator can'...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "fmt" "math" ) type cFunc func(float64) float64 func main() { fmt.Println("integral:", glq(math.Exp, -3, 3, 5)) } func glq(f cFunc, a, b float64, n int) float64 { x, w := glqNodes(n, f) show := func(label string, vs []float64) { fmt.Printf("%8s: ", label) ...
* 31.10.2013 Walter Pachl Translation from REXX (from PL/I) * using ooRexx' rxmath package * which limits the precision to 16 digits *--------------------------------------------------------------------*/ prec=60 Numeric Digits prec epsilon=1/10**prec pi=3.14159265358...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import "fmt" var grid []byte var w, h, last int var cnt int var next [4]int var dir = [4][2]int{{0, -1}, {-1, 0}, {0, 1}, {1, 0}} func walk(y, x int) { if y == 0 || y == h || x == 0 || x == w { cnt += 2 return } t := y*(w+1) + x grid[t]++ grid[last-t]++ for i, d :...
numeric digits 20 parse arg N .; if N=='' | N=="," then N= 10 dir.= 0; dir.0.1= -1; dir.1.0= -1; dir.2.1= 1; dir.3.0= 1 do y=2 to N; say do x=1 for y; if x//2 & y//2 then iterate z= solve(y,x,1); _= comm...
Produce a functionally identical REXX code for the snippet given in Go.
package main import "fmt" var grid []byte var w, h, last int var cnt int var next [4]int var dir = [4][2]int{{0, -1}, {-1, 0}, {0, 1}, {1, 0}} func walk(y, x int) { if y == 0 || y == h || x == 0 || x == w { cnt += 2 return } t := y*(w+1) + x grid[t]++ grid[last-t]++ for i, d :...
numeric digits 20 parse arg N .; if N=='' | N=="," then N= 10 dir.= 0; dir.0.1= -1; dir.1.0= -1; dir.2.1= 1; dir.3.0= 1 do y=2 to N; say do x=1 for y; if x//2 & y//2 then iterate z= solve(y,x,1); _= comm...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "math/big" ) func commatize(n uint64) string { s := fmt.Sprintf("%d", n) le := len(s) for i := le - 3; i >= 1; i -= 3 { s = s[0:i] + "," + s[i:] } return s } func main() { var z big.Int var cube1, cube2, cube100k, diff uint64 cubans := make(...
numeric digits 20 parse arg N . if N=='' | N=="," then N= 200 Nth= N<0; N= abs(N) @.=0; @.0=1; @.2=1; @.3=1; @.4=1; @.5=1; @.6=1; @.8=1 sw= linesize() - 1; if sw<1 then sw= 79 w=12; ...
Change the programming language of this snippet from Go to REXX without modifying what it does.
package main import ( "fmt" "image" "image/color" "image/draw" "image/gif" "log" "math" "math/rand" "os" "time" ) var bwPalette = color.Palette{ color.Transparent, color.White, color.RGBA{R: 0xff, A: 0xff}, color.RGBA{G: 0xff, A: 0xff}, color.RGBA{B: 0xff, A: 0xff}, } func main() { const ( width ...
parse value scrsize() with sd sw . sw= sw - 2 sd= sd - 4 parse arg pts chr seed . if pts=='' | pts=="," then pts= 1000000 if chr=='' | chr=="," then chr= '∙' if datatype(seed,'W...
Rewrite this program in REXX while keeping its functionality equivalent to the Go version.
package main import ( "fmt" "image" "image/color" "image/draw" "image/gif" "log" "math" "math/rand" "os" "time" ) var bwPalette = color.Palette{ color.Transparent, color.White, color.RGBA{R: 0xff, A: 0xff}, color.RGBA{G: 0xff, A: 0xff}, color.RGBA{B: 0xff, A: 0xff}, } func main() { const ( width ...
parse value scrsize() with sd sw . sw= sw - 2 sd= sd - 4 parse arg pts chr seed . if pts=='' | pts=="," then pts= 1000000 if chr=='' | chr=="," then chr= '∙' if datatype(seed,'W...
Write the same algorithm in REXX as shown in this Go implementation.
package main import ( "fmt" "sort" "strconv" ) var games = [6]string{"12", "13", "14", "23", "24", "34"} var results = "000000" func nextResult() bool { if results == "222222" { return false } res, _ := strconv.ParseUint(results, 3, 32) results = fmt.Sprintf("%06s", strconv.Format...
results = '000000' games = '12 13 14 23 24 34' points.=0 records.=0 Do Until nextResult(results)=0 records.=0 Do i=1 To 6 r=substr(results,i,1) g=word(games,i); Parse Var g g1 +1 g2 Select When r='2' Then records.g1=records.g1+3 When r='1' Th...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "strings" ) var input = "3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3" var opa = map[string]struct { prec int rAssoc bool }{ "^": {4, true}, "*": {3, false}, "/": {3, false}, "+": {2, false}, "-": {2, false}, } func main() { fmt.Println("infix: ", input) f...
parse arg x if x='' then x= '3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3' ox=x x='(' space(x) ") " #=words(x) do i=1 for #; @.i=word(x, i) end tell=1 ...
Generate an equivalent REXX version of this Go code.
package main import ( "fmt" "math" ) func main() { fmt.Println(noise(3.14, 42, 7)) } func noise(x, y, z float64) float64 { X := int(math.Floor(x)) & 255 Y := int(math.Floor(y)) & 255 Z := int(math.Floor(z)) & 255 x -= math.Floor(x) y -= math.Floor(y) z -= math.Floor(z) u := fa...
_= 97a0895b5a0f830dc95f6035c2e907e18c24671e458e086325f0150a17be0694f778ea4b001ac53e5efcdbcb75230b2039b12158ed953857ae147d88aba844af, ||4aa547868b301ba64d929ee7536fe57a3cd385e6dc695c29372ef528f4668f3641193fa101d85049d14c84bbd05912a9c8c4878274bc9f56a4646dc6adba0340, ||34d9e2fa7c7b05ca2693767eff5255d4cfce3be32f103a11b6...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "fmt" "os/exec" ) func main() { synthType := "sine" duration := "5" frequency := "440" cmd := exec.Command("play", "-n", "synth", duration, synthType, frequency) err := cmd.Run() if err != nil { fmt.Println(err) } }
parse arg freq time . if freq=='' | freq=="," then freq= 880 if time=='' | time=="," then time= 5 call sound freq, time exit 0
Produce a functionally identical REXX code for the snippet given in Go.
package astar import "container/heap" type Node interface { To() []Arc Heuristic(from Node) int } type Arc struct { To Node Cost int } type rNode struct { n Node from Node l int g int f int fx int } type openHeap []*rNode func...
parse arg N sCol sRow . if N=='' | N=="," then N=8 if sCol=='' | sCol=="," then sCol=1 if sRow=='' | sRow=="," then sRow=1 beg= '─0─' o.=.; p.=0 times=0 ...