Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Generate an equivalent REXX version of this Go code.
package 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 ...
Ensure the translated REXX code behaves exactly like the original Go snippet.
package main import ( "fmt" "math/big" "strings" ) func factorial(n int64) *big.Int { var z big.Int return z.MulRange(1, n) } var one = big.NewInt(1) var three = big.NewInt(3) var six = big.NewInt(6) var ten = big.NewInt(10) var seventy = big.NewInt(70) func almkvistGiullera(n int64, print bool)...
numeric digits length( pi() ) + length(.); w= 102 say $( , 3) $( , w%2) $('power', 5) $( , w) say $('N', 3) $('integer term', w%2) $('of 10', 5) $('Nth term', w) say $( , 3, "─") $( , w%2, "─") $( ...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "math/big" "strings" ) func factorial(n int64) *big.Int { var z big.Int return z.MulRange(1, n) } var one = big.NewInt(1) var three = big.NewInt(3) var six = big.NewInt(6) var ten = big.NewInt(10) var seventy = big.NewInt(70) func almkvistGiullera(n int64, print bool)...
numeric digits length( pi() ) + length(.); w= 102 say $( , 3) $( , w%2) $('power', 5) $( , w) say $('N', 3) $('integer term', w%2) $('of 10', 5) $('Nth term', w) say $( , 3, "─") $( , w%2, "─") $( ...
Write the same code in REXX as shown below in Go.
package main import ( "flag" "fmt" "math" "math/big" "os" ) var maxRev = big.NewInt(math.MaxUint64 / 10) var ten = big.NewInt(10) func reverseInt(v *big.Int, result *big.Int) *big.Int { if v.Cmp(maxRev) <= 0 { result.SetUint64(reverseUint64(v.Uint64())) } else { if true { s := reverseString(...
parse arg high limit . if high='' | high=="," then high= 10000 if limit='' | limit=="," then limit= 500 numeric digits limit % 2 T.= 0; @.= T.; #.=@.; w= length(high) $= do j=1 for hig...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "flag" "fmt" "math" "math/big" "os" ) var maxRev = big.NewInt(math.MaxUint64 / 10) var ten = big.NewInt(10) func reverseInt(v *big.Int, result *big.Int) *big.Int { if v.Cmp(maxRev) <= 0 { result.SetUint64(reverseUint64(v.Uint64())) } else { if true { s := reverseString(...
parse arg high limit . if high='' | high=="," then high= 10000 if limit='' | limit=="," then limit= 500 numeric digits limit % 2 T.= 0; @.= T.; #.=@.; w= length(high) $= do j=1 for hig...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "math/big" ) type mTerm struct { a, n, d int64 } var testCases = [][]mTerm{ {{1, 1, 2}, {1, 1, 3}}, {{2, 1, 3}, {1, 1, 7}}, {{4, 1, 5}, {-1, 1, 239}}, {{5, 1, 7}, {2, 3, 79}}, {{1, 1, 2}, {1, 1, 5}, {1, 1, 8}}, {{4, 1, 5}, {-1, 1, 70}, {1, 1, 99}}, ...
* 09.04.2014 Walter Pachl the REXX solution adapted for ooRexx * which provides a function package rxMath *--------------------------------------------------------------------*/ Numeric Digits 16 Numeric Fuzz 3; pi=rxCalcpi(); a.='' a.1 = 'pi/4 = rxCalcarctan(1/2,16,'R') + rxC...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import ( "fmt" "math/big" ) type mTerm struct { a, n, d int64 } var testCases = [][]mTerm{ {{1, 1, 2}, {1, 1, 3}}, {{2, 1, 3}, {1, 1, 7}}, {{4, 1, 5}, {-1, 1, 239}}, {{5, 1, 7}, {2, 3, 79}}, {{1, 1, 2}, {1, 1, 5}, {1, 1, 8}}, {{4, 1, 5}, {-1, 1, 70}, {1, 1, 99}}, ...
* 09.04.2014 Walter Pachl the REXX solution adapted for ooRexx * which provides a function package rxMath *--------------------------------------------------------------------*/ Numeric Digits 16 Numeric Fuzz 3; pi=rxCalcpi(); a.='' a.1 = 'pi/4 = rxCalcarctan(1/2,16,'R') + rxC...
Translate this program into REXX but keep the logic exactly as in Go.
package main import "C" import ( "fmt" "os" "os/exec" ) var conOut = C.GetStdHandle(C.STD_OUTPUT_HANDLE) func setCursor(p C.COORD) { C.SetConsoleCursorPosition(conOut, p) } func cls() { cmd := exec.Command("cmd", "/c", "cls") cmd.Stdout = os.Stdout cmd.Run() } func getInput(row, col, w...
parse arg row col len . if row=='' | row=="," then row= 3 if col=='' | col=="," then col= 5 if len=='' | len=="," then len= 8 parse upper version v . if v\=='REXX/PERSONAL' then do; say ...
Write a version of this Go function in REXX with identical behavior.
package main import "C" import ( "fmt" "os" "os/exec" ) var conOut = C.GetStdHandle(C.STD_OUTPUT_HANDLE) func setCursor(p C.COORD) { C.SetConsoleCursorPosition(conOut, p) } func cls() { cmd := exec.Command("cmd", "/c", "cls") cmd.Stdout = os.Stdout cmd.Run() } func getInput(row, col, w...
parse arg row col len . if row=='' | row=="," then row= 3 if col=='' | col=="," then col= 5 if len=='' | len=="," then len= 8 parse upper version v . if v\=='REXX/PERSONAL' then do; say ...
Please provide an equivalent version of this Go code in REXX.
package main import "fmt" const ( msg = "a Top Secret secret" key = "this is my secret key" ) func main() { var z state z.seed(key) fmt.Println("Message: ", msg) fmt.Println("Key Β : ", key) fmt.Println("XOR Β : ", z.vernam(msg)) } type state struct { aa, bb, cc uint32 mm ...
* 24.07.2014 Walter Pachl translated from Pascal * extend with decryption (following Pascal) * 25.07.2014 WP changed i+=8 to I=I+8 (courtesy GS) * 26.07-2014 WP removed extraneous semicolons *--------------------------------------------------------------------*/ Numeric Digits 32 aa=0 bb=0 cc=0 mm.=0 randcn...
Write the same algorithm in REXX as shown in this Go implementation.
package main import "fmt" const ( msg = "a Top Secret secret" key = "this is my secret key" ) func main() { var z state z.seed(key) fmt.Println("Message: ", msg) fmt.Println("Key Β : ", key) fmt.Println("XOR Β : ", z.vernam(msg)) } type state struct { aa, bb, cc uint32 mm ...
* 24.07.2014 Walter Pachl translated from Pascal * extend with decryption (following Pascal) * 25.07.2014 WP changed i+=8 to I=I+8 (courtesy GS) * 26.07-2014 WP removed extraneous semicolons *--------------------------------------------------------------------*/ Numeric Digits 32 aa=0 bb=0 cc=0 mm.=0 randcn...
Generate a REXX translation of this Go snippet without changing its computational steps.
package main import "C" import ( "fmt" "os" "os/exec" ) var conOut = C.GetStdHandle(C.STD_OUTPUT_HANDLE) func setCursor(p C.COORD) { C.SetConsoleCursorPosition(conOut, p) } func cls() { cmd := exec.Command("cmd", "/c", "cls") cmd.Stdout = os.Stdout cmd.Run() } func getInput(row, col, w...
parse arg row col len . if row=='' | row=="," then row= 3 if col=='' | col=="," then col= 5 if len=='' | len=="," then len= 8 parse upper version v . if v\=='REXX/PERSONAL' then do; say ...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import ( "fmt" "math" ) func steepestDescent(x []float64, alpha, tolerance float64) { n := len(x) g0 := g(x) fi := gradG(x) delG := 0.0 for i := 0; i < n; i++ { delG += fi[i] * fi[i] } delG = math.Sqrt(delG) b := alpha / delG for delG...
numeric digits (length( e() ) - length(.) ) % 2 tolerance= 1e-30 alpha= 0.1 x.0= 0.1; x.1= -1 say center(' testing for the steepest descent method ', 79, "═") call steepestD say 'The minimum is at: x[0]=' format(x.0,,9) "...
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import ( "fmt" "math/rand" ) func MRPerm(q, n int) []int { p := ident(n) var r int for n > 0 { q, r = q/n, q%n n-- p[n], p[r] = p[r], p[n] } return p } func ident(n int) []int { p := make([]int, n) for i := range p { p[i] = i } ...
parse arg N y seed . if N=='' | N=="," then N= 4 if y=='' | y=="," then y= 17 if datatype(seed,'W') then call random ,,seed permutes= permSets(N) w= length(permutes) @.= do p=0 f...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "math/rand" ) func MRPerm(q, n int) []int { p := ident(n) var r int for n > 0 { q, r = q/n, q%n n-- p[n], p[r] = p[r], p[n] } return p } func ident(n int) []int { p := make([]int, n) for i := range p { p[i] = i } ...
parse arg N y seed . if N=='' | N=="," then N= 4 if y=='' | y=="," then y= 17 if datatype(seed,'W') then call random ,,seed permutes= permSets(N) w= length(permutes) @.= do p=0 f...
Change the following Go code into REXX without altering its purpose.
package main import ( "fmt" "math" "time" ) const ld10 = math.Ln2 / math.Ln10 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 p(L, n uint64) uint64 { i := L digits :=...
parse arg L n b . if L=='' | L=="," then L= 12 if n=='' | n=="," then n= 1 if b=='' | b=="," then b= 2 LL= length(L) fd= left(L, 1) fr= substr(L, 2) ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "math" "time" ) const ld10 = math.Ln2 / math.Ln10 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 p(L, n uint64) uint64 { i := L digits :=...
parse arg L n b . if L=='' | L=="," then L= 12 if n=='' | n=="," then n= 1 if b=='' | b=="," then b= 2 LL= length(L) fd= left(L, 1) fr= substr(L, 2) ...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" big "github.com/ncw/gmp" "sort" ) var ( one = new(big.Int).SetUint64(1) two = new(big.Int).SetUint64(2) three = new(big.Int).SetUint64(3) ) func pierpont(ulim, vlim int, first bool) []*big.Int { p := new(big.Int) p2 := new(big.Int).Set(one) p3 := ne...
parse arg n . if n=='' | n=="," then n= 50 numeric digits n big= copies(9, digits() ) @.= '2nd'; @.1= '1st' do t=1 to -1 by -2; usum= 0; vsum= 0; s= 0 #...
Change the programming language of this snippet from Go to REXX without modifying what it does.
package main import ( "fmt" "log" "math/big" ) var ( primes []*big.Int smallPrimes []int ) func init() { two := big.NewInt(2) three := big.NewInt(3) p521 := big.NewInt(521) p29 := big.NewInt(29) primes = append(primes, two) smallPrimes = append(smallPrimes, 2) fo...
numeric digits 200 parse arg LOx HIx LOn HIn . if LOx=='' | LOx=="," then LOx= 1 if HIx=='' | HIx=="," then HIx= LOx + 24 if LOn=='' | LOn=="," then LOn= 2 if HIn=='' | HIn=="," then HIn= LOn + 27 call genP HIn ...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "log" ) var ( primes = sieve(100000) foundCombo = false ) func sieve(limit uint) []uint { primes := []uint{2} c := make([]bool, limit+1) p := uint(3) for { p2 := p * p if p2 > limit { break } for i := p2...
parse arg what do until what=='' parse var what x n what; parse var x x '-' y parse var n n '-' m if x=='' | x=="," then x= 19 if y=='' | y=="," then y= x if n=='' | n==",...
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() { limit := 100 last := 12 unsigned := true s1 := make([][]*big.Int, limit+1) for n := 0; n <= limit; n++ { s1[n] = make([]*big.Int, limit+1) for k := 0; k <= limit; k++ { s1[n][k] = new(big.Int) } ...
parse arg lim . if lim=='' | lim=="," then lim= 12 olim= lim lim= abs(lim) numeric digits max(9, 2*lim) @.=; @.0.0= 1 do n=0 for...
Write a version of this Go function in REXX with identical behavior.
package main import ( "fmt" "math/big" ) func main() { limit := 100 last := 12 unsigned := true s1 := make([][]*big.Int, limit+1) for n := 0; n <= limit; n++ { s1[n] = make([]*big.Int, limit+1) for k := 0; k <= limit; k++ { s1[n][k] = new(big.Int) } ...
parse arg lim . if lim=='' | lim=="," then lim= 12 olim= lim lim= abs(lim) numeric digits max(9, 2*lim) @.=; @.0.0= 1 do n=0 for...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "math" ) type point struct{ x, y float64 } func RDP(l []point, Ξ΅ float64) []point { x := 0 dMax := -1. last := len(l) - 1 p1 := l[0] p2 := l[last] x21 := p2.x - p1.x y21 := p2.y - p1.y for i, p := range l[1:last] { if d := math.Abs(y21*p.x -...
parse arg epsilon pts if epsilon='' | epsilon="," then epsilon= 1 if pts='' then pts= '(0,0) (1,0.1) (2,-0.1) (3,5) (4,6) (5,7) (6,8.1) (7,9) (8,9) (9,9)' pts= space(pts) say ' error threshold: ' epsilon say ' points spe...
Convert this Go snippet to REXX and keep its semantics consistent.
package main import ( "fmt" "math" ) type point struct{ x, y float64 } func RDP(l []point, Ξ΅ float64) []point { x := 0 dMax := -1. last := len(l) - 1 p1 := l[0] p2 := l[last] x21 := p2.x - p1.x y21 := p2.y - p1.y for i, p := range l[1:last] { if d := math.Abs(y21*p.x -...
parse arg epsilon pts if epsilon='' | epsilon="," then epsilon= 1 if pts='' then pts= '(0,0) (1,0.1) (2,-0.1) (3,5) (4,6) (5,7) (6,8.1) (7,9) (8,9) (9,9)' pts= space(pts) say ' error threshold: ' epsilon say ' points spe...
Translate the given Go code snippet into REXX without altering its behavior.
package main import "fmt" type vector []float64 func (v vector) add(v2 vector) vector { r := make([]float64, len(v)) for i, vi := range v { r[i] = vi + v2[i] } return r } func (v vector) sub(v2 vector) vector { r := make([]float64, len(v)) for i, vi := range v { r[i] = vi - v...
v=.vector~new(12,-3); Say "v=.vector~new(12,-3) =>" v~print v~ab(1,1,6,4); Say "v~ab(1,1,6,4) =>" v~print v~al(45,2); Say "v~al(45,2) =>" v~print w=v~'+'(v); Say "w=v~'+'(v) =>" w~print x=v~'-'(w); Say "x=v~'-'(w) =>" x~print y=x~'*'(3); ...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "math" ) const bCoeff = 7 type pt struct{ x, y float64 } func zero() pt { return pt{math.Inf(1), math.Inf(1)} } func is_zero(p pt) bool { return p.x > 1e20 || p.x < -1e20 } func neg(p pt) pt { return pt{p.x, -p.y} } func dbl(p pt) pt { if is_zero(p) { r...
numeric digits 100 a= func(1) ; say ' a = ' show(a) b= func(2) ; say ' b = ' show(b) c= add(a, b) ; say ' c = (a+b) =' show(c) d= neg(c) ...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "math" ) const bCoeff = 7 type pt struct{ x, y float64 } func zero() pt { return pt{math.Inf(1), math.Inf(1)} } func is_zero(p pt) bool { return p.x > 1e20 || p.x < -1e20 } func neg(p pt) pt { return pt{p.x, -p.y} } func dbl(p pt) pt { if is_zero(p) { r...
numeric digits 100 a= func(1) ; say ' a = ' show(a) b= func(2) ; say ' b = ' show(b) c= add(a, b) ; say ' c = (a+b) =' show(c) d= neg(c) ...
Generate a REXX translation of this Go snippet without changing its computational steps.
package main import ( "fmt" "math" ) type cheb struct { c []float64 min, max float64 } func main() { fn := math.Cos c := newCheb(0, 1, 10, 10, fn) fmt.Println("coefficients:") for _, c := range c.c { fmt.Printf("% .15f\n", c) } fmt.Println("\nx computed a...
numeric digits length( pi() ) - length(.) parse arg a b N . if a=='' | a=="," then a= 0 if b=='' | b=="," then b= 1 if N=='' | N=="," then N= 10 fac= 2 / N; pin= pi / N Dma= (b-a) / 2 ...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "math" ) type cheb struct { c []float64 min, max float64 } func main() { fn := math.Cos c := newCheb(0, 1, 10, 10, fn) fmt.Println("coefficients:") for _, c := range c.c { fmt.Printf("% .15f\n", c) } fmt.Println("\nx computed a...
numeric digits length( pi() ) - length(.) parse arg a b N . if a=='' | a=="," then a= 0 if b=='' | b=="," then b= 1 if N=='' | N=="," then N= 10 fac= 2 / N; pin= pi / N Dma= (b-a) / 2 ...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "fmt" "sort" "strings" ) const stx = "\002" const etx = "\003" func bwt(s string) (string, error) { if strings.Index(s, stx) >= 0 || strings.Index(s, etx) >= 0 { return "", fmt.Errorf("String can't contain STX or ETX") } s = stx + s + etx le := len(s) tab...
$.= parse arg $.1 if $.1='' then do; $.1= "banana" $.2= "BANANA" $.3= "appellee" $.4= "dogwood" $.5= "TO BE OR NOT TO BE OR WANT TO BE O...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "sort" "strings" ) const stx = "\002" const etx = "\003" func bwt(s string) (string, error) { if strings.Index(s, stx) >= 0 || strings.Index(s, etx) >= 0 { return "", fmt.Errorf("String can't contain STX or ETX") } s = stx + s + etx le := len(s) tab...
$.= parse arg $.1 if $.1='' then do; $.1= "banana" $.2= "BANANA" $.3= "appellee" $.4= "dogwood" $.5= "TO BE OR NOT TO BE OR WANT TO BE O...
Generate an equivalent REXX version of this Go code.
package main import "fmt" type vList struct { base *vSeg offset int } type vSeg struct { next *vSeg ele []vEle } type vEle string func (v vList) index(i int) (r vEle) { if i >= 0 { i += v.offset for sg := v.base; sg != nil; sg = sg.next { if i < len(sg.ele...
-- show how to use the queue class q = .queue~of(1, 2, 3, 4) -- show indexed access to item say q[4] -- update an item q[2] = "Fred" -- show update and that other indexes are unchanged say q[2] q[4] -- push an item on the front and show the change in positions q~push("Mike") say q[1] q[2] q[4] -- pop an item and s...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import "fmt" type vList struct { base *vSeg offset int } type vSeg struct { next *vSeg ele []vEle } type vEle string func (v vList) index(i int) (r vEle) { if i >= 0 { i += v.offset for sg := v.base; sg != nil; sg = sg.next { if i < len(sg.ele...
-- show how to use the queue class q = .queue~of(1, 2, 3, 4) -- show indexed access to item say q[4] -- update an item q[2] = "Fred" -- show update and that other indexes are unchanged say q[2] q[4] -- push an item on the front and show the change in positions q~push("Mike") say q[1] q[2] q[4] -- pop an item and s...
Write the same algorithm in REXX as shown in this Go implementation.
package main import ( "fmt" "math/rand" "time" ) func reverse(s []int) { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } } func riffle(deck []int, iterations int) []int { le := len(deck) pile := make([]int, le) copy(pile, deck) for i := 0; i < i...
call create; call show 'new deck' call create; call riffle 1 call show 'riffle shuffle' call create; call overhand 1/5 call show 'overhand shuffle' call create; call barnYard 13 ca...
Generate an equivalent REXX version of this Go code.
package main import ( "fmt" "math/rand" "time" ) func reverse(s []int) { for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 { s[i], s[j] = s[j], s[i] } } func riffle(deck []int, iterations int) []int { le := len(deck) pile := make([]int, le) copy(pile, deck) for i := 0; i < i...
call create; call show 'new deck' call create; call riffle 1 call show 'riffle shuffle' call create; call overhand 1/5 call show 'overhand shuffle' call create; call barnYard 13 ca...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import ( "fmt" "math/big" ) func bernoulli(n uint) *big.Rat { a := make([]big.Rat, n+1) z := new(big.Rat) for m := range a { a[m].SetFrac64(1, int64(m+1)) for j := m; j >= 1; j-- { d := &a[j-1] d.Mul(z.SetInt64(int64(j)), d.Sub(d, &a[j])) ...
Numeric Digits 100 Do r=0 To 20 ra=r-1 If r=0 Then f.r.1=1 Else Do rsum=0 Do c=2 To r+1 ca=c-1 f.r.c=fdivide(fmultiply(f.ra.ca,r),c) rsum=fsum(rsum,f.r.c) End f.r.1=fsubtract(1,rsum) End End Do r=0 To 9 ol='' Do c=1 To r+1 ol=ol right(f.r.c,5) End Say ol...
Translate the given Go code snippet into REXX without altering its behavior.
package main import ( "fmt" "math/big" ) const branches = 4 const nMax = 500 var rooted, unrooted [nMax + 1]big.Int var c [branches]big.Int var tmp = new(big.Int) var one = big.NewInt(1) func tree(br, n, l, sum int, cnt *big.Int) { for b := br + 1; b <= branches; b++ { sum += n if sum > ...
parse arg nodes . if nodes=='' | nodes=="," then nodes= 100 rooted. = 0; rooted.0= 1; rooted.1= 1 unrooted. = 0; unrooted.0= 1; unrooted.1= 1 numeric digits max(9, nodes % 2) w= length(nodes) say right(0, w) u...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "math/big" ) const branches = 4 const nMax = 500 var rooted, unrooted [nMax + 1]big.Int var c [branches]big.Int var tmp = new(big.Int) var one = big.NewInt(1) func tree(br, n, l, sum int, cnt *big.Int) { for b := br + 1; b <= branches; b++ { sum += n if sum > ...
parse arg nodes . if nodes=='' | nodes=="," then nodes= 100 rooted. = 0; rooted.0= 1; rooted.1= 1 unrooted. = 0; unrooted.0= 1; unrooted.1= 1 numeric digits max(9, nodes % 2) w= length(nodes) say right(0, w) u...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "strings" ) type pair struct{ first, second string } var ( fStrs = []pair{{"MAC", "MCC"}, {"KN", "N"}, {"K", "C"}, {"PH", "FF"}, {"PF", "FF"}, {"SCH", "SSS"}} lStrs = []pair{{"EE", "Y"}, {"IE", "Y"}, {"DT", "D"}, {"RT", "D"}, {"RD", "D"}, {"NT", "D"}, {"ND"...
return strip( left(key, 6) )
Generate a REXX translation of this Go snippet without changing its computational steps.
package main import ( "fmt" "strings" ) type pair struct{ first, second string } var ( fStrs = []pair{{"MAC", "MCC"}, {"KN", "N"}, {"K", "C"}, {"PH", "FF"}, {"PF", "FF"}, {"SCH", "SSS"}} lStrs = []pair{{"EE", "Y"}, {"IE", "Y"}, {"DT", "D"}, {"RT", "D"}, {"RD", "D"}, {"NT", "D"}, {"ND"...
return strip( left(key, 6) )
Write a version of this Go function in REXX with identical behavior.
package main import ( "log" "github.com/jtblin/go-ldap-client" ) func main() { client := &ldap.LDAPClient{ Base: "dc=example,dc=com", Host: "ldap.example.com", Port: 389, GroupFilter: "(memberUid=%s)", } defer client.Close() err := client.Co...
options replace format comments java crossref symbols binary import org.apache.directory.ldap.client.api.LdapConnection import org.apache.directory.ldap.client.api.LdapNetworkConnection import org.apache.directory.shared.ldap.model.cursor.EntryCursor import org.apache.directory.shared.ldap.model.entry.Entry import or...
Generate an equivalent REXX version of this Go code.
package main import ( "fmt" "sort" ) 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 } for { p += 2 if !c[p] { break } } ...
parse arg N . if N=='' | N=="," then N= 1000000 Np= N+1; w= length(N-1) H= N* (2**max(4, (w%2+1) ) ) @.= . #= 1 do j=3 by 2; ...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "log" "os" "strconv" ) type tree uint64 var ( list []tree offset = [32]uint{1: 1} ) func add(t tree) { list = append(list, 1|t<<1) } func show(t tree, l uint) { for ; l > 0; t >>= 1 { l-- var paren byte if (t & 1) != 0 { ...
parse arg N . if N=='' | N=="," then N=5 if N>5 then do; say N "isn't supported for this program at this time."; exit 13; end nn= N + N - 1 numeric digits 200 numeric digits max(9, 1 + le...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "fmt" "log" "os" "strconv" "strings" ) const luckySize = 60000 var luckyOdd = make([]int, luckySize) var luckyEven = make([]int, luckySize) func init() { for i := 0; i < luckySize; i++ { luckyOdd[i] = i*2 + 1 luckyEven[i] = i*2 + 2 } } func filterLu...
parse arg bot top func _ . if func=='' then func= 'lucky' s= left('s', bot\==top & top\==",") say func 'number's":" bot top '───►' $lucky(bot, top, func, _) exit 0 $lucky: arg x,y,f,?; if y=='' | y=="," then ...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "math" "math/rand" "strings" ) func norm2() (s, c float64) { r := math.Sqrt(-2 * math.Log(rand.Float64())) s, c = math.Sincos(2 * math.Pi * rand.Float64()) return s * r, c * r } func main() { const ( n = 10000 bins = 12 sig =...
numeric digits 20 parse arg n seed . if n=='' | n=="," then n= 10000 if datatype(seed, 'W') then call random ,,seed call pi do g=1 for n; #.g= sqrt( -2 * ln( rand() ) ) * c...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "github.com/shabbyrobe/go-num" "strings" "time" ) func b10(n int64) { if n == 1 { fmt.Printf("%4d: %28s Β %-24d\n", 1, "1", 1) return } n1 := n + 1 pow := make([]int64, n1) val := make([]int64, n1) var count, ten, x int64 = 0, 1, 1 ...
numeric digits 30; w= length( commas( copies(1, digits()))) parse arg list if list=='' then list= 1..10 95..105 297 say center(' N ', 9, "─") center(' B10 ', w, "─") center(' multiplier ', w, "─") do i=1 for words(list) z= word(list, i); LO= z; HI= z if po...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import "fmt" func divisors(n int) []int { divs := []int{1} divs2 := []int{} for i := 2; i*i <= n; i++ { if n%i == 0 { j := n / i divs = append(divs, i) if i != j { divs2 = append(divs2, j) } } } for i := l...
parse arg n cols . if n=='' | n=="," then n= 25 if cols=='' | cols=="," then cols= 10 w= 10 if cols>0 then say ' index β”‚'center(' weird numbers', 1 + cols*(w+1) ) if cols>0 then say '───────┼'center("" ...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import ( "fmt" "log" "math/big" "strings" ) type result struct { name string size int start int end int } func (r result) String() string { return fmt.Sprintf("%-7s %2d %3d %3d", r.name, r.size, r.start, r.end) } func validate(diagram string) []string { ...
numeric digits 100 er= '***error*** illegal input txt' parse arg iFID test . if iFID=='' | iFID=="," then iFID= 'ASCIIART.TXT' if test=='' | test=="," then test= 'cafe8050800000808080000a' w= 0; wb= 0; !.= 0; ...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "fmt" "math" "math/big" ) var bi = new(big.Int) func isPrime(n int) bool { bi.SetUint64(uint64(n)) return bi.ProbablyPrime(0) } func generateSmallPrimes(n int) []int { primes := make([]int, n) primes[0] = 2 for i, count := 3, 1; count < n; i += 2 { if is...
parse arg N . if N=='' | N=="," then N= 15 if N>=50 then numeric digits 10 w= 50 say '─divisors─' center("the Nth number with exactly N divisors", w, '─') @.1= 2; ...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "bufio" "fmt" "log" "os" "strings" ) type vf = func() var history []string func hello() { fmt.Println("Hello World!") history = append(history, "hello") } func hist() { if len(history) == 0 { fmt.Println("No history") } else { for _, cmd := ...
trace off signal on syntax; signal on noValue cmdX='ATTRIB CAL CHDIR COPY DEL DIR ECHO EDIT FC FIND KEDIT LLL MEM MKDIR MORE REM REXX', 'RMDIR SET TYPE VER XCOPY' cls= 'CLS' @hist.= '*** command not defi...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "io/ioutil" "log" "strconv" "strings" ) type userInput struct{ formFeed, lineFeed, tab, space int } func getUserInput() []userInput { h := "0 18 0 0 0 68 0 1 0 100 0 32 0 114 0 45 0 38 0 26 0 16 0 21 0 17 0 59 0 11 " + "0 29 0 102 0 0 0 10 0 50 0 39 0 42 0 ...
parse arg iFID . if iFID=='' | iFID=="," then iFID= 'JIT.TXT' $= 'abcdefghijklmnopqrstuvwxyz'; _=$; upper _; $= "0123456789"$ || _; $$=$ || xrange() prompt= '────────── enter four positive integers or Quit' pag=1; lin=1; FF= 'c'x @.= ...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "runtime" ) type point struct { x, y float64 } func add(x, y int) int { result := x + y debug("x", x) debug("y", y) debug("result", result) debug("result+1", result+1) return result } func debug(s string, x interface{}) { _, _, lineNo, _ := runtime...
trace i parse arg maxDiv . if maxDiv=='' | maxDiv=="," then maxDiv= 1000 say 'maximum random divisor is:' maxDiv total= 0 do j=1 to 100 total= total + j/random(maxDiv) end say 'total=' total
Convert this Go block to REXX, preserving its control flow and logic.
package main import ( "bufio" "fmt" "log" "os" "strings" ) type state int const ( ready state = iota waiting exit dispense refunding ) func check(err error) { if err != nil { log.Fatal(err) } } func fsm() { fmt.Println("Please enter your option when promp...
10: say "Press D (deposit) or Q (quit)" 20: $=inkey(); upper $ if $=="D" then signal 50 if $=="Q" then exit signal 20 50: say "Press S (select) or R (refund)" 60: $=inkey(); ...
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import "fmt" func getDivisors(n int) []int { divs := []int{1, n} for i := 2; i*i <= n; i++ { if n%i == 0 { j := n / i divs = append(divs, i) if i != j { divs = append(divs, j) } } } return divs } func sum(div...
parse arg n m v . if n=='' | n=="," then n= 220 if m=='' | m=="," then m= 40 if v=='' | v=="," then v= 40 @zum= ' Zumkeller numbers are: ' sw= linesize() - 1 say if n>0 then sa...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "regexp" "strings" ) var reg = regexp.MustCompile(`(\.[0-9]+|[1-9]([0-9]+)?(\.[0-9]+)?)`) func reverse(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { r[i], r[j] = r[j], r[i] } return string(r) } func commatiz...
@. = @.1= "pi=3.14159265358979323846264338327950288419716939937510582097494459231" @.2= "The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." @.3= "-in Aus$+1411.8millions" @.4= "===US$0017440 millions=== (in 2000 dollars)" @.5= "123.e8000 is pretty big." @.6= "The land area of the earth is 57268900(2...
Change the following Go code into REXX without altering its purpose.
package main import ( "fmt" "math" "sort" "time" ) type term struct { coeff uint64 ix1, ix2 int8 } const maxDigits = 19 func toUint64(digits []int8, reverse bool) uint64 { sum := uint64(0) if !reverse { for i := 0; i < len(digits); i++ { sum = sum*10 + uint64(d...
numeric digits 20; w= digits() + digits() % 3 parse arg many . if many=='' | many=="," then many= 5 @g= 2002 2112 2222 2332 2442 2552 2662 2772 2882 2992 4000 4010 4030 4050 4070 4090 4100 , 4110 4120 4140 4160 4180 4210 4230 4250 4270 4290 4300 4320 4340 4360 4380...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "image" "reflect" ) type t struct { X int next *t } func main() { report(t{}) report(image.Point{}) } func report(x interface{}) { t := reflect.TypeOf(x) n := t.NumField() fmt.Printf("Type %v has %d fields:\n", t, n) fmt.Println("Name Type Exported") for i := 0; i...
d.1='' d.2='a23' d.3='101' d.4='123' d.5='12345678901234567890' d.6='abc' d.7='aBc' d.8='1' d.9='0' d.10='Walter' d.11='ABC' d.12='f23' d.13='123' t.1='A' t.2='B' t.3='I' t.4='L' t.5='M' t.6='N' t.7='O' t.8='S' t.9='U' t.10='V' t.11='W' t.12=...
Convert this Go snippet to REXX and keep its semantics consistent.
package main import "fmt" func main() { tree := eertree([]byte("eertree")) fmt.Println(subPalindromes(tree)) } type edges map[byte]int type node struct { length int edges suffix int } const evenRoot = 0 const oddRoot = 1 func eertree(s []byte) []node { tree := []node{ evenRoot: {le...
parse arg x . if x=='' | x=="," then x= 'eertree' L= length(x) @.= . $= do j=1 for L do k=1 for ...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import "fmt" func main() { tree := eertree([]byte("eertree")) fmt.Println(subPalindromes(tree)) } type edges map[byte]int type node struct { length int edges suffix int } const evenRoot = 0 const oddRoot = 1 func eertree(s []byte) []node { tree := []node{ evenRoot: {le...
parse arg x . if x=='' | x=="," then x= 'eertree' L= length(x) @.= . $= do j=1 for L do k=1 for ...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "log" "math/big" "strings" ) const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" var big0 = new(big.Int) var big58 = big.NewInt(58) func reverse(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { ...
s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" Numeric Digits 100 k='00010966776006953D5567439E5E39F86A0D273BEED61967F6'x n=c2d(k) o='' Do Until n=0 rem=n//58 n=n%58 o=o||substr(s,rem+1,1) End o=o||substr(s,1,1) Say reverse(o)
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "log" "math/big" "strings" ) const alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" var big0 = new(big.Int) var big58 = big.NewInt(58) func reverse(s string) string { r := []rune(s) for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 { ...
s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" Numeric Digits 100 k='00010966776006953D5567439E5E39F86A0D273BEED61967F6'x n=c2d(k) o='' Do Until n=0 rem=n//58 n=n%58 o=o||substr(s,rem+1,1) End o=o||substr(s,1,1) Say reverse(o)
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "bufio" "flag" "fmt" "io" "log" "math/rand" "os" "strings" "time" "unicode" "unicode/utf8" ) func main() { log.SetFlags(0) log.SetPrefix("markov: ") input := flag.String("in", "alice_oz.txt", "input file") n := flag.Int("n", 2, "number of words to use as prefix") runs := flag.Int...
parse arg ord fin iFID seed . if ord=='' | ord=="," then ord= 3 if fin=='' | fin=="," then fin= 300 if iFID=='' |iFID=="," then iFID='alice_oz.txt' if datatype(seed, 'W') then call random ,,seed sw = linesize() - 1 $= space( linein(iF...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "bufio" "fmt" "os" "strings" ) type playfairOption int const ( noQ playfairOption = iota iEqualsJ ) type playfair struct { keyword string pfo playfairOption table [5][5]byte } func (p *playfair) init() { var used [26]bool if p.pfo == noQ...
options replace format comments java crossref symbols nobinary -- input arguments: -- encipher/decipher IQ-switch key text -- encipher/decipher - -- a character E, D (default E; . is an alias for E) -- IQ-switch - -- a character I, Q (default I for I==J, Q for exclude Q; . is an alias for I) -- ...
Produce a functionally identical REXX code for the snippet given in Go.
package main import ( "bufio" "fmt" "os" "strings" ) type playfairOption int const ( noQ playfairOption = iota iEqualsJ ) type playfair struct { keyword string pfo playfairOption table [5][5]byte } func (p *playfair) init() { var used [26]bool if p.pfo == noQ...
options replace format comments java crossref symbols nobinary -- input arguments: -- encipher/decipher IQ-switch key text -- encipher/decipher - -- a character E, D (default E; . is an alias for E) -- IQ-switch - -- a character I, Q (default I for I==J, Q for exclude Q; . is an alias for I) -- ...
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "fmt" "strings" ) type dict map[string]bool func newDict(words ...string) dict { d := dict{} for _, w := range words { d[w] = true } return d } func (d dict) wordBreak(s string) (broken []string, ok bool) { if s == "" { return nil, true } typ...
parse arg a '/' x; a=space(a); x=space(x) if a=='' | a=="," then a= 'abcd abbc abcbcd acdbc abcdd' if x=='' | x=="," then x= 'a bc abc cd b' na= words(a) nx= words(x) say nx ' dictionary words: ' x a...
Port the provided Go code into REXX while preserving the original functionality.
package main import ( "fmt" "math" "strconv" "strings" ) func decToBin(d float64) string { whole := int64(math.Floor(d)) binary := strconv.FormatInt(whole, 2) + "." dd := d - float64(whole) for dd > 0.0 { r := dd * 2.0 if r >= 1.0 { binary += "1" ...
parse arg number toBase inBase digits . if toBase=='' | toBase=="," then toBase= 10 if inBase=='' | inBase=="," then inBase= 10 if digits=='' | digits=="," then digits= 60 if number=='' | number=="," then call err "no number specified." if \datatype(toBase, 'W') then call err "invalid...
Write the same code in REXX as shown below in Go.
package main import ( "fmt" "math" "strconv" "strings" ) func decToBin(d float64) string { whole := int64(math.Floor(d)) binary := strconv.FormatInt(whole, 2) + "." dd := d - float64(whole) for dd > 0.0 { r := dd * 2.0 if r >= 1.0 { binary += "1" ...
parse arg number toBase inBase digits . if toBase=='' | toBase=="," then toBase= 10 if inBase=='' | inBase=="," then inBase= 10 if digits=='' | digits=="," then digits= 60 if number=='' | number=="," then call err "no number specified." if \datatype(toBase, 'W') then call err "invalid...
Change the following Go code into REXX without altering its purpose.
package main import ( "fmt" "math" "math/rand" "time" ) type ff = func([]float64) float64 type parameters struct{ omega, phip, phig float64 } type state struct { iter int gbpos []float64 gbval float64 min []float64 max []float64 params parame...
* Test for McCormick function *--------------------------------------------------------------------*/ Numeric Digits 16 Parse Value '-.5 -1.5 1' With x y d fmin=1e9 Call refine x,y Do r=1 To 10 d=d/5 Call refine xmin,ymin End Say 'which is better (less) than' Say ' f(-.54719,-1.54719)='f(-.54719,-1.54719)...
Port the provided Go code into REXX while preserving the original functionality.
package main import "fmt" func sumDivisors(n int) int { sum := 1 k := 2 if n%2 == 0 { k = 1 } for i := 1 + k; i*i <= n; i += k { if n%i == 0 { sum += i j := n / i if j != i { sum += j } } } return sum }...
parse arg n cols tens over . if n='' | n=="," then n=2000 if cols='' | cols=="," | cols==0 then cols= 10 if tens='' | tens=="," then tens= 0 if over='' | over=="," then over= 20 tell= n>0; n= abs(n) call genP n * over...
Produce a functionally identical REXX code for the snippet given in Go.
package main import ( "fmt" "math/big" "time" ) var p []*big.Int var pd []int func partDiffDiff(n int) int { if n&1 == 1 { return (n + 1) / 2 } return n + 1 } func partDiff(n int) int { if n < 2 { return 1 } pd[n] = pd[n-1] + partDiffDiff(n-1) return pd[n] } ...
numeric digits 1000 parse arg lo hi . if lo=='' | lo=="," then lo= 0 if hi=='' | hi=="," then hi= lo @.= 0; @.0= 1; @.1= 1; @.2= 2; @.3= 3; @.4= 5 !.= @.; !.1= 1; !.3= 1; !.5= 1; !.7= 1; !.9= 1 w= length( commas(h...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "rcu" ) func reversed(n int) int { rev := 0 for n > 0 { rev = rev*10 + n%10 n = n / 10 } return rev } func main() { var special []int for n := 1; n < 200; n++ { divs := rcu.Divisors(n) revN := reversed(n) all := true ...
parse arg hi cols . if hi=='' | hi=="," then hi= 200 if cols=='' | cols=="," then cols= 10 w= 10 title= ' special divisors N that reverse(D) divides reverse(N) for all divisors' , ' D of N, where N <...
Translate this program into REXX but keep the logic exactly as in Go.
package main import ( "fmt" "math/big" ) func div(dividend, divisor []*big.Rat) (quotient, remainder []*big.Rat) { out := make([]*big.Rat, len(dividend)) for i, c := range dividend { out[i] = new(big.Rat).Set(c) } for i := 0; i < len(dividend)-(len(divisor)-1); i++ { out[i].Quo...
call set_dd '1 0 0 0 -1' Call set_dr '1 1 1 1' Call set_dd '1 -12 0 -42' Call set_dr '1 -3' q.0=0 Say list_dd '/' list_dr do While dd.0>=dr.0 q=dd.1/dr.1 Do j=1 To dr.0 dd.j=dd.j-q*dr.j End Call set_q q Call shift_dd End say 'Quotient:' mk_list_q() 'Remainder:' mk_list_dd() Exit set_dd: Parse Arg l...
Convert this Go block to REXX, preserving its control flow and logic.
package main import ( "fmt" "math/big" ) func div(dividend, divisor []*big.Rat) (quotient, remainder []*big.Rat) { out := make([]*big.Rat, len(dividend)) for i, c := range dividend { out[i] = new(big.Rat).Set(c) } for i := 0; i < len(dividend)-(len(divisor)-1); i++ { out[i].Quo...
call set_dd '1 0 0 0 -1' Call set_dr '1 1 1 1' Call set_dd '1 -12 0 -42' Call set_dr '1 -3' q.0=0 Say list_dd '/' list_dr do While dd.0>=dr.0 q=dd.1/dr.1 Do j=1 To dr.0 dd.j=dd.j-q*dr.j End Call set_q q Call shift_dd End say 'Quotient:' mk_list_q() 'Remainder:' mk_list_dd() Exit set_dd: Parse Arg l...
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import ( "bytes" "fmt" "io/ioutil" "log" ) func levenshtein(s, t string) int { d := make([][]int, len(s)+1) for i := range d { d[i] = make([]int, len(t)+1) } for i := range d { d[i][0] = i } for j := range d[0] { d[0][j] = j } for j ...
parse arg what iFID . if what==''|what=="," then what= 'complition' if iFID==''|iFID=="," then iFID= 'UNIXDICT.TXT' @abc= 'abcdefghijklmnopqrstuvwxyz' L= length(@abc) wrds= 0 dups= 0 ...
Generate a REXX translation of this Go snippet without changing its computational steps.
package main import ( "github.com/fogleman/gg" "math/rand" "time" ) const c = 0.00001 func linear(x float64) float64 { return x*0.7 + 40 } type trainer struct { inputs []float64 answer int } func newTrainer(x, y float64, a int) *trainer { return &trainer{[]float64{x, y, 1}, a} } type p...
Call init Call time 'R' try=0 Call show 0 Do d=1 To dots x=x.d y=y.d Parse Value x y 1 with inputs.0 inputs.1 inputs.2 answer.d=sign(y-f(x)) Select When f(x)<y Then r='<' When f(x)>y Then r='>' Otherwise r='=' End training.d=x y 1 answer.d End Do try=1 To tries Call time 'R' zz...
Preserve the algorithm and functionality while converting the code from Go to REXX.
package main import ( "fmt" "github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre" ) var pattern = "(*UTF)(*UCP)" + "[a-z][-a-z0-9+.]*:" + "(?=[/\\w])" + "(?: "[-\\w.~/%!$&'()*+,;=]*" + "(?:\\?[-\\w.~%!$&'()*+,;=/?]*)?" ...
$$= 'this URI contains an illegal character, parentheses and a misplaced full stop:', 'http://en.wikipedia.org/wiki/Erich_KΓ€stner_(camera_designer). (which is handled by http://mediawiki.org/).', 'and another one just to confuse the parser: http://en.wikipedia.org/wiki/-)', '")" is handled the wrong way by...
Keep all operations the same but rewrite the snippet in REXX.
package main import ( "fmt" "github.com/glenn-brown/golang-pkg-pcre/src/pkg/pcre" ) var pattern = "(*UTF)(*UCP)" + "[a-z][-a-z0-9+.]*:" + "(?=[/\\w])" + "(?: "[-\\w.~/%!$&'()*+,;=]*" + "(?:\\?[-\\w.~%!$&'()*+,;=/?]*)?" ...
$$= 'this URI contains an illegal character, parentheses and a misplaced full stop:', 'http://en.wikipedia.org/wiki/Erich_KΓ€stner_(camera_designer). (which is handled by http://mediawiki.org/).', 'and another one just to confuse the parser: http://en.wikipedia.org/wiki/-)', '")" is handled the wrong way by...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "crypto/md5" "io/ioutil" "log" "os" "path/filepath" "sort" "time" ) type fileData struct { filePath string info os.FileInfo } type hash [16]byte func check(err error) { if err != nil { log.Fatal(err) } } func checksum(filePath ...
sep=center(' files are identical in size and content: ',79,"═") tFID= 'c:\TEMP\FINDDUP.TMP' arg maxSize aDir if maxSize='' | maxSize="," then maxSize=1000000 aDir=strip(aDir) if right(aDir,1)\=='\' then aDir=aDir"\" "...
Produce a functionally identical REXX code for the snippet given in Go.
package main import ( "fmt" "io/ioutil" "log" "os" "regexp" "strings" ) type header struct { start, end int lang string } type data struct { count int names *[]string } func newData(count int, name string) *data { return &data{count, &[]string{name}} } var bmap = m...
parse arg iFID . if iFID=='' | iFID="," then iFID= 'BARELANG.HTM' call lineout iFID call linein ifid,1,0 noLa= 0; bare= 0; header=; heads= !.= 0 do re...
Write the same algorithm in REXX as shown in this Go implementation.
package main import ( "fmt" "rcu" "sort" ) func areSame(l1, l2 []int) bool { if len(l1) != len(l2) { return false } sort.Ints(l2) for i := 0; i < len(l1); i++ { if l1[i] != l2[i] { return false } } return true } func main() { i := 100 ...
do n=1 b= 2*n t= 3*n if verify(t, b)>0 then iterate q= 4*n if verify(q, b)>0 then iterate if ...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import ( "fmt" "rcu" "sort" ) func areSame(l1, l2 []int) bool { if len(l1) != len(l2) { return false } sort.Ints(l2) for i := 0; i < len(l1); i++ { if l1[i] != l2[i] { return false } } return true } func main() { i := 100 ...
do n=1 b= 2*n t= 3*n if verify(t, b)>0 then iterate q= 4*n if verify(q, b)>0 then iterate if ...
Translate this program into REXX but keep the logic exactly as in Go.
package main import "fmt" func reverse(s uint64) uint64 { e := uint64(0) for s > 0 { e = e*10 + (s % 10) s /= 10 } return e } func commatize(n uint) string { s := fmt.Sprintf("%d", n) le := len(s) for i := le - 3; i >= 1; i -= 3 { s = s[0:i] + "," + s[i:] } ...
numeric digits 20 parse arg palGaps if palGaps='' then palGaps= 20 100@@15 1000@@10 do until palGaps=''; parse var palGaps stuff palGaps; call palGap stuff end exit 0 palGap: pr...
Can you help me rewrite this code in REXX instead of Go, keeping it the same logically?
package main import "fmt" func reverse(s uint64) uint64 { e := uint64(0) for s > 0 { e = e*10 + (s % 10) s /= 10 } return e } func commatize(n uint) string { s := fmt.Sprintf("%d", n) le := len(s) for i := le - 3; i >= 1; i -= 3 { s = s[0:i] + "," + s[i:] } ...
numeric digits 20 parse arg palGaps if palGaps='' then palGaps= 20 100@@15 1000@@10 do until palGaps=''; parse var palGaps stuff palGaps; call palGap stuff end exit 0 palGap: pr...
Write the same algorithm in REXX as shown in this Go implementation.
package main import ( "fmt" "math" "rcu" "time" ) func sos(n int) []int { if n < 3 { return []int{} } var primes []int k := (n-3)/2 + 1 marked := make([]bool, k) limit := (int(math.Sqrt(float64(n)))-3)/2 + 1 for i := 0; i < limit; i++ { p := 2*i + 3 ...
parse arg n cols . if n=='' | n=="," then n= 100 if cols=='' | cols=="," then cols= 10 @.= .; lim= 16 * n do j=1 for n; do k=1 for n until _>lim; _= j + k + 2*j*k; @._= end ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "rcu" ) const LIMIT = 999999 var primes = rcu.Primes(LIMIT) func longestSeq(dir string) { pd := 0 longSeqs := [][]int{{2}} currSeq := []int{2} for i := 1; i < len(primes); i++ { d := primes[i] - primes[i-1] if (dir == "ascending" && d <= pd) || (di...
parse arg hi cols . if hi=='' | hi=="," then hi= 1000000 if cols=='' | cols=="," then cols= 10 call genP w= 10 call fRun 1; call show 1 call fRun 0; call...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "math/big" "rcu" ) func main() { const LIMIT = 11000 primes := rcu.Primes(LIMIT) facts := make([]*big.Int, LIMIT) facts[0] = big.NewInt(1) for i := int64(1); i < LIMIT; i++ { facts[i] = new(big.Int) facts[i].Mul(facts[i-1], big.NewInt(i)) ...
parse arg oLO oHI hip . if oLO=='' | oLO=="," then oLO= 1 if oHI=='' | oHI=="," then oHI= 11 if hip=='' | hip=="," then hip= 11000 call genP !!.= . bignum= !(hip) ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import "fmt" func padovanN(n, t int) []int { if n < 2 || t < 3 { ones := make([]int, t) for i := 0; i < t; i++ { ones[i] = 1 } return ones } p := padovanN(n-1, t) for i := n + 1; i < t; i++ { p[i] = 0 for j := i - 2; j >= i-n-1; ...
parse arg n m . if n=='' | n=="," then n= 15 if m=='' | m=="," then m= 8 w.= 1 do #=2 for m-1 @.= 0; @.0= 1; @.1= 1; @.2= 1 $= @.0 ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "math/big" ) var names = [10]string{"Platinum", "Golden", "Silver", "Bronze", "Copper", "Nickel", "Aluminium", "Iron", "Tin", "Lead"} func lucas(b int64) { fmt.Printf("Lucas sequence for %s ratio, where b = %d:\n", names[b], b) fmt.Print("First 15 elements: ") var ...
parse arg n bLO bHI digs . if n=='' | n=="," then n= 15 if bLO=='' | bLO=="," then bLO= 0 if bHI=='' | bHI=="," then bHI= 9 if digs=='' | digs=="," then digs= 32 numeric digits digs + length(.) metals= 'platinum ...
Transform the following Go implementation into REXX, maintaining the same output and logic.
package main import ( "fmt" "math/big" ) var names = [10]string{"Platinum", "Golden", "Silver", "Bronze", "Copper", "Nickel", "Aluminium", "Iron", "Tin", "Lead"} func lucas(b int64) { fmt.Printf("Lucas sequence for %s ratio, where b = %d:\n", names[b], b) fmt.Print("First 15 elements: ") var ...
parse arg n bLO bHI digs . if n=='' | n=="," then n= 15 if bLO=='' | bLO=="," then bLO= 0 if bHI=='' | bHI=="," then bHI= 9 if digs=='' | digs=="," then digs= 32 numeric digits digs + length(.) metals= 'platinum ...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "crypto/des" "encoding/hex" "fmt" "log" ) func main() { key, err := hex.DecodeString("0e329232ea6d0d73") if err != nil { log.Fatal(err) } c, err := des.NewCipher(key) if err != nil { log.Fatal(err) } src, err := hex.DecodeString("878787...
Parse Upper Arg action Select When action='?' Then Do Say "REXX des shows how '8787878787878787'X is encoded to" Say " '000000000000000'X" Say "REXX des DEC shows how '000000000000000'X is decoded to" Say " '8787878787878787'X" Exit End When a...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "fmt" "math" "rcu" ) var maxDepth = 6 var maxBase = 36 var c = rcu.PrimeSieve(int(math.Pow(float64(maxBase), float64(maxDepth))), true) var digits = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" var maxStrings [][][]int var mostBases = -1 func maxSlice(a []int) in...
parse arg widths . if widths=='' | widths=="," then widths= 5 call genP names= 'one two three four five six seven eight' $.= do j=1 for # do b=36 by -1 for 35; n= base(@.j, b) L= lengt...
Please provide an equivalent version of this Go code in REXX.
package main import ( "bytes" "fmt" "io/ioutil" "log" "strings" ) func contains(a []string, s string) bool { for _, e := range a { if e == s { return true } } return false } func oneAway(a, b string) bool { sum := 0 for i := 0; i < len(a); i++ { ...
lower: procedure; parse arg a; @= 'abcdefghijklmnopqrstuvwxyz'; @u= @; upper @u return translate(a, @, @u)
Convert the following code from Go to REXX, ensuring the logic remains intact.
package main import ( "bytes" "fmt" "io/ioutil" "log" "math/rand" "sort" "strings" "time" ) var adfgvx = "ADFGVX" var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" func distinct(bs []byte) []byte { var u []byte for _, b := range bs { if !bytes.Contains(u, []byte{b}...
cls eol=x2c(0D0A) ; msg="ATTACKAT1200AM" keyword= upper('lifeguard') ; cyph= 'ADFGVX' s_sort= keyword ; new_key= '' do while length(s_sort) > 0 nmax= 0 do i=1 to length(s_sort) ch= substr(s_sort,i,1) num= c2d(ch) if num > nmax then do nmax= num ...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import ( "bytes" "fmt" "io/ioutil" "log" "math/rand" "sort" "strings" "time" ) var adfgvx = "ADFGVX" var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" func distinct(bs []byte) []byte { var u []byte for _, b := range bs { if !bytes.Contains(u, []byte{b}...
cls eol=x2c(0D0A) ; msg="ATTACKAT1200AM" keyword= upper('lifeguard') ; cyph= 'ADFGVX' s_sort= keyword ; new_key= '' do while length(s_sort) > 0 nmax= 0 do i=1 to length(s_sort) ch= substr(s_sort,i,1) num= c2d(ch) if num > nmax then do nmax= num ...
Rewrite this program in REXX while keeping its functionality equivalent to the Go version.
package main import ( "fmt" "strings" ) func isDigit(b byte) bool { return '0' <= b && b <= '9' } func separateHouseNumber(address string) (street string, house string) { length := len(address) fields := strings.Fields(address) size := len(fields) last := fields[size-1] penult := fiel...
!= 'β”‚' $= "Plataanstraat 5" ! , "Straat 12" ! , "Straat 12 II" ! , "Dr. J. Straat 12" ! , "Dr. J. Straat 12 a" ! , "Dr. J. Straat 12-14" ! , ...
Produce a language-to-language conversion: from Go to REXX, same semantics.
package main import ( "fmt" "math/big" "strconv" "strings" ) func main() { var res []int64 for n := 0; n <= 50; n++ { ns := strconv.Itoa(n) k := int64(1) for { bk := big.NewInt(k) s := bk.Exp(bk, bk, nil).String() if strings.Contains(...
numeric digits 200 parse arg hi cols . if hi=='' | hi=="," then hi= 51 if cols=='' | cols=="," then cols= 10 w= 6 title=' smallest positive integer K where K**K contains N, 0 ...
Maintain the same structure and functionality when rewriting this code in REXX.
package main import ( "fmt" "strconv" ) var days = []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} func anchorDay(y int) int { return (2 + 5*(y%4) + 4*(y%100) + 6*(y%400)) % 7 } func isLeapYear(y int) bool { return y%4 == 0 && (y%100 != 0 || y%400 == 0) } var firs...
parse arg $ if $='' | $="," then $= , '01/06/1800 03/29/1875 12/07/1915 12/23/1970 05/14/2043 04/02/2077 04/02/2101' d= 'Sun Mon Tues Wednes Thurs Fri Satur' y.0= 3 7 7 4 2 6 4 1 5 3 7 5 y.1= 4 1 7 4 2 6 4 1 5 3 7 5...
Please provide an equivalent version of this Go code in REXX.
package main import ( "fmt" "strconv" ) var days = []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} func anchorDay(y int) int { return (2 + 5*(y%4) + 4*(y%100) + 6*(y%400)) % 7 } func isLeapYear(y int) bool { return y%4 == 0 && (y%100 != 0 || y%400 == 0) } var firs...
parse arg $ if $='' | $="," then $= , '01/06/1800 03/29/1875 12/07/1915 12/23/1970 05/14/2043 04/02/2077 04/02/2101' d= 'Sun Mon Tues Wednes Thurs Fri Satur' y.0= 3 7 7 4 2 6 4 1 5 3 7 5 y.1= 4 1 7 4 2 6 4 1 5 3 7 5...
Rewrite the snippet below in REXX so it works the same as the original Go code.
package main import "fmt" type vector = []float64 type matrix []vector func (m matrix) inverse() matrix { le := len(m) for _, v := range m { if len(v) != le { panic("Not a square matrix") } } aug := make(matrix, le) for i := 0; i < le; i++ { aug[i] = make(vecto...
Parse Arg seed nn If seed='' Then seed=23345 If nn='' Then nn=5 If seed='?' Then Do Say 'rexx gjmi seed n computes a random matrix with n rows and columns' Say 'Default is 23345 5' Exit End Numeric Digits 50 Call random 1,2,seed a='' Do i=1 To nn**2 a=a random(9)+1 End n2=words(a) Do n=2 To n2/2 If n**...
Port the following code from Go to REXX with equivalent syntax and logic.
package main import "fmt" type vector = []float64 type matrix []vector func (m matrix) inverse() matrix { le := len(m) for _, v := range m { if len(v) != le { panic("Not a square matrix") } } aug := make(matrix, le) for i := 0; i < le; i++ { aug[i] = make(vecto...
Parse Arg seed nn If seed='' Then seed=23345 If nn='' Then nn=5 If seed='?' Then Do Say 'rexx gjmi seed n computes a random matrix with n rows and columns' Say 'Default is 23345 5' Exit End Numeric Digits 50 Call random 1,2,seed a='' Do i=1 To nn**2 a=a random(9)+1 End n2=words(a) Do n=2 To n2/2 If n**...