Archived
1
0

Simple operations

This commit is contained in:
Sweet Bread
2022-11-19 16:35:47 +03:00
parent dc7b7d6d12
commit 0c190f2c71
4 changed files with 481 additions and 140 deletions
Binary file not shown.
-20
View File
@@ -1,20 +0,0 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "meow.sweetbread.lincalc",
"variantName": "debug",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 1,
"versionName": "1.0",
"outputFile": "app-debug.apk"
}
],
"elementType": "File"
}
@@ -5,117 +5,382 @@ import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.ImageButton
import android.widget.TextView
import kotlin.math.pow
import kotlin.math.sqrt
class MainActivity : AppCompatActivity() {
private var tmp_buf = ""
var buffer = listOf<String>()
private var act_ena = false
var priority = HashMap<String, Int>()
private var priority = HashMap<String, Int>()
private var tokensType = HashMap<String, Tokens>()
private val leftAssociative = arrayOf("^")
private var constants = HashMap<String, Double>()
@SuppressLint("MissingInflatedId", "CutPasteId")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
priority.put("+", 1)
priority.put("-", 1)
priority.put("*", 2)
priority.put("/", 2)
priority["("] = 0
priority["+"] = 1
priority["-"] = 1
priority["*"] = 2
priority["/"] = 2
priority["^"] = 3
val input = findViewById<TextView>(R.id.input)
tokensType["+"] = Tokens.Operations
tokensType["-"] = Tokens.Operations
tokensType["*"] = Tokens.Operations
tokensType["/"] = Tokens.Operations
tokensType["^"] = Tokens.Operations
tokensType["+"] = Tokens.Operations
tokensType["+"] = Tokens.Operations
tokensType["("] = Tokens.BracketOpen
tokensType[")"] = Tokens.BracketClose
findViewById<Button>(R.id.btn_0).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_1).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_2).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_3).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_4).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_5).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_6).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_7).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_8).setOnClickListener { btnInt(it as Button) }
findViewById<Button>(R.id.btn_9).setOnClickListener { btnInt(it as Button) }
constants["π"] = Math.PI
constants["e"] = Math.E
findViewById<Button>(R.id.btn_add).setOnClickListener { btnAct(it as Button) }
findViewById<Button>(R.id.btn_sub).setOnClickListener { btnAct(it as Button) }
findViewById<Button>(R.id.btn_mul).setOnClickListener { btnAct(it as Button) }
findViewById<Button>(R.id.btn_div).setOnClickListener { btnAct(it as Button) }
findViewById<Button>(R.id.btn_0).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_1).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_2).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_3).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_4).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_5).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_6).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_7).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_8).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_9).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_equ).setOnClickListener { toRpn() }
findViewById<Button>(R.id.btn_dot).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_add).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_sub).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_mul).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_div).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_bro).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_brc).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_pow).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_sqrt).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_pi).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_elr).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_x).setOnClickListener { btn_listener(it as Button) }
findViewById<Button>(R.id.btn_equ).setOnClickListener { btn_listener(it as Button) }
val image = findViewById<TextView>(R.id.input)
findViewById<ImageButton>(R.id.del).setOnClickListener {
image.text = image.text.dropLast(1)
}
findViewById<Button>(R.id.btn_sbm).setOnClickListener {
findViewById<TextView>(R.id.last_exp_out).text = findViewById<TextView>(R.id.input).text.toString()
val equations = findViewById<TextView>(R.id.input).text.toString().split('=')
if (equations.size == 1) {
val answer = evaluate(toRpn(tokenizer(equations[0])))
val value = if (answer.value.toString().split('.')[1] == "0")
(answer.value as Double).toInt().toString()
else (answer.value as Double).toFloat().toString()
findViewById<TextView>(R.id.left_out).text = answer.toString()
findViewById<TextView>(R.id.last_exp_out).text =
findViewById<TextView>(R.id.last_exp_out).text.toString() + " = " + value
findViewById<TextView>(R.id.input).text = ""
} else {
var left = evaluate(toRpn(tokenizer(equations[0])))
var right = evaluate(toRpn(tokenizer(equations[1])))
if (((left.type == Tokens.Number) and (right.type != Tokens.Number)) or
(left.type == Tokens.Linear) and (right.type == Tokens.Quadratic)) {
val tmp = right
left = right
right = tmp
}
findViewById<TextView>(R.id.left_out).text = left.toString()
findViewById<TextView>(R.id.right_out).text = right.toString()
if (left.type == Tokens.Number) {
val value = if (left.value.toString().split('.')[1] == "0")
(left.value as Double).toInt().toString()
else left.value.toString()
findViewById<TextView>(R.id.last_exp_out).text =
findViewById<TextView>(R.id.last_exp_out).text.toString() + " = " + value
findViewById<TextView>(R.id.input).text = ""
} else if (left.type == Tokens.Linear) {
val answer: Double
answer = if (right.type == Tokens.Number)
(left.value as Linear - right.value as Double).answer()
else
(left.value as Linear - right.value as Linear).answer()
val value: String
value = if (answer.toString().split('.')[1] == "0")
answer.toInt().toString()
else answer.toString()
findViewById<TextView>(R.id.last_exp_out).text =
findViewById<TextView>(R.id.last_exp_out).text.toString() +
"\n${(left.value as Linear).name} = " + value
findViewById<TextView>(R.id.input).text = ""
} else {
}
}
}
}
fun btnInt(btn: Button) {
val input = findViewById<TextView>(R.id.input)
input.text = input.text.toString() + btn.text
tmp_buf += btn.text
private fun tokenizer(exp: String): List<Token> {
var position = 0
var tokens = listOf<Token>()
act_ena = true
findViewById<TextView>(R.id.tmp_buf_out).text = tmp_buf
findViewById<TextView>(R.id.buf_out).text = buffer.toString()
while (position < exp.length) {
val chr = exp[position]
if (chr == ' ') {
position++
continue
} else if ((chr in '0'..'9') or (chr == '.')) {
var pos = position
while (pos < exp.length) {
if (!((exp[pos] in '0'..'9') or (exp[pos] == '.')))
break
pos++
}
fun btnAct(btn: Button) {
if (act_ena) {
val input = findViewById<TextView>(R.id.input)
input.text = input.text.toString() + btn.text
if (tmp_buf != "") {
buffer += tmp_buf
tmp_buf = ""
if (tokens.isNotEmpty()) {
if (tokens.last().type in arrayOf(Tokens.BracketClose, Tokens.Constant, Tokens.Variable))
tokens += Token(Tokens.Operations, "*")
}
act_ena = false
buffer += btn.text.toString()
tokens += Token(Tokens.Number, exp.substring(position, pos).toDouble())
position = pos
} else if (chr == 'X') {
if (tokens.isNotEmpty()) {
if (tokens.last().type in arrayOf(Tokens.BracketClose, Tokens.Constant, Tokens.Number))
tokens += Token(Tokens.Operations, "*")
}
findViewById<TextView>(R.id.buf_out).text = buffer.toString()
tokens += Token(Tokens.Variable, chr.toString())
position++
} else if (chr.toString() in constants.keys){
if (tokens.isNotEmpty()) {
if (tokens.last().type in arrayOf(Tokens.BracketClose, Tokens.Constant, Tokens.Variable, Tokens.Number))
tokens += Token(Tokens.Operations, "*")
}
fun toRpn() {
if (tmp_buf != "") {
buffer += tmp_buf
tmp_buf = ""
tokens += Token(Tokens.Constant, chr.toString())
position++
} else if (chr in 'a'..'z') {
var pos = position
while (pos < exp.length) {
if (exp[pos] !in 'a'..'z')
break
pos++
}
findViewById<TextView>(R.id.tmp_buf_out).text = tmp_buf
findViewById<TextView>(R.id.buf_out).text = buffer.toString()
var out_buf = listOf<String>()
var act_stc = listOf<String>()
Log.d("Meow!", buffer.toString())
for (token in buffer) {
if (token.toBigDecimalOrNull() != null)
out_buf += token
else if (token in listOf<String>("+", "-", "*", "/")) {
// if (act_stc.lastOrNull() == null)
// act_stc += token
// else if (priority[token]!! > priority[act_stc.last()]!!)
// act_stc += token
// else {
// out_buf += act_stc.last()
// act_stc = act_stc.dropLast(1)
// act_stc += token
// }
if (act_stc.lastOrNull() != null) {
while (priority[token]!! <= priority[act_stc.last()]!!) {
out_buf += act_stc.last()
act_stc = act_stc.dropLast(1)
if (act_stc.isEmpty())
if (tokens.isNotEmpty()) {
if (tokens.last().type in arrayOf(Tokens.BracketClose, Tokens.Constant, Tokens.Variable))
tokens += Token(Tokens.Operations, "*")
}
tokens += Token(Tokens.Function, exp.substring(position, pos))
position = pos
}
else if (tokensType.containsKey(chr.toString())) {
if (tokens.isNotEmpty()) {
if ((tokensType[chr.toString()]!! == Tokens.BracketOpen) and (tokens.last().type == Tokens.Number))
tokens += Token(Tokens.Operations, "*")
if ((chr == '-') and (tokens.last().type != Tokens.Number))
tokens += Token(Tokens.Number, 0.toDouble())
} else if (chr == '-')
tokens += Token(Tokens.Number, 0.toDouble())
tokens += Token(tokensType[chr.toString()]!!, chr.toString())
position++
} else {
findViewById<TextView>(R.id.input).error = "Неизвестный символ: ${exp[position]}"
break
}
}
act_stc += token
var new_tokens = listOf<Token>()
for (token in tokens) {
if (token.type == Tokens.Constant) {
new_tokens += Token(Tokens.Number, constants[token.value]!!)
} else {
new_tokens += token
}
Log.d("Meow!", "Act: $act_stc\tOut: $out_buf")
}
out_buf += act_stc.reversed()
Log.i("Meow!", new_tokens.toString())
return new_tokens
}
private fun btn_listener(btn: Button) {
val input = findViewById<TextView>(R.id.input)
input.text = input.text.toString() + btn.text.toString()
}
fun toRpn(tokens: List<Token>): List<Token> {
var out_buf = listOf<Token>()
val act_buf = arrayListOf<Token>()
for (token in tokens) {
if (token.type in arrayOf(Tokens.Number, Tokens.Variable))
out_buf += token
else if (token.type == Tokens.Function)
act_buf += token
else if (token.type == Tokens.Operations) {
if (act_buf.lastOrNull() != null) {
while (
(priority[token.value]!! < priority[act_buf.last().value]!!) or
((priority[token.value]!! == priority[act_buf.last().value]!!) and
(token.value in leftAssociative))) {
out_buf += act_buf.removeLast()
if (act_buf.isEmpty())
break
}
}
act_buf += token
} else if (token.type == Tokens.BracketOpen)
act_buf += token
else if (token.type == Tokens.BracketClose){
while (act_buf.last().type != Tokens.BracketOpen)
out_buf += act_buf.removeLast()
act_buf.removeLast()
if (act_buf.lastOrNull() != null) {
if (act_buf.last().type == Tokens.Function)
out_buf += act_buf.removeLast()
}
}
Log.d("Meow!", "Act: $act_buf\tOut: $out_buf")
}
out_buf += act_buf.reversed()
findViewById<TextView>(R.id.RPN_out).text = out_buf.toString()
tmp_buf = ""
buffer = listOf()
act_ena = false
findViewById<TextView>(R.id.input).text = ""
Log.d("Meow!", "toRpn: $out_buf")
return out_buf
}
fun evaluate(ext: List<Token>): Token {
var position = 0
var buffer = ext
var tmp_buf = listOf<Token>()
while (buffer.size != 1) {
val token = buffer[position]
if (token.type == Tokens.Function) {
if (token.value == "sqrt") {
tmp_buf = buffer.dropLast(ext.size - position + 1)
var res = Token(Tokens.Number, sqrt(buffer[position - 1].value as Double))
tmp_buf += res
tmp_buf += buffer.drop(position+1)
}
} else if (token.type == Tokens.Operations) {
val first = buffer[position-2]
val second = buffer[position-1]
//TODO: make operations with other objects
if (token.value == "+") {
tmp_buf = buffer.dropLast(ext.size - position + 2)
var res: Token
if ((first.type == Tokens.Number) and (second.type == Tokens.Number))
res = Token(Tokens.Number, (first.value as Double + second.value as Double))
else if ((first.type == Tokens.Variable) and (second.type == Tokens.Number))
res = Token(Tokens.Linear, Linear(first.value as String, second.value as Double, 0.toDouble()))
else
res = Token(Tokens.Linear, Linear(second.value as String, first.value as Double, 0.toDouble()))
tmp_buf += res
tmp_buf += buffer.drop(position+1)
} else if (token.value == "-") {
tmp_buf = buffer.dropLast(ext.size - position + 2)
val res = Token(Tokens.Number, (first.value as Double - second.value as Double))
tmp_buf += res
tmp_buf += buffer.drop(position+1)
} else if (token.value == "*") {
tmp_buf = buffer.dropLast(ext.size - position + 2)
val res: Token
res = if ((first.type == Tokens.Number) and (second.type == Tokens.Number))
Token(Tokens.Number, first.value as Double*second.value as Double)
else if ((first.type == Tokens.Number) and (second.type == Tokens.Variable))
Token(Tokens.Linear, Linear(second.value as String, 0.toDouble(), first.value as Double))
else if ((first.type == Tokens.Variable) and (second.type == Tokens.Number))
Token(Tokens.Linear, Linear(first.value as String, 0.toDouble(), second.value as Double))
else //if ((first.type == Tokens.Variable) and (second.type == Tokens.Variable))
Token(Tokens.Quadratic, Quadratic(first.value as String, 0.toDouble(), 0.toDouble(), 2.toDouble()))
tmp_buf += res
tmp_buf += buffer.drop(position+1)
} else if (token.value == "/") {
tmp_buf = buffer.dropLast(ext.size - position + 2)
val res = Token(Tokens.Number, first.value as Double/second.value as Double)
tmp_buf += res
tmp_buf += buffer.drop(position+1)
} else if (token.value == "^") {
tmp_buf = buffer.dropLast(ext.size - position + 2)
val res = Token(
Tokens.Number, (first.value as Double)
.pow(second.value as Double)
)
tmp_buf += res
tmp_buf += buffer.drop(position + 1)
}
} else {
position++
continue
}
buffer = tmp_buf
position = 0
Log.d("Meow!", buffer.toString())
}
return buffer[0]
}
}
enum class Tokens {
Number,
Operations,
Function,
BracketOpen,
BracketClose,
Constant,
Variable,
Linear,
Quadratic
}
class Token (val type: Tokens, var value: Any) {
override fun toString(): String {
return "<$type, $value>"
}
}
open class MathObject(val value: Any) {
operator fun minus(num: MathObject): MathObject {
return MathObject(value)
}
}
class Linear(val name: String, private val add: Double, private val mul: Double) : MathObject("$mul*$name+$add") {
//TODO: Implement more methods
override fun toString(): String {
return "$mul*$name+$add"
}
operator fun minus(num: Double): Linear {
return Linear(name, add-num, mul)
}
operator fun minus(lin: Linear): Linear {
// if (name != lin.name) throw IllegalArgumentException
return Linear(name, add-lin.add, mul-lin.mul)
}
fun answer() = -add/mul
}
class Quadratic(name: String, add: Double, mul: Double, pow: Double) {
//TODO: Implement more methods
}
+138 -42
View File
@@ -14,29 +14,117 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tmp_buf_out"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/input" />
<TextView
android:id="@+id/buf_out"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tmp_buf_out" />
<TextView
android:id="@+id/RPN_out"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/last_exp_out" />
<TextView
android:id="@+id/left_out"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/RPN_out" />
<TextView
android:id="@+id/right_out"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/left_out" />
<ScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buf_out" />
app:layout_constraintTop_toBottomOf="@+id/RPN_out">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btn_sbm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Вычислить" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/btn_x"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="X" />
<Button
android:id="@+id/btn_pi"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="π" />
<Button
android:id="@+id/btn_elr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="e" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<Button
android:id="@+id/btn_bro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="(" />
<Button
android:id="@+id/btn_brc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text=")" />
<Button
android:id="@+id/btn_pow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="^" />
<Button
android:id="@+id/btn_sqrt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="sqrt" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/linearLayout2"
@@ -49,7 +137,7 @@
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
@@ -62,21 +150,18 @@
android:id="@+id/btn_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="1" />
<Button
android:id="@+id/btn_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="2" />
<Button
android:id="@+id/btn_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3" />
</LinearLayout>
@@ -89,21 +174,18 @@
android:id="@+id/btn_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="4" />
<Button
android:id="@+id/btn_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5" />
<Button
android:id="@+id/btn_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="6" />
</LinearLayout>
@@ -117,21 +199,18 @@
android:id="@+id/btn_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="7" />
<Button
android:id="@+id/btn_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8" />
<Button
android:id="@+id/btn_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="9" />
</LinearLayout>
@@ -148,30 +227,19 @@
android:text="0" />
<Button
android:id="@+id/btn_bro"
android:id="@+id/btn_dot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(" />
android:text="." />
<Button
android:id="@+id/btn_brc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=")" />
<Button
android:id="@+id/btn_equ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="=" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
<Button
@@ -203,8 +271,36 @@
android:text="/" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<Button
android:id="@+id/btn_equ"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="=" />
<ImageButton
android:id="@+id/del"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@android:drawable/ic_input_delete" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/last_exp_out"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/input" />
<!-- <EditText-->
<!-- android:id="@+id/function_in"-->
<!-- android:layout_width="0dp"-->