<commit_before>package main

import "github.com/nsf/gothic"
import "math/big"

var args [2]*big.Int
var lastOp string
var afterOp = true

func applyOp(op string, ir *gothic.Interpreter) {
	var num string
	ir.EvalAs(&num, "set calcText")
	if args[0] == nil {
		if op != "=" {
			args[0] = big.NewInt(0)
			args[0].SetString(num, 10)
		}
	} else {
		args[1] = big.NewInt(0)
		args[1].SetString(num, 10)
	}

	afterOp = true

	if args[1] == nil {
		lastOp = op
		return
	}

	switch lastOp {
	case "+":
		args[0] = args[0].Add(args[0], args[1])
	case "-":
		args[0] = args[0].Sub(args[0], args[1])
	case "/":
		args[0] = args[0].Div(args[0], args[1])
	case "*":
		args[0] = args[0].Mul(args[0], args[1])
	}

	lastOp = op
	args[1] = nil

	ir.Eval("set calcText %{}", args[0])
	if op == "=" {
		args[0] = nil
	}
}

func main() {
	ir := gothic.NewInterpreter(`
set lastOp {}
set calcText 0
wm title . "GoCalculator"

ttk::frame .f
ttk::entry .f.lastop -textvariable lastOp -justify center -state readonly -width 3
ttk::entry .f.entry -textvariable calcText -justify right -state readonly

grid .f.lastop .f.entry -sticky we
grid columnconfigure .f 0 -weight 0
grid columnconfigure .f 1 -weight 1

ttk::button .0 -text 0 -command { appendNum 0 }
ttk::button .1 -text 1 -command { appendNum 1 }
ttk::button .2 -text 2 -command { appendNum 2 }
ttk::button .3 -text 3 -command { appendNum 3 }
ttk::button .4 -text 4 -command { appendNum 4 }
ttk::button .5 -text 5 -command { appendNum 5 }
ttk::button .6 -text 6 -command { appendNum 6 }
ttk::button .7 -text 7 -command { appendNum 7 }
ttk::button .8 -text 8 -command { appendNum 8 }
ttk::button .9 -text 9 -command { appendNum 9 }
ttk::button .pm    -text +/- -command plusMinus
ttk::button .clear -text C -command clearAll
ttk::button .eq    -text = -command { applyOp = }
ttk::button .plus  -text + -command { applyOp + }
ttk::button .minus -text - -command { applyOp - }
ttk::button .mul   -text * -command { applyOp * }
ttk::button .div   -text / -command { applyOp / }

grid .f -   -      .div   -sticky nwes
grid .7 .8  .9     .mul   -sticky nwes
grid .4 .5  .6     .minus -sticky nwes
grid .1 .2  .3     .plus  -sticky nwes
grid .0 .pm .clear .eq    -sticky nwes

grid configure .f -sticky wes

foreach w [winfo children .] {grid configure $w -padx 3 -pady 3}<commit_msg>Typo. Display frame should be sticky to east and west, not south.<commit_after>package main

import "github.com/nsf/gothic"
import "math/big"

var args [2]*big.Int
var lastOp string
var afterOp = true

func applyOp(op string, ir *gothic.Interpreter) {
	var num string
	ir.EvalAs(&num, "set calcText")
	if args[0] == nil {
		if op != "=" {
			args[0] = big.NewInt(0)
			args[0].SetString(num, 10)
		}
	} else {
		args[1] = big.NewInt(0)
		args[1].SetString(num, 10)
	}

	afterOp = true

	if args[1] == nil {
		lastOp = op
		return
	}

	switch lastOp {
	case "+":
		args[0] = args[0].Add(args[0], args[1])
	case "-":
		args[0] = args[0].Sub(args[0], args[1])
	case "/":
		args[0] = args[0].Div(args[0], args[1])
	case "*":
		args[0] = args[0].Mul(args[0], args[1])
	}

	lastOp = op
	args[1] = nil

	ir.Eval("set calcText %{}", args[0])
	if op == "=" {
		args[0] = nil
	}
}

func main() {
	ir := gothic.NewInterpreter(`
set lastOp {}
set calcText 0
wm title . "GoCalculator"

ttk::frame .f
ttk::entry .f.lastop -textvariable lastOp -justify center -state readonly -width 3
ttk::entry .f.entry -textvariable calcText -justify right -state readonly

grid .f.lastop .f.entry -sticky we
grid columnconfigure .f 0 -weight 0
grid columnconfigure .f 1 -weight 1

ttk::button .0 -text 0 -command { appendNum 0 }
ttk::button .1 -text 1 -command { appendNum 1 }
ttk::button .2 -text 2 -command { appendNum 2 }
ttk::button .3 -text 3 -command { appendNum 3 }
ttk::button .4 -text 4 -command { appendNum 4 }
ttk::button .5 -text 5 -command { appendNum 5 }
ttk::button .6 -text 6 -command { appendNum 6 }
ttk::button .7 -text 7 -command { appendNum 7 }
ttk::button .8 -text 8 -command { appendNum 8 }
ttk::button .9 -text 9 -command { appendNum 9 }
ttk::button .pm    -text +/- -command plusMinus
ttk::button .clear -text C -command clearAll
ttk::button .eq    -text = -command { applyOp = }
ttk::button .plus  -text + -command { applyOp + }
ttk::button .minus -text - -command { applyOp - }
ttk::button .mul   -text * -command { applyOp * }
ttk::button .div   -text / -command { applyOp / }

grid .f -   -      .div   -sticky nwes
grid .7 .8  .9     .mul   -sticky nwes
grid .4 .5  .6     .minus -sticky nwes
grid .1 .2  .3     .plus  -sticky nwes
grid .0 .pm .clear .eq    -sticky nwes

grid configure .f -sticky we

foreach w [winfo children .] {grid configure $w -padx 3 -pady 3}
{'fraction_non_alphanumeric': 0.16079436258808455, 'fraction_numerical': 0.03416613282084134, 'mean_word_length': 2.877483443708609, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3345542', 'n_tokens_mistral': 1945, 'n_tokens_neox': 1836, 'n_words': 572}